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: 88275 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp300376vqo; Thu, 27 Apr 2023 07:16:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5xO8gV78wj16SyWooaeO93UXAJSL/Gn9yjlR1y8+G57HyOoVxhUkD4rmLUNywTLmWL5cpk X-Received: by 2002:a05:6a20:d392:b0:f3:3810:8a89 with SMTP id iq18-20020a056a20d39200b000f338108a89mr1529860pzb.51.1682604990718; Thu, 27 Apr 2023 07:16:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682604990; cv=none; d=google.com; s=arc-20160816; b=QfLqbOS532BOeqiETXlo29CYZlOtSGBo/Whnc9BZCbIU3WQpHu3txCVxs/bYAupVdT y43ihHm4T6LKyxRoVVI8X2JdA/n6njdfdq5VGWBw07MocgFfhANcdIM3MgWSxKjH3FDR M5pSbJuMYICVFeIOU5ARtKTQK2dwzwaS13wS2T2QmcweQgfJf0en4AuTCJCmt/DDYo6r OL72m9M4Yt0Ia5Cp81B03+7lHiM7tCxjE9MmZN8zsQq8BcYndbgh/FAqFzyFZ5lcsVmg eT4V/9H5YSiT2iSuCewEkER38vWKsLUoIIR5NedUEx4MKEJ7OfLkyUDVAxTcceihmLQB PL7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature:dkim-signature; bh=jEqRVG+8Dcj6ijJa/JrCFAx9tBcDp1RS6kPZqc1Elbc=; b=nvNbo8rnCFLtgr1o3YmTb5ZsoErKpKaIskOLKaI4JGku+HxtAc6jFcSg68Yw7bvo2/ uRjcQkvsmKbsZn5vhD9L8FmqMnrAU5rYf2stzM1WtBAJU8RTPd3kniE+wD+n2rMZTZfp RTk9pi7yeSiPgsxg5jJv2KPFEPLYPF5NrxIBeIBsODgIKJORUaTbHThtvZTTXYi2QP6s DCYebpkLpxP5uQlk9lt8aMmWvzVfd+8iwjK983TNhT39mo37IF6bXlKoAM/LuX7b5I/9 W5hF6VDXurwUTdqWRn4j3a3ogxeHYLhblYEYhGXn9ztj8d7E5y9H5fhdb4dTK5Ekl8R7 bu1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=MePFwGha; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b1-20020a656681000000b0050c0a7a2742si19655726pgw.350.2023.04.27.07.16.15; Thu, 27 Apr 2023 07:16:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=MePFwGha; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232885AbjD0OKL (ORCPT + 99 others); Thu, 27 Apr 2023 10:10:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243343AbjD0OKJ (ORCPT ); Thu, 27 Apr 2023 10:10:09 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75043B3; Thu, 27 Apr 2023 07:10:08 -0700 (PDT) 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-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764339210706876971?= X-GMAIL-MSGID: =?utf-8?q?1764339210706876971?= 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;