Received: by 2002:ac8:734e:0:b0:40f:fb00:664b with SMTP id q14csp1733331qtp; Wed, 9 Aug 2023 10:13:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFPlN5FWlyk4q6zFKxt+6ucFtQMIs8AEX14oofbXZqE/BF5W+HMUe998qgccUbr2vJK421D X-Received: by 2002:a17:906:3298:b0:99c:ad52:b06 with SMTP id 24-20020a170906329800b0099cad520b06mr2739123ejw.10.1691601219045; Wed, 09 Aug 2023 10:13:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691601219; cv=none; d=google.com; s=arc-20160816; b=jUMd2/nFLXKFBrOQVsRc3GBtWcUcP4H5SlvSRwcUi8gc6GqybahQWxCJ8TxamdFDYm XT+rFPxMVxJFmpkDC035hmW6yy99lVa2n21z8z1yQBxn4U3NPBeRQjFxEtir13TY5z+I 4Eroditu2OK7IBGKRJkI/j1QKfLmjRsYHqPV9l2Dm9fuWk481/4TxL42iT/puOglJZ1q QStjYB2iaspvZw6/uSSp5hMhZbtWaphAOhLlOSkSUpUzmwaYag1QTqkKv4Ti52SPY2Iv PZLtnEqOHw6GMm6xso0YNswNdR9I5SW7qWPuwcddXeN2KQXCOMGM+U3VIuQ2gJnN6DPu gdWQ== 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; bh=nAOqbS5Qgl4SST4mVTxt2U0LC8XCkPEc99k44uCyOG0=; fh=nP2j7OaEzQjkloWkv3sT4avv8VlBd3KmGiPiz0r18M8=; b=ju6mQ67L29Fb6GNy8m9hJ+n29sk+D+AVvD09tLdpTRo4esjrZSuKRRn9VIu0I/tBV8 3bZ1jiXThJoBnLJo8g3tmHl3WwLd/bYXxmfnpo3TupjIQb2iJgbqcUH3OG8/QCPCd30S sGRgMYFbJseSIIuywgFA2G+ayy19W6olnkfsRB0JdgYew7vZm2vv4JhpCTzXRlxjGBAe Fp+cM9h0ptwCxC+Wk22FWJ5sq6uNJJ18dJbDdpe71DgLUBJaODr2L9wm6Vk2PUXlyQcp 7nfAar2d+/1xv8Os1oy1e4ItIt+2M/SI/TxjcW3GYFrqZkiTHQRClrz80UXCHHiCn1Hf qpdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BBovHaA8; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g2-20020a17090670c200b0099325564b77si9024859ejk.548.2023.08.09.10.13.14; Wed, 09 Aug 2023 10:13:39 -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=@intel.com header.s=Intel header.b=BBovHaA8; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233431AbjHIOqW (ORCPT + 99 others); Wed, 9 Aug 2023 10:46:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233427AbjHIOqU (ORCPT ); Wed, 9 Aug 2023 10:46:20 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00CBE2110; Wed, 9 Aug 2023 07:46:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1691592378; x=1723128378; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=nat6JIpKlbNyaE2SmtvG1qRCszoGjlyVBGDav8zdJFs=; b=BBovHaA8b6u5OGs6B2AXPziLc9QFSB8FJ/iiT9pvhDj7h/gul2Ci2eHg UMAlYjAdULgGJJA4hblimEThnXofy/6hzGv0HL0iOQjTkXjHwd5FKm+14 SuYQCSWLuACCVwNXnj+Rm2FbloTXiXq537Qtr4HX2vqX3M3iyyjzObAF5 ZW4v4rbY1yCTsOarUzMv0FKH5LR3fnVXjc5hmZnwGYppDUcSPw9cLpWxJ xZBsJOCBtdRJXGZpA8klIvEoTqSxHX9rHc8a+fn10cPiSW15pxpEuCQ0O vh4mN04lnclRWPI664VooVKAMGewMaFUynudz7dHNfMWVKnVlGRtQcLy7 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10797"; a="371127925" X-IronPort-AV: E=Sophos;i="6.01,159,1684825200"; d="scan'208";a="371127925" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Aug 2023 07:46:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10797"; a="905676169" X-IronPort-AV: E=Sophos;i="6.01,159,1684825200"; d="scan'208";a="905676169" Received: from jmhendri-mobl.ger.corp.intel.com (HELO box.shutemov.name) ([10.252.40.58]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Aug 2023 07:46:11 -0700 Received: by box.shutemov.name (Postfix, from userid 1000) id 8E85310A257; Wed, 9 Aug 2023 17:46:07 +0300 (+03) From: "Kirill A. Shutemov" To: Linus Torvalds , Andrew Morton , Dave Hansen Cc: Kostya Serebryany , Andrey Ryabinin , Andrey Konovalov , Alexander Potapenko , Taras Madan , Dmitry Vyukov , Rick Edgecombe , linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" , Christina Schimpe , stable@vger.kernel.org Subject: [PATCH] mm: Fix access_remote_vm() regression on tagged addresses Date: Wed, 9 Aug 2023 17:46:00 +0300 Message-ID: <20230809144600.13721-1-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,URIBL_BLOCKED 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 GDB uses /proc/PID/mem to access memory of the target process. GDB doesn't untag addresses manually, but relies on kernel to do the right thing. mem_rw() of procfs uses access_remote_vm() to get data from the target process. It worked fine until recent changes in __access_remote_vm() that now checks if there's VMA at target address using raw address. Untag the address before looking up the VMA. Signed-off-by: Kirill A. Shutemov Reported-by: Christina Schimpe Fixes: eee9c708cc89 ("gup: avoid stack expansion warning for known-good case") Cc: stable@vger.kernel.org --- mm/memory.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/memory.c b/mm/memory.c index 01f39e8144ef..3be9db30db32 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -5701,6 +5701,9 @@ int __access_remote_vm(struct mm_struct *mm, unsigned long addr, void *buf, if (mmap_read_lock_killable(mm)) return 0; + /* Untag the address before looking up the VMA */ + addr = untagged_addr_remote(mm, addr); + /* Avoid triggering the temporary warning in __get_user_pages */ if (!vma_lookup(mm, addr) && !expand_stack(mm, addr)) return 0; -- 2.41.0