From patchwork Fri Feb 24 10:00:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 13151070 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 CE3E6C64ED8 for ; Fri, 24 Feb 2023 10:00:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 17BB56B0072; Fri, 24 Feb 2023 05:00:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0B7136B0073; Fri, 24 Feb 2023 05:00:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E99816B0074; Fri, 24 Feb 2023 05:00:44 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id DBC686B0072 for ; Fri, 24 Feb 2023 05:00:44 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id AF928AC25D for ; Fri, 24 Feb 2023 10:00:44 +0000 (UTC) X-FDA: 80501741208.04.9642891 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf22.hostedemail.com (Postfix) with ESMTP id C7A16C0023 for ; Fri, 24 Feb 2023 10:00:42 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=eOJS6frd; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=8uSvZSyN; spf=pass (imf22.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1677232843; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=bQMJWpenP6OEu3AR0STwSIwzPSjq3AkhCnZCUwU4em4=; b=mNAXMQAVjTkp2EwdOo15w9lucHKHqBlJGfhp7ZeqPLdvZ3uFBGQ4OdRJHBa/uycqALONt2 oREyl24EX5gaRAEIL31rKYu9n4v1PmWU1iyKcZ2QuOrAyxL+h/o0Z9pvVOUk2dDaET7SO+ NTlPU3QV5wn0jyBGTlZiAwYSrJw/88o= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=eOJS6frd; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=8uSvZSyN; spf=pass (imf22.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677232843; a=rsa-sha256; cv=none; b=g7VeBTfqabFJ44YjsVk1mlg6MsMkwQfNGaHBYerDRJ6cFYOa8ohE6eJeUcsk1JV9miGv3N +jJN7BxvXNd/O0rL9kAVcmaB/mBkoJJfrypPPXQJ7ZsV9FiSHByS9lJKa58RmWuc4MpF4q 4+ZR4QJN11h7CSoufcUCGRuZQJ9UEL0= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 3470733FFB; Fri, 24 Feb 2023 10:00:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1677232841; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bQMJWpenP6OEu3AR0STwSIwzPSjq3AkhCnZCUwU4em4=; b=eOJS6frdV5UgXb66LQirAS9ZQ/sN6R7VVfUyUQO93GuJ7YDYy+gCcVKQpNK3ME6ofsbj+u qNoA75ZP+SCcWx6iNzv+kDslqOfh6KioPYBLkFW6Vm5wsP0uKlXfxMhG+f33PGKL2I+nON vlLQQ7NCxHTEb09vqsuUXAqKdYuwsts= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1677232841; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bQMJWpenP6OEu3AR0STwSIwzPSjq3AkhCnZCUwU4em4=; b=8uSvZSyN2Kf6MO7A0WVXIqBZpcPjWwSrokqUDvePSMNZCMXdTvp4Mz2BcsSD0D1/fRbS9I yWrCVUnAmFfSuECg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 1B8B213A3C; Fri, 24 Feb 2023 10:00:41 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id qEYfBsmK+GPeTgAAMHmgww (envelope-from ); Fri, 24 Feb 2023 10:00:41 +0000 From: Vlastimil Babka To: linux-mm@kvack.org, "Liam R. Howlett" Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, maple-tree@lists.infradead.org, Vlastimil Babka Subject: [RFC 01/11] mm/mremap: fix dup_anon_vma() in vma_merge() case 4 Date: Fri, 24 Feb 2023 11:00:12 +0100 Message-Id: <20230224100022.11268-2-vbabka@suse.cz> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230224100022.11268-1-vbabka@suse.cz> References: <20230224100022.11268-1-vbabka@suse.cz> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: C7A16C0023 X-Rspam-User: X-Stat-Signature: eg1598ybnsndc3c4qoq75bcdkc6irp6c X-HE-Tag: 1677232842-968228 X-HE-Meta: U2FsdGVkX187MfmxbdrbuQYhJPno+wOahAOtCN7tl1oBg2I5ITmku+ws80qp/5b5f+7LkOGx1GEMpWBSTkKodXvywlZ6G2Tu6jqnzflQOCC6OdbQreEHhJwxyTNEUMgSxxK18jsFQlZV882THbYD3a9VslJ+Dm6CAuqdlc4hmEkKgpqL5oMRgiZKRUoxFhHEOvhhze9k6GZJvaX/UYv9nCoXdxRPxvrtzleDDqB09/wMpCgPy23V2Tns27sFjPk1q1eggofZ7EKDH3fpIRLgKHX6v7TFyzJsG3FDGQxeaiFR8FUcTpmNCftYZRX2ev5ga5oQFHh1sW9rN4EGws7iu2bncdmbGYd2Ta6ymDpvn+Rdjp6mO2RHOIoox7n+TJtAK/uMPSA3VpWK57WXni8Gh1+xoO9TFE9nnS0rogplhQfoY7OCCHs/4dIM00Y9PDOJS5VI3NniC4z5hPxBW1cBvPuRXA0O7zxsL4AfI/ykPyJAlYytoXF30V/uDpGvpQMKXzmJrLDHHrtXfXX1NaMViNaFiiYblhdGH44frWPKOo9J4mczB4LgWOUjPzkrrQNPTYjURWuWY24tAUUB62ttMXHLTaor80Szs1qL+rZOgh3S4lBzQJHPPBHapN0vZ2XifmaLJFtrWT+jjly/iUOAH1uanDmKzUH9VY3IE1r9hm40fgLPPXw7MzDMfi9rby8jsGce5kEOSku/a9NtAJXzwHk3Za2JP9BwKAd9NDXA2CIOfKyC1sTDc8dRXF3vMsbWccN4ShzT4wWtzFsX30aDHW8QYXW7KHuHcQGdzxjAXjLQCagRKoA9yyNaadWRT/0QbFrmkVMAcZpXtL0mNMvadQ/n/gOytp8WPSIKZHQ/mCkdC9AlbyQjwMYjWQLi6N8RGXfTMsk2WpRyvJlDm+FZD3bcATyDzZnP2yXNZHZuK1rIdioWUS8w8XE+ybSUcsPDXH1gZx0xvofNbmGhoq4 XayYBgS8 x4FemPC6SsFSeupKzYYtlt+vYDoEYpehQI7OXmIqmNA6sxrS+lTGvlgZdLziiWmUVJFL/dh097X4C9jWQLbJsTND47XQaAMgWruQ62tZ31WSDpH4Xik5fw6lw2mVUlBPW1ieP1706aGarIUpfYWZm/Exo9gXqDspSPrUgFcSMRWUByUVsZu9fxLVCU6mvfiN0ZeafGkOPUnTzwAjImJU4N+sIOYcMptmgnq1ODM/dua0O4/nnlBUF3lvtQw== 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: In case 4, we are shrinking 'prev' (PPPP in the comment) and expanding 'mid' (NNNN). So we need to make sure 'mid' clones the anon_vma from 'prev', if it doesn't have any. After commit 0503ea8f5ba7 ("mm/mmap: remove __vma_adjust()") we can fail to do that due to wrong parameters for dup_anon_vma(). The call is a no-op because res == next, adjust == mid and mid == next. Fix it. Fixes: 0503ea8f5ba7 ("mm/mmap: remove __vma_adjust()") Signed-off-by: Vlastimil Babka --- mm/mmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/mmap.c b/mm/mmap.c index 20f21f0949dd..740b54be3ed4 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -973,7 +973,7 @@ struct vm_area_struct *vma_merge(struct vma_iterator *vmi, struct mm_struct *mm, vma_end = addr; adjust = mid; adj_next = -(vma->vm_end - addr); - err = dup_anon_vma(res, adjust); + err = dup_anon_vma(adjust, prev); } else { vma = next; /* case 3 */ vma_start = addr;