From patchwork Wed May 17 15:04:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13245169 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 EF460C77B7D for ; Wed, 17 May 2023 15:06:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9218390000B; Wed, 17 May 2023 11:06:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8D277900003; Wed, 17 May 2023 11:06:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 79A4590000B; Wed, 17 May 2023 11:06:18 -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 6C0B2900003 for ; Wed, 17 May 2023 11:06:18 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id E9605C060A for ; Wed, 17 May 2023 15:06:17 +0000 (UTC) X-FDA: 80800072794.19.8F7C8D6 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf03.hostedemail.com (Postfix) with ESMTP id 36B612036C for ; Wed, 17 May 2023 15:04:13 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=H1AVzqyO; spf=pass (imf03.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684335855; a=rsa-sha256; cv=none; b=14f8eQU0oeBvraHKhkfLW3twuhnlMZaOQ6JuBH/c9dVh3yG1V+uqfPKRwG+Xpa+gChw0O9 cT48ZHr4jmXz24WQD5RopOF/Ff/lCMrZLoIVu4eW3yWZHbdqrPqHaqt1Pl2aZbZLRTsIg0 kiiTMrgeHWiAHDp3iDJUrnFe5+ttcOA= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=H1AVzqyO; spf=pass (imf03.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=1684335855; 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:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=EUoskz06alEGKkrRXumx8WXCB+JzMICYOzDauyzYlD4=; b=XAGHsnDSiRoyXm7ttQwoAiPoH420dgAxXZYQ5T1DPWqCbt6qLTO2gfOjeB7T+5YNGsvkco FOEU9kjp9hJ0x+JegDD6boz3mVLMYi1Y0zCO/WdA8ctIzpmdZ2nIePkEtQOtD0isdg8yKj wibOyPxuSBY4l1ylTKBNg5xDcqKDVYw= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684335852; 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: content-transfer-encoding:content-transfer-encoding; bh=EUoskz06alEGKkrRXumx8WXCB+JzMICYOzDauyzYlD4=; b=H1AVzqyOQRl7WfcfMV3OablyaMN8yCOUCjP/TJA5BHoitFF39F+IH7o9F1F/OOTTs/onB1 qCRYb8PlqESuXqod7Mg/Qd/ZdrxmFDoziD/IVdeav8bOgP6lrcM+PwuBbhTHHFIiizeB2c O2JVK62BQYo5DC+DRLxNkWR3i8GKFVY= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-113-OoowbAqaNkaotf29_egNxw-1; Wed, 17 May 2023 11:04:11 -0400 X-MC-Unique: OoowbAqaNkaotf29_egNxw-1 Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-7592c8fe630so1360785a.0 for ; Wed, 17 May 2023 08:04:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684335850; x=1686927850; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=EUoskz06alEGKkrRXumx8WXCB+JzMICYOzDauyzYlD4=; b=cjAGJ/mBebQAz/OYyM0iiWq6cQnBh4vAliF0lbXozeqiTp4bJvLmu2GD4akmxSLHP1 wZdICr+idl76Pi/sZn7do4MO++3mAmxKJDnW3lEWccF4LcmZ4ADYlI1BmCXl2OIsL7kn UBouoFnuJG9Uh4HosoXIYwQO/34WTPm72i0f9AS1hAW0HvoA6d+P6X+pZraLk6+TOs5A Ym3vFE+mDraTe5C/P2MrzpTsmgWC/f/QDc8t7ztVBOaXN9VsklFCd1VsOsOigzGte51r BnlgZ6jasRFgeTYs8lSBxliOhl9uu3JP/ZBVH5zmWi5M8FlCErhAAWyXnVLY+7fEHoGG qNPA== X-Gm-Message-State: AC+VfDzh8uKSVGg/dBkzbXpoOoxSIDCpGOnPiiyKevrX5TdXJ18DyXX2 WAAtckjM+xbsnu55ZpQTENRFuh0pL+0xZ3MRcJ+PtL/QkzlEjTXj+j4DZVKErxpH+DpBvSN5a7p bEHICNKfVxpI= X-Received: by 2002:a05:6214:b65:b0:61b:76dd:b643 with SMTP id ey5-20020a0562140b6500b0061b76ddb643mr5556172qvb.4.1684335850731; Wed, 17 May 2023 08:04:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7xgOY1O5oVXe1NC6GuvFKRBlHEK+Cti7Nt9EV78tAkmZgzxu+H/s1ciiZK62BAp7RGcvV/QQ== X-Received: by 2002:a05:6214:b65:b0:61b:76dd:b643 with SMTP id ey5-20020a0562140b6500b0061b76ddb643mr5556114qvb.4.1684335850117; Wed, 17 May 2023 08:04:10 -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 u10-20020a05620a120a00b0074d4cf8f9fcsm661141qkj.107.2023.05.17.08.04.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 May 2023 08:04:09 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Lorenzo Stoakes , Andrew Morton , "Liam R . Howlett" , Mark Rutland , Andrea Arcangeli , Mike Rapoport , peterx@redhat.com, Alexander Viro Subject: [PATCH 0/2] mm/uffd: Fix vma merge/split Date: Wed, 17 May 2023 11:04:06 -0400 Message-Id: <20230517150408.3411044-1-peterx@redhat.com> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 36B612036C X-Stat-Signature: cot9mq4oegncut16gbx3gu1naqfkg3bh X-HE-Tag: 1684335853-25246 X-HE-Meta: U2FsdGVkX1/hkVhhT/p4UIGmEaflz/zz7F2MTbmhQcogGe6mROfMARr6W9NEt+P44qhAP9qbrzQrxkyTvvN952iox8Unq1dvv4eUEZUoxvYHnzCdgwY5U71fewUAqY3cKYxicoZ3Jf0ncgJ6f+dfJBSFw48wq9NenPa66TEjUJC9dMzvQp0nMWhxdmbfJglnZ06rStdQG1+l9zkCfAmquzKUPZ2N/RtpCzSHqJWu7I/heTJmsTPA7ZA5N5zDPf1N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vwXMpOP7lcgDyR8oyM1KD5ke3vpyT1tbUKX6XupM/bJGNRJkzpaSzk= 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: This series contains two patches that fix vma merge/split for userfaultfd on two separate issues. The patchset is based on akpm/mm-hotfixes-unstable with 2f628010799e reverted (where patch 1 should be used to replace it which seems to be the plan we reached). The major changes comparing to the patches I attached to the reply: - Fixed up patch 1 on vma_prev() side effect pointed out by Liam, further I simplified it to just bring back the two lines missing, so even shorter. - Add fixes tags for both patches, I decided to copy stable for both patch in this version, even though patch 2 is more or less tentative (as I don't see anything wrong besides vma didn't trigger a merge). Patch 1 fixes a regression since 6.1+ due to something we overlooked when converting to maple tree apis. The plan is we use patch 1 to replace the commit "2f628010799e (mm: userfaultfd: avoid passing an invalid range to vma_merge())" in mm-hostfixes-unstable tree if possible, so as to bring uffd vma operations back aligned with the rest code again. Patch 2 fixes a long standing issue that vma can be left unmerged even if we can for either uffd register or unregister. Many thanks to Lorenzo on either noticing this issue from the assert movement patch, looking at this problem, and also provided a reproducer on the unmerged vma issue [1]. Please have a look, thanks. [1] https://gist.github.com/lorenzo-stoakes/a11a10f5f479e7a977fc456331266e0e Peter Xu (2): mm/uffd: Fix vma operation where start addr cuts part of vma mm/uffd: Allow vma to merge as much as possible fs/userfaultfd.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)