From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18FB0C77B7A for ; Tue, 16 May 2023 22:32:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 89B08900007; Tue, 16 May 2023 18:32:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 84956900002; Tue, 16 May 2023 18:32:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6E9CE900007; Tue, 16 May 2023 18:32:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 5AE27900002 for ; Tue, 16 May 2023 18:32:45 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 28BB91A041A for ; Tue, 16 May 2023 22:32:45 +0000 (UTC) X-FDA: 80797569090.15.CA65D63 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf24.hostedemail.com (Postfix) with ESMTP id AAB2B180011 for ; Tue, 16 May 2023 22:32:42 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=SigYsiay; spf=pass (imf24.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684276363; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=8MJzaFBsdors8Mev/Yq9G84UySkOY2kS3Vs3xLy2EDk=; b=QMz59/bDZ8vv3nJJ7i+5ZTZUJ02dKhQb/90Yeag64GZU5ghg+1uoMVpYU5mK8ogHvOcshE ac/dIos9QKFDLWTbL24j9KWdFEHymrwcE7+1pnF/6lYJvSUZW/tqJH/v/16Bx1xAV+I0T5 2pbd3EatKgSlwD8+eZ0aCkBdndISwok= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684276363; a=rsa-sha256; cv=none; b=2jpB7P2kXYk83Lbok/UtibfJuy3avyXoKnb4WLQvAZV/TjqEXV6thReQRGAyVHkaWQlzog eujunhgAKpfoPeUYQg3qWlpWd565cIW1M4Br0vlZzGK4wY6xFwjDf805Zt5YMz+bWrhOvp ebBJ55KL4/swklxzglBihaNRjxqZjRw= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=SigYsiay; spf=pass (imf24.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684276362; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=8MJzaFBsdors8Mev/Yq9G84UySkOY2kS3Vs3xLy2EDk=; b=SigYsiaycqK3Y2XbrJHdK53y4U2gfuB0vZOA18F4fWUr53ruOfbvj7WYz4h1LwVOoOh/zu KQwRZzVnodm++XiyZ5sqdeqsYJG6ZfPqIF6lUj5tHkqQKNMNyoQNVDHUJswAhjWKB1YHss 2J/lxcklbunstD6jXtBI3obqnakLi+Q= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-433-RfaEhyr6NLy_9aJ-B3UF1w-1; Tue, 16 May 2023 18:32:40 -0400 X-MC-Unique: RfaEhyr6NLy_9aJ-B3UF1w-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-61a3c7657aeso175676d6.0 for ; Tue, 16 May 2023 15:32:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684276360; x=1686868360; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=8MJzaFBsdors8Mev/Yq9G84UySkOY2kS3Vs3xLy2EDk=; b=cJUOt3neXf1t8zzSkL2a4Ra7c3cwhFOQ7tSEpv9D3BrJwTaa+AlmnVfInztoSAgOeg E48CYEb7QAgxd0bsChiM99iNpwkv007qYvNjLgJd2q6pO8Ovka2vF3T7Nkn280PxTBvx 4oH/eRY4Z3rvFU81lgsMcTtWpjsZ9ZiperNYpeYgTQ2mHvvLYsF0mhysZFhPvxr2Y+vd M06Qp2fFSX4LbBC0hutF01UejUEySLxb3A0b5uYFEs2JSRG/X+A1N3ehWx2yOdq0gxeo K+mY4qAtcXgN05qDCOZBZI3IH8hyEFm2k72H6KGBonYjGDJXGGYEnzObnNAS7sWD9kxA v5Pw== X-Gm-Message-State: AC+VfDwqDWsLdBQjnRTH+imGy7ElCtjtqzzY/A8H+FlYXVcrcwVhXHl6 SKx9KtwZBXcokdn8JbdJb9p57HOiCi9Z/6LI4R7rCuUdr8QN9QRzbism1szBDOdMkattwBxfAfY DMldh5V9zQjM= X-Received: by 2002:a05:6214:b65:b0:61b:76dd:b643 with SMTP id ey5-20020a0562140b6500b0061b76ddb643mr1732508qvb.4.1684276360429; Tue, 16 May 2023 15:32:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6k7yQTt9V9ROhTxyHKalGuCi+1pP62Ju0r38kxo7lRU1SOLrA2ijBKl86I/lNOhQE+n97+Sw== X-Received: by 2002:a05:6214:b65:b0:61b:76dd:b643 with SMTP id ey5-20020a0562140b6500b0061b76ddb643mr1732485qvb.4.1684276360096; Tue, 16 May 2023 15:32:40 -0700 (PDT) Received: from x1n (bras-base-aurron9127w-grc-62-70-24-86-62.dsl.bell.ca. [70.24.86.62]) by smtp.gmail.com with ESMTPSA id d10-20020a0ce44a000000b005ef54657ea0sm5926054qvm.126.2023.05.16.15.32.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 May 2023 15:32:39 -0700 (PDT) Date: Tue, 16 May 2023 18:32:38 -0400 From: Peter Xu To: Lorenzo Stoakes Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , Mike Rapoport , Mark Rutland , "Liam R . Howlett" , Alexander Viro , Christian Brauner Subject: Re: [PATCH v2] mm: userfaultfd: avoid passing an invalid range to vma_merge() Message-ID: References: <20230515193232.67552-1-lstoakes@gmail.com> <20abea10-5307-498b-b9df-8f0b2fed1701@lucifer.local> <9739133c-3ee7-4e94-a6a8-783045a50ac6@lucifer.local> <9174fd63-5d32-4b83-bf6b-27f9cb00bd9e@lucifer.local> MIME-Version: 1.0 In-Reply-To: <9174fd63-5d32-4b83-bf6b-27f9cb00bd9e@lucifer.local> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Stat-Signature: crgh6knsoqmtyi1bmpytgxbizejyqg1z X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: AAB2B180011 X-Rspam-User: X-HE-Tag: 1684276362-307327 X-HE-Meta: U2FsdGVkX18K/lbGQ+sOy0+y0tFbTekJYKmVey862PkAjRYloRLna99eLqcczP5ecxJoOoMVvYK6c8yX8tm4oqxdFb20UmrwmobcKU0c9SueG5rtkeqC3yzUeMVxzmqpj4l/DvyOjBabPdufYoUZwa7IDVbYJaBsY6Icq4qD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utzz1ttg136OuJwi7Mj6sSJfUJ405aGHPk62FjLffCKjHE+wid6DN60ymM6g75Tpkg9Ou8W5phAamZjsYjETk2QmpMS6OlZFs9sZ7oW5Vc7sVLu2Yp/8V4whmzgBVOA8MMEvhYIFIczhaT X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, May 16, 2023 at 11:15:54PM +0100, Lorenzo Stoakes wrote: > I'll try to address this in a later series, I don't think there's much use > in going round in circles on this. If you dislike that series, you're > welcome to provide negative feedback there, I don't think there's much use > in discussing further here. I'm happy to read it, sorry if any of my wording was intruding, I didn't mean so. I think there's chance at least on generalizing vma flag change cases, even though I'm not sure whether vma_merge() needs change. Maybe it can be another layer on top of it while keeping vma_merge() as is, but I can't tell. > We've seen a regression on invalid input to vma_merge() (explicitly I mean > triggering a VM_WARN_ON()) and VMA fragmentation you were not aware of > here, that does not strike me as a great + clear interface. Yes, the code needs time to read through, even the interface. I don't think I fully digested that myself. [...] > Ah the thanks you get for contributing a regression fix _and_ a repro - a > nack :) will you at least give me some kind of a tag... or buy me a beer? > ;) I can. :) We actually met on the conference, if I'll be able to meet you somewhere that's what I can do. I was probably hashing in the words, sorry about that if so, and thanks for looking at this issue! I appreciate both your assertion patch and the png documentation file. It's just that I feel irresponsible when we were talking about having vma not merged correctly but then the discussion tried to end at there saying it kept so so it's fine. IMHO we should look into that problem or something could be missing here. Then when I was looking into that not-merged issue I found that it's not uffd that's special. > > Before that I'd like to know whether you agree that the new patch 1 (I'll > > fixup the vma_prev() side effect) could be a better solution than the > > current one, no matter whether we need a full revert or not. > > In principle it looks fine actually (pending Liam's assessment), case 4/5 > should handle it, but I feel like we need a comment (perhaps only in commit > msg) to make clear that we are ensuring that the inputs to vma_merge() are > either clamped to VMAs or case 4/5. > > Let's see what Liam thinks, then let me check it locally to give a final > OK, if I may. Sounds perfect here. Thanks a lot. -- Peter Xu