From patchwork Thu Apr 27 14:09:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 13225514 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 305FDC77B61 for ; Thu, 27 Apr 2023 14:10:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 79B7E6B0071; Thu, 27 Apr 2023 10:10:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 74AAC6B0072; Thu, 27 Apr 2023 10:10:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6395C6B0074; Thu, 27 Apr 2023 10:10:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 52E6F6B0071 for ; Thu, 27 Apr 2023 10:10:12 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 1587E802CE for ; Thu, 27 Apr 2023 14:10:12 +0000 (UTC) X-FDA: 80727355464.15.CA1018C Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf27.hostedemail.com (Postfix) with ESMTP id 021E640004 for ; Thu, 27 Apr 2023 14:10:08 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=MePFwGha; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=ySABGXvh; spf=pass (imf27.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.29 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=1682604609; 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:references:dkim-signature; bh=jEqRVG+8Dcj6ijJa/JrCFAx9tBcDp1RS6kPZqc1Elbc=; b=raqbHLud/RQYiCHdzfrf7zBxs3jkSaURoxZOw0v2h/+yCGguRwm6Bd7xECUjYa93oGw3mr I6rdMqy3g+NBahxFOJ//J3gVWyVvCokZYWbyu8ubBhAsFJ7WEz/GYzLa3ujk2xXko5Jet7 uur2t7zR2+8hj/IIHll4/CuEw6lZsig= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=MePFwGha; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=ySABGXvh; spf=pass (imf27.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.29 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1682604609; a=rsa-sha256; cv=none; b=XLeqKaY9rcEd/Si5rbarFhZDQlU7vmo68Q4DPqnheOAHR9Oj64v5pzMn2KqrxPunQvPgp6 AALokPeX/yCnqmbpnhez92xXklhBteppHyuqi3UttlzJ/dTLrmGa3/WQjjbF5/icDHSVoB p+TGXk+YsoCs2QeMNa/yJr+1y2Bg56c= 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-out2.suse.de (Postfix) with ESMTPS id 2D4921FE3B; Thu, 27 Apr 2023 14:10:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1682604607; 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; bh=jEqRVG+8Dcj6ijJa/JrCFAx9tBcDp1RS6kPZqc1Elbc=; b=MePFwGhaepIE3/27uZpP71e7L5tVtchBYpdXJ4oUagj0/EjIJe+PGXVrfUv0i6427RuUkb QJY+xGZy6cRmiyxihdjr/pJ7I9aRNnult1PaQMd4okCQrejLCHB12LwzqnV4VSuFbCUVMl CLpoDdcszSWFz3Qi2dVWKmwACY0dhUo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1682604607; 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; bh=jEqRVG+8Dcj6ijJa/JrCFAx9tBcDp1RS6kPZqc1Elbc=; b=ySABGXvhe1KqxVKho6dXds9Kj/WWS8MSO1VyFw9UZ5laodhQY+uuJ9N9osw8id34H7TGWb vEhr0ZCOsZ8Lt9CQ== 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 EE850138F9; Thu, 27 Apr 2023 14:10:06 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id drdvOT6CSmQuEAAAMHmgww (envelope-from ); Thu, 27 Apr 2023 14:10:06 +0000 From: Vlastimil Babka To: Andrew Morton , Linus Torvalds Cc: "Liam R. Howlett" , lstoakes@gmail.com, regressions@lists.linux.dev, linux-mm@kvack.org, patches@lists.linux.dev, linux-kernel@vger.kernel.org, Vlastimil Babka , Jiri Slaby , Fabian Vogt , stable@vger.kernel.org Subject: [PATCH for v6.3 regression] mm/mremap: fix vm_pgoff in vma_merge() case 3 Date: Thu, 27 Apr 2023 16:09:59 +0200 Message-Id: <20230427140959.27655-1-vbabka@suse.cz> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: noz4rbqr6up5j6ras83x4nbjeg7fe4sn X-Rspamd-Queue-Id: 021E640004 X-HE-Tag: 1682604608-943821 X-HE-Meta: U2FsdGVkX19Cx59S04mjY3nsNKtPgYxIPPdhXTqFdNQNDzsehZ1CVGgt3XP2iRsHUE6IiLT38LWD4xdVNtTuJuvTcL8ogBAU+m+/jDiU61YP6QrwwvlJvWbT37MicFByw6t4EACOh9PxN2z6QqPqpI2vvh8xzDj6Og1SAH9y4p2ujsfUkCviSY7XYH8V5niMxmZBkwtiRHEsLEydLqNc8uxx1xmI+G7gOU/DRCcIYypp0+DBs4N6xh7LHUMBVLD+Z5He7K4yNK9JKw07hINuHuWBqD68amZNMLBb+p/DDOsITUtf6ynJI2dkG7coNPpgNXe59Zb+kf9+k4PGHiFx3ebg+tCS8Q/aTXZc77S3vnavX5mnNLK91UtxZyS/QSLUxAJ7q0hXMCWnAAqrDOT5aGBy+yGd0K3qeXoGphfDFtDy/MugRBIlY1lEbR7Nabh2QSXzbyCO1C8lf+Grxoo+lFZcv0jUX2vJYuWFbLdHXgNd6DFquRYEliX3nlcOewIFNDQ3lD9GluU4ku5B7cYql/+NxqqkMP/eUr5N0loAclY7q+7hab7F6LreUiio9vDHhiqQ0UirzNfig3WsQiLyKMu8SuwZn6JwxEHXwRyDDWLuII9F+NyXE2EMOsATJRLkkKVU5lQAuHnkfI8AcC80Ngd1EoIbd15NX1U1O8zzgKiVlKNaVzGdV/zC9/Ne/fz1fNCI01+Sg8BOscnFEhwRKJ3BW8ZSARnD9aF7sbCLyo3dnWVFWdaK1jHRM0bwgOGVnGtrjhj3k1/2DiTJzP3MvyXdhpiHW4oFRVA6pV4Z6PLY5nT4PooKF4Z4F0/P41OBq21gBGNsQNlu9OtGAeBBth8wj+Jh85HEQeem+sWJYJwx09a4oTdFvT4ZfkJ+qpHQLqlqlO8xdMltdzMOCrROR6/Eb3AVZAAJ2+bKiduT1aOBQnwMMtqu2PhFRdPTlRzNZt+A6IIFoHYkzdLzI5k gmAkWIoI GoSC96OityhV1SPQcdSNPI1eUXoZoM07NfXqvxeaqwEeyitrUNfbMY78dP0J8kFRHJ7R+F8c+t1+QhooXIPMTOZGAyYVtrybxz+WAwne1mgmvMFlWQ66mzHqhhATtMcx1z/mFGMY0SX2GrJRVdaSJ87SoTHe60lRMI7rXLHYNvPG3O43aDztCvvVOUTNSj4ZO80JtWWeAEmg9z4zaWrS5H3r9xHuP6uRjrAY3DaeumLvd0mJu9GUVP0FECl9YKVxgk4sB6YZKosQjXGUZN/xOYOLOVe0CLiqrO8tY17KhwqFAsluFrzSr9/Zsd+Mzh2XvqTc3QOdbTSbNVoLGELWkKFPY3xR6/l6m4LQi 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: After upgrading build guests to v6.3, rpm started segfaulting for specific packages, which was bisected to commit 0503ea8f5ba7 ("mm/mmap: remove __vma_adjust()"). rpm is doing many mremap() operations with file mappings of its db. The problem is that in vma_merge() case 3 (we merge with the next vma, expanding it downwards) vm_pgoff is not adjusted as it should when vm_start changes. As a result the rpm process most likely sees data from the wrong offset of the file. Fix the vm_pgoff calculation. For case 8 this is a non-functional change as the resulting vm_pgoff is the same. Reported-and-bisected-by: Jiri Slaby Reported-and-tested-by: Fabian Vogt Link: https://bugzilla.suse.com/show_bug.cgi?id=1210903 Fixes: 0503ea8f5ba7 ("mm/mmap: remove __vma_adjust()") Signed-off-by: Vlastimil Babka Cc: Signed-off-by: Vlastimil Babka --- Hi, I'm sending this patch on top of v6.3 as I think it should be applied and backported to 6.3-stable rather sooner than later. This means there would be a small conflict when merging mm/mm-stable later. Alternatively it could be added to mm/mm-stable and upcoming 6.4 pull request, but then the stable backport would need adjustment. It's up to Linus and Andrew. #regzbot introduced: 0503ea8f5ba7 https://bugzilla.suse.com/show_bug.cgi?id=1210903 mm/mmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/mmap.c b/mm/mmap.c index d5475fbf5729..eefa6f0cda28 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -978,7 +978,7 @@ struct vm_area_struct *vma_merge(struct vma_iterator *vmi, struct mm_struct *mm, vma = next; /* case 3 */ vma_start = addr; vma_end = next->vm_end; - vma_pgoff = mid->vm_pgoff; + vma_pgoff = next->vm_pgoff - pglen; err = 0; if (mid != next) { /* case 8 */ remove = mid;