From patchwork Wed May 17 19:09:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13245566 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 EAC3CC77B75 for ; Wed, 17 May 2023 19:09:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6A398900008; Wed, 17 May 2023 15:09:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 62C95900003; Wed, 17 May 2023 15:09:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4A5D4900008; Wed, 17 May 2023 15:09:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 343FA900003 for ; Wed, 17 May 2023 15:09:26 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 01F2EC066E for ; Wed, 17 May 2023 19:09:25 +0000 (UTC) X-FDA: 80800685490.05.1618D64 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf02.hostedemail.com (Postfix) with ESMTP id EDFD180010 for ; Wed, 17 May 2023 19:09:23 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LvI8ybcM; spf=pass (imf02.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.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=1684350564; 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=TNueZVKvKbqYKsThUlmAqqW8H5EGDZrswTYYHFq1+MY=; b=OjYyl+Q9f0I1EcxnhUDz+ju8Qgs5j/REBPw7QD0t2BJgEnozmaYZYE3OBVO2M3jnNf4SLm DLTYYs3iHTV7BoFj8vbGQC0T4bvvoRgwhVkLcAk1EMB0bBK8Wb6mOoRHO9otwOZUAZcwEx LsP0SlPzhQz7fZyvXbcsTLijInUJLPI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684350564; a=rsa-sha256; cv=none; b=TAajnmJl643XQwU46q3W2u7AYWZDvolqzVJcPNfw9YBuBn+I/JYCZUez/HzjQrP8cKoWGJ qyHoZyFMkeXwbG4vL8hhW7IlHXZmV2trdWPoywCsoLnkT4xzV7A4y4f9jN/QTgi7MIj2t8 PJIqxwl5+k+FnKwuQ5JV1wh79DHEzg4= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LvI8ybcM; spf=pass (imf02.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.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=1684350563; 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=TNueZVKvKbqYKsThUlmAqqW8H5EGDZrswTYYHFq1+MY=; b=LvI8ybcMGbvD/UZaCJxBn3km2FcjG4mk8q5c2bRCgdDcW0s8U0W1UwGxlSO06ZIVcmsqZe EEBsoHjCp8doG28LvxYVzXgHT5fxZP+Iolpp05P4zCo7eUg84tE1dqLrRbpdKsuNuih6yG bGsK0C9gVlR5N/tlEH0Ps/RBgfKu0Dw= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-354-D0UNtCA6NA2bVFU2f3YOuw-1; Wed, 17 May 2023 15:09:22 -0400 X-MC-Unique: D0UNtCA6NA2bVFU2f3YOuw-1 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-3f384644b08so2249011cf.0 for ; Wed, 17 May 2023 12:09:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684350559; x=1686942559; 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=TNueZVKvKbqYKsThUlmAqqW8H5EGDZrswTYYHFq1+MY=; b=cRr4YwwwktZUwKB+G/VFBqjbBPNG8kO9r5ccPXBiLJ5+YrOZ1eRNVtN5RvSMxP/5+L M0HVK2BAtFupF+DNOBr4Cu8mZuwcWvGFUcuB1qB69BNYu2AkI4R5bRUrBKBsmpIagvhy sTBxx478tfKi15f2icNs2MlrwW8gkPCLCQEpHQ7EFigXpHAGO7ZTp8dv1TdX6oOxeK/m HdNCtmaRnyTZ9Ib8d3ClDk2F+wr2e/yyKNDtj8HSnK9DhsQU/mRvQgG6EIIxaQSvNanp 452GnwHHbU8ACqN7Kct12n1gzt88cy5yWKhlFKF05kxaQTVqfBNzVyn7OFphpRlAWrmU Ww5g== X-Gm-Message-State: AC+VfDzs4MFZx4Ydu8tyK0GjBNfIZEj0ni1pSp+uq4aGu5PBjazP1dh3 8iw+31UqDhJBUBiRkn+zgL7xB6Hs+HIo9SiDUAt8lKw5fRSL4YEyBtjLJjq7yYNhTQhdOK2EQIm Kvvz1nyOaVfo= X-Received: by 2002:a05:622a:1a9f:b0:3f5:1def:67fd with SMTP id s31-20020a05622a1a9f00b003f51def67fdmr6869892qtc.2.1684350559286; Wed, 17 May 2023 12:09:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5m7p0QqMHfQEXYY68UUBJuy0d24Wlx3YBE8G36XlPM1mx1FsLjvPznRvMD7EUjylbl1XAp/g== X-Received: by 2002:a05:622a:1a9f:b0:3f5:1def:67fd with SMTP id s31-20020a05622a1a9f00b003f51def67fdmr6869843qtc.2.1684350558865; Wed, 17 May 2023 12:09:18 -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 k21-20020a05620a143500b0075954005b46sm833464qkj.48.2023.05.17.12.09.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 May 2023 12:09:18 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Mike Rapoport , peterx@redhat.com, Alexander Viro , Andrew Morton , "Liam R . Howlett" , Andrea Arcangeli , Mark Rutland , Lorenzo Stoakes Subject: [PATCH v2 0/2] mm/uffd: Fix vma merge/split Date: Wed, 17 May 2023 15:09:14 -0400 Message-Id: <20230517190916.3429499-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-Stat-Signature: ta1yazwy3yyyew14sbksamg5z13ttbqb X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: EDFD180010 X-Rspam-User: X-HE-Tag: 1684350563-684917 X-HE-Meta: U2FsdGVkX19QbwJIL2BzkL5joQoUoDJsRQ1UgItWbZNL36BSwm1I3E+JmBO/e7XxTJ1K6A4syyNOP6JoO84p12b187VOJvIZOSKQpOLUeiWnIjtTRuSpuNi5h+oGTaa38l7wZpT2HYO4C3rUIMeNXDvRmQcpwY4sgRKlkmKdldlQaxv478rRgV2Rf4ekwKFvQ8rCIKbtnCYRih2uX5wO1IRTjyRK23WIieP8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aLVN0zfrXMXuv8/1genYY03dMV44fj67IhUa4dt3pMSqiykDUZWLOpQB5UVR/Che/n90kuCj2 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: v2: - Added r-bs for Lorenzo and Liam - Reworded patch 1's commit message [Lorenzo] 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). 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(-)