Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp704445rwr; Thu, 27 Apr 2023 07:10:59 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6xS5jMaQtjovirkjT7vTXi/04S54xrv5GzEzMgNRgCzRtCDpsDOPFx/qpyuhEhF8hVNCZU X-Received: by 2002:a17:90a:34c:b0:247:2baf:d6f with SMTP id 12-20020a17090a034c00b002472baf0d6fmr1916207pjf.0.1682604658901; Thu, 27 Apr 2023 07:10:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682604658; cv=none; d=google.com; s=arc-20160816; b=pGoEjBQf+gX16YpgfIF+jwrs7Qz9m8I8Wrr5DBvmBnqsY3PKTDBHZwe9LfUxguZTqf Y4YXvKnzgQ9fXNMLAG5BdRcJTs6PcbtD3mZ9sW7WBqOyHktYcUV8bwuX1iiGHIX33khh vh5mtbMMhG+ZRwtXmT1rHZ9RUmpFD4EAOaTq+1f3/VOsnAgNGx93Ndc7B6/ZgdkwTDWY GwPnXIWGKffpoyoDLZfWIQ9jH0JelQo/QkhU5uB2q6updxE9fIr6I2quilIUjDk6cy3q nyzNEFCfQcNrLUzmZJ63M067UHWpGiEgbH2ms7/ZVfXhOLL9qyTZN4vVZyaQBl5Vo9BV x3zQ== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e3-20020a17090a818300b0024bb5f9b750si10489117pjn.85.2023.04.27.07.10.43; Thu, 27 Apr 2023 07:10:58 -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 S243730AbjD0OKL (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 Content-Transfer-Encoding: 8bit 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 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: --- 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; -- 2.40.0