Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4207824rdb; Mon, 11 Dec 2023 11:58:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IGUuGDLz7mGyrZbiBfv+leAalOXpYSSxqjVcok1oSJ+dIdANL2hInps43mHCChToa3P30zW X-Received: by 2002:a05:6e02:1a21:b0:35d:6aa4:d5bd with SMTP id g1-20020a056e021a2100b0035d6aa4d5bdmr7807163ile.34.1702324711113; Mon, 11 Dec 2023 11:58:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702324711; cv=none; d=google.com; s=arc-20160816; b=fTzgkrIEqUIk9yb2LoWaqAJ7Axz4baAC9C9yPq6uW+ZJCXczuLrox8ikDCuTt05LJU EuW/COpNQXMaWtfhzl555ilxUTErGGlcXYHPD1rbQyVZzP97Lyk+EVyRR82pQDGDDFk3 x9HDMYEjDZB+X5iaUBUh/cbpXkMbQaf763sg1ohqiHg/ZKnz8iGxLUUMT2KtrdEcSUs7 vYfkLgldG4gKf4VN97vYOcCUSgcwx6MRqxv/bADKrZAE73g1ZhUhiTBQJP0t0Az38gZk NK3p96wZy8A6nbtGy8F7vRK1NKJu1BJiAAGTcT1nd31+sTpi+MfqmneVqQ/FOa+Auq3T 4aQA== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=6Elw3RSA8ypj0e2taUSUQHrh6YXprm2vvCPOxvcU7vE=; fh=iilJkKpE3haHbvq4/WsUEv+ZZiHti2T7Y8kM/lvqEBI=; b=qga9sho3BTgUxHaetnHLXqzleTqP3jweqCNYs52DDY9g6FTm9gHeBBOsNwLxWIQwK/ 4myZFXaGYs2hC25gyRXOVNVWEdc8ZitkMydHot5ezxVlayhMjXF02w9wefP5AO5+UaTJ XKOkEyuuQvP6UHXun2D0/AxmIZ++b7Qnpi6FQfHI7gTXh2aOB+w5lhRHQHd2IAlO94Mr BejxeIA6WfBCdx3Fdt2iSnTispston4Z51wnBXT+n5cmQm7Ee98Hj2HQkQdw3eDroPfu EUBSxuoacKksDZY0FQcXJ7AmNQAwj3CYuOD/RLZ1gj1aqiPAg4fV7XYHpuWaMEIqOAd7 UF5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b="CdlMZT/2"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id cb22-20020a056a02071600b0056569ee3ae6si6663716pgb.798.2023.12.11.11.58.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 11:58:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b="CdlMZT/2"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id A458D80BEDC6; Mon, 11 Dec 2023 11:58:28 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344920AbjLKT6B (ORCPT + 99 others); Mon, 11 Dec 2023 14:58:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344862AbjLKT6A (ORCPT ); Mon, 11 Dec 2023 14:58:00 -0500 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF070C4 for ; Mon, 11 Dec 2023 11:58:05 -0800 (PST) Received: from mail-lj1-f197.google.com (mail-lj1-f197.google.com [209.85.208.197]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id E98DD3F043 for ; Mon, 11 Dec 2023 19:58:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1702324682; bh=6Elw3RSA8ypj0e2taUSUQHrh6YXprm2vvCPOxvcU7vE=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=CdlMZT/2iK6TADOSKZR6ivNNjaBTs2UUFoR8bYiJmtYZuc8ZdBRHkQiDJYxTNYKJ6 h9mBetNZagihjGIzQiLKK6eNtpxWnH6omsJ6OcS0ED5mUZ74tKWQFKKq+hsjvayEOn e7AmaFTXtsPd3BSbKRwJugIN+t8tlA01kCWnIGPx32g6NmR0Hw4Wcjjmt9agIfkc2j 8cZDte+fF+h3KYZKD/QL2vjE899U18RVW6ehjsrG0SPMWxOx5R3FNHuxJGUFbktsYB k2Wolpl0/+dfvcC2v6Uw+K/Bs1PGSQPf0yp8mtXSd0gje+oGrfeuRTxgtaeSfQQI2C mGmVKHMTa05FQ== Received: by mail-lj1-f197.google.com with SMTP id 38308e7fff4ca-2ca31b054e4so37023601fa.2 for ; Mon, 11 Dec 2023 11:58:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702324682; x=1702929482; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6Elw3RSA8ypj0e2taUSUQHrh6YXprm2vvCPOxvcU7vE=; b=ev6JsbYbbTrEkJutyuxSi/45jmUZaSJT5ZOd0G2AoBN5E0p6r5IK9xIIGcGl9vWI+b Ex2sXoHtUuEnxr/moqOj/PyMz5IVghTu6gWFDpx32KpGJn266YAaU+f/MWTcMt05ZwsX +Ikj2+hyIRalEMKO3zE3/zxdLUmuS8oGGhUB7z0LMZ8kFkNUSC4sL86sEJbGLyWwd1Qu xs3AEDmYi55s+nS4VKzNTjUoCrp0VYemnnOjMfVIb5PF8vhFl8q7yZmLUhhwQsxR3AVt NvSYymNbZLpBAUV7zXUVSYLq/tY4FzGXS7/p3zbh0/rDk2xaQh1/ElIGX3nwSQagTY4q CzmA== X-Gm-Message-State: AOJu0Yz3zpMw3sAPTeXmizcbkezDcZmUMTLC/TeW6Hwwhnh7yZOCKgYW yV9WvJzj/h1aVd51VqrD7ANan0NpHZ9nJ+TOvVqTxyXe3llzIejfOtutkT8kioLaSur4EPdyv6L XExPAgDpwuNa64ZOZVDicLS/y7qedT6BQnh3L4ecfuA== X-Received: by 2002:a2e:97d1:0:b0:2ca:2ab0:dd90 with SMTP id m17-20020a2e97d1000000b002ca2ab0dd90mr2360771ljj.95.1702324682377; Mon, 11 Dec 2023 11:58:02 -0800 (PST) X-Received: by 2002:a2e:97d1:0:b0:2ca:2ab0:dd90 with SMTP id m17-20020a2e97d1000000b002ca2ab0dd90mr2360764ljj.95.1702324682026; Mon, 11 Dec 2023 11:58:02 -0800 (PST) Received: from amikhalitsyn ([2a02:8109:8624:a300:8a21:8f36:2e85:27a6]) by smtp.gmail.com with ESMTPSA id r10-20020a508d8a000000b0054cb88a353dsm3918472edh.14.2023.12.11.11.58.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 11:58:01 -0800 (PST) Date: Mon, 11 Dec 2023 20:57:59 +0100 From: Alexander Mikhalitsyn To: Andrei Vagin Cc: Andrew Morton , linux-kernel@vger.kernel.org, Amir Goldstein , Alexander Mikhalitsyn , brauner@kernel.org Subject: Re: [PATCH 1/2] fs/proc: show correct device and inode numbers in /proc/pid/maps Message-Id: <20231211205759.583ca1ff4ea510061068027f@canonical.com> In-Reply-To: <20231211193048.580691-1-avagin@google.com> References: <20231211193048.580691-1-avagin@google.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 11 Dec 2023 11:58:28 -0800 (PST) On Mon, 11 Dec 2023 11:30:47 -0800 Andrei Vagin wrote: > Device and inode numbers in /proc/pid/maps have to match numbers returned by > statx for the same files. > > /proc/pid/maps shows device and inode numbers of vma->vm_file-s. Here is > an issue. If a mapped file is on a stackable file system (e.g., > overlayfs), vma->vm_file is a backing file whose f_inode is on the > underlying filesystem. To show correct numbers, we need to get a user > file and shows its numbers. The same trick is used to show file paths in > /proc/pid/maps. > > But it isn't the end of this story. A file system can manipulate inode numbers > within the getattr callback (e.g., ovl_getattr), so vfs_getattr must be used to > get correct numbers. > > Cc: Amir Goldstein > Cc: Alexander Mikhalitsyn We have discussed this with Andrei offlist, so LGTM. Reviewed-by: Alexander Mikhalitsyn +cc Christian > Signed-off-by: Andrei Vagin > --- > fs/proc/task_mmu.c | 20 +++++++++++++++++--- > 1 file changed, 17 insertions(+), 3 deletions(-) > > diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c > index 435b61054b5b..abbf96c091ad 100644 > --- a/fs/proc/task_mmu.c > +++ b/fs/proc/task_mmu.c > @@ -273,9 +273,23 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma) > const char *name = NULL; > > if (file) { > - struct inode *inode = file_inode(vma->vm_file); > - dev = inode->i_sb->s_dev; > - ino = inode->i_ino; > + const struct path *path; > + struct kstat stat; > + > + path = file_user_path(file); > + /* > + * A file system can manipulate inode numbers within the > + * getattr callback (e.g. ovl_getattr). > + */ > + if (!vfs_getattr_nosec(path, &stat, STATX_INO, AT_STATX_DONT_SYNC)) { > + dev = stat.dev; > + ino = stat.ino; > + } else { > + struct inode *inode = d_backing_inode(path->dentry); > + > + dev = inode->i_sb->s_dev; > + ino = inode->i_ino; > + } > pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT; > } > > -- > 2.43.0.472.g3155946c3a-goog > -- Alexander Mikhalitsyn