Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp1663386lqz; Mon, 1 Apr 2024 13:09:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWYibHFHOQLAjCIS52TNIIV7RMGJxsDVg0sjdW/ogqUCh/nz+3RTZgbTiD/zcncjkLNrjAYpKQJX86dtdLBfEM5mLTPq0aIYmzIzyum4A== X-Google-Smtp-Source: AGHT+IG9EDjMbvOQr6Ht4kz/ntAHE5Bxowr4BuQHSmYQo6EAKd9OM9v3t5/Bdkb2g5nQE6FGNt1z X-Received: by 2002:a17:90a:ca03:b0:29b:10bc:acaf with SMTP id x3-20020a17090aca0300b0029b10bcacafmr8024352pjt.30.1712002142860; Mon, 01 Apr 2024 13:09:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712002142; cv=pass; d=google.com; s=arc-20160816; b=0BuBrOB7nowchcrYP0nqo3GqgSzSt6BQK/f5f2pbIdIk6qq0AR6SlT7i6G2fd+pguP 2jg6Gl8JMhEBUjS4qogBNEcPBv0ZoHMFj+gXy5FRns0k2yqsyrH9Ey2EmBlNtPIDnbI1 IMlAPAPV8Ci6ZdpigmmMTNNIBeE0cdEFd5h3/4Wn0mpxJbwTHsTJhPcbxFAM+NxVMDmL J28+ew+ho1dfbirr7OW6qTGaG2uyyM/2mXA0MkChNUdIBrrlgZkalju/YPdCUc4sTTZY WHFOBRnURfpai5A+vCIKFLmqC1uUlVINJHoAPVvLBgSrebIN2UAxZxW7zg3PC8Xf76cD MqRw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6uzxeeCXx2GteCLHIEaxu9FTl7Vo3pQTpoPxx4XKqAM=; fh=SUP7VjUSsiKXywPmb+VNbMETy/v1CLNSBAo30QxP10I=; b=mkexbEvdhE4UgEoVIdpwf2scJf6K9p6F2yg6bvCIKAtEtxVYIhDecQLzQivqWQnZ+5 egH56FGQS01GmOyvWK+94fEBL8u0O1CjRQkLoIFRUXPb0JR8XR1gsgkXPChgTUEEr9Tv YtlK3q0VYlmLEf8W9+JGiP0wHxby+fnlJ5AgttAb/yAHGKjHZm1FeNv9fcOHdWQpWqHn ZEk2XPN6efJv0PxQb+nc1pfy6yng2zr5VYlaH3tkqQodobFRp+BR/BpmDzdob61QITKn l0A8iOw3MzQ3UpQrKnUr2BYvxLZoDK2DuGPAu2VSB3TAsrb7PsxeyB2oVXqXjAspnuJU StCg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@natalenko.name header.s=dkim-20170712 header.b=jHjFVSmv; arc=pass (i=1 spf=pass spfdomain=natalenko.name dkim=pass dkdomain=natalenko.name dmarc=pass fromdomain=natalenko.name); spf=pass (google.com: domain of linux-kernel+bounces-127018-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-127018-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=natalenko.name Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 90-20020a17090a09e300b002a25408f855si137133pjo.157.2024.04.01.13.09.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Apr 2024 13:09:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-127018-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@natalenko.name header.s=dkim-20170712 header.b=jHjFVSmv; arc=pass (i=1 spf=pass spfdomain=natalenko.name dkim=pass dkdomain=natalenko.name dmarc=pass fromdomain=natalenko.name); spf=pass (google.com: domain of linux-kernel+bounces-127018-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-127018-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=natalenko.name Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 86863282B11 for ; Mon, 1 Apr 2024 20:09:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 745635381A; Mon, 1 Apr 2024 20:08:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=natalenko.name header.i=@natalenko.name header.b="jHjFVSmv" Received: from prime.voidband.net (prime.voidband.net [199.247.17.104]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD6C951C52 for ; Mon, 1 Apr 2024 20:08:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.247.17.104 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712002135; cv=none; b=kMFNCO/lwwNyfsMPBWBxaVglKfZJjS0oH+9j+28snzK16qPHRgAbLqV1f95uJanNZM3E+5K1NYrhbv+h7G1BBVKNlq60916NBk0tPGhXa9MU6yrq8paiHA5ROYAI/qw1nhWEQhwNuP9DDqBSCJ49YNWt3pbug5m/U7pQGdis//4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712002135; c=relaxed/simple; bh=9ziyHFW1xbg3LeHXWDh3lD+n4WpebuIyi03HNsaX3Zc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=c7tmwyQSU9Iyo5evvmKNIkZPhNUUmwDCUGXnYcTLyRh5KxLTMgsiGKkZf7jJilasnOke4pY9tlSA1f+Z15mFGmfqqqLk1y8h8G0M8UOF8Tu7aYCW5DjyHnUxbdbHMZANuP809hGTaHK+yWqMvWJ/XWl7QiOux9JRnGh0q54ZZaI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=natalenko.name; spf=pass smtp.mailfrom=natalenko.name; dkim=pass (1024-bit key) header.d=natalenko.name header.i=@natalenko.name header.b=jHjFVSmv; arc=none smtp.client-ip=199.247.17.104 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=natalenko.name Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=natalenko.name Received: from spock.localnet (unknown [94.142.239.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by prime.voidband.net (Postfix) with ESMTPSA id 655AC62FD5E0; Mon, 1 Apr 2024 22:08:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=natalenko.name; s=dkim-20170712; t=1712002123; 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=6uzxeeCXx2GteCLHIEaxu9FTl7Vo3pQTpoPxx4XKqAM=; b=jHjFVSmvo9SJZgKzBrfNcqyRlqocuEkwwmvOycbJKjzG474hmKijpqugq/bh9rbB/h284v 9pZGaBRylOW3FmQWEfePFQt+pbKnRLGmwZOQOAZm24rrxgn6GMvBwQBKpFFgE2LDjDcrwk WtMJbT/dM/Y0HZ9Fy6s49fx6VukTrvM= From: Oleksandr Natalenko To: linux-mm@kvack.org, Vlastimil Babka Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, Vlastimil Babka , stable@vger.kenrel.org, Lorenzo Stoakes , "Liam R . Howlett" Subject: Re: [PATCH] mm, mmap: remove vma_merge() Date: Mon, 01 Apr 2024 22:08:31 +0200 Message-ID: <2335177.ElGaqSPkdT@natalenko.name> In-Reply-To: <20240401192623.18575-2-vbabka@suse.cz> References: <20240401192623.18575-2-vbabka@suse.cz> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart4896029.GXAFRqVoOG"; micalg="pgp-sha256"; protocol="application/pgp-signature" --nextPart4896029.GXAFRqVoOG Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8"; protected-headers="v1" From: Oleksandr Natalenko To: linux-mm@kvack.org, Vlastimil Babka Subject: Re: [PATCH] mm, mmap: remove vma_merge() Date: Mon, 01 Apr 2024 22:08:31 +0200 Message-ID: <2335177.ElGaqSPkdT@natalenko.name> In-Reply-To: <20240401192623.18575-2-vbabka@suse.cz> References: <20240401192623.18575-2-vbabka@suse.cz> MIME-Version: 1.0 Hello. On pond=C4=9Bl=C3=AD 1. dubna 2024 21:26:24, CEST Vlastimil Babka wrote: > With SLAB gone I was looking for what I could delete next, and then it > dawned on me - it should be vma_merge(). It's simply an unmaintainable > mess. >=20 > The code is extremely hard to follow. There has been a number of recent > attempts to made it more readable, by Liam, Lorenzo and myself. Almost > every time this only resulted in subtle embarassing bugs [1] [2] [3] [4] > [5]. For many of the bugs the only reliable testcase we have is the rpm > process running in the Open Build Service. Which is worrying, as that > clearly makes vma_merge() a potential supply chain attack vector for > planting backdoors. >=20 > Thus simply remove vma_merge() and all the related code, and adjust all > callers to take the path as if merging was attempted and failed. > The only downside is that there might now be more vmas and maple tree > nodes due to no merging. To extensively validate that, I've booted the > kernel with virtme-ng before and after the change and checked slabinfo > for the number of active objects: >=20 > before: > maple_node 1159 > vm_area_struct 1538 >=20 > after: > maple_node 1113 > vm_area_struct 1861 >=20 > Yeah there's more vma's but interestingly, less maple tree nodes. I > believe it's worth it. The larger number of smaller vmas could even help > with better parallelism thanks to per-vma locking. So the conclusion is > obvious - we should have never tried merging vmas in the first place, > hence the tags on this patch. >=20 > [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/co= mmit/?id=3Dd014cd7c1c35 > [2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/co= mmit/?id=3D4c6759967826 > [3] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/co= mmit/?id=3D7e7757876f25 > [4] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/co= mmit/?id=3D1419430c8abb > [5] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/co= mmit/?id=3Dfc0c8f9089c2 >=20 > Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") > Cc: # CVE mandatory > Cc: Lorenzo Stoakes > Cc: Liam R. Howlett > Singed-off-by-one: Vlastimil Babka Nyacked-by: Oleksandr Natalenko TYVM! > --- > mm/internal.h | 7 - > mm/mmap.c | 368 +++----------------------------------------------- > mm/mremap.c | 60 -------- > 3 files changed, 17 insertions(+), 418 deletions(-) /* SNIP */ =2D-=20 Oleksandr Natalenko (post-factum) --nextPart4896029.GXAFRqVoOG Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part. Content-Transfer-Encoding: 7Bit -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEZUOOw5ESFLHZZtOKil/iNcg8M0sFAmYLFD8ACgkQil/iNcg8 M0vAbg/6A8Krc8bk+nqpqjPO0IDAhn5xp+Cdh/sua9KVU7ddNCpZdgsHRUz91tU5 GOQQmTWjpZU55lTS72r7LCE6KvU/UYOAnIVbwD1Iy5xLAKd6261tmMhAxQlCqJ6E 7m/4jys/Kzex9tl6ulKsZHbgURoAfo+7WBuSSCwLJpFvxNMQMoKdIrHj/bbC6G7C ylDz+pd1w7FM/3Lc/Le7xAMbG+EA+U3jcif0kprjXiq7njq8g4RalahModA4LI4E NcehS9hGeueZrmaP2nKHhGryR/o1nc328tC1RzlF2Aby+oP9FxihUfYNf497oqew VzOZqMeMzDV8Vl6oyQe8WqOp6z2Ht2588BnecgpHkckkUs99wltQr5XvYKSYVf51 WZUCXNSgB7XyUAJpgG+L/FBDvaMJCKeDhOesscm8SStVs7FEZQYXVf+Bf6SlK5sB 0ybZMW3vEdBd0tMfoic+Wr4FTgFwJcONeOkHTqjnp7t/tAzmNfh8qSW+LlNZ4ji5 T4uX+mkEYpNuMxq9/4t34nohaG+LgArjTwcFr1gfzBe1HasO6dGw/dUAM2rqrLlN p7w8lNygK5FyVZUH9sXMoa+5HOxbcLjA9wAEP31ISwA+O688D4qL7gGWq6uzucba kZPF9HYPD323SZhDZ+Z3UOuEbDDBHpSwuXplQjJYwokrTHGDelU= =aH3Z -----END PGP SIGNATURE----- --nextPart4896029.GXAFRqVoOG--