Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp4131696rwb; Mon, 21 Nov 2022 04:14:17 -0800 (PST) X-Google-Smtp-Source: AA0mqf442gL5f18bMfgtKW3aJIhSyfioXCChzpQiWFsXw1ct6crXWaHhZ4wrilh9xGoAbOB5I8Nc X-Received: by 2002:a17:906:692:b0:7ad:49b8:1687 with SMTP id u18-20020a170906069200b007ad49b81687mr5136851ejb.407.1669032857372; Mon, 21 Nov 2022 04:14:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669032857; cv=none; d=google.com; s=arc-20160816; b=bB2BliQjvA3BwZnF4YR6bmdzyyt5Bny9AMeG1dYNSfLI8opbjQ3FM23QEUDwl33/U2 8CAAZzXmmeMFvbGDDBU2NLBk+iDIaNURgxmlf8+4/n6H6enzmcrEkbdRrBae1k7VP018 XpaGTLT4pVM+uQJJiH5oWhG9sq2vtjm/g1c2yzNbkeT0LlDlNoGIjQKdNKMk+1ZzOc8H OgGcPw0rbf6ofnujLgZMh7lwXvuVIa5uPIpZg1U7s/hl+Adt13nxXtbv2iEw6lW5QPqq Em22GoqIcP6UPiq9iS6TVtdWUlMJjlKZfwXWOXHzpiYZbOxyhFrZh4xSMh7KKNhFbzkb Kv1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=f0yfsdol+yJgmcL0Jiq/hqGtRju0QVsHN+RKjYJPQas=; b=rQvSDdNJdP5CddB0HrDnt60rBGgsMgwh8nk14dTNUVPmkoDxftD6ZYtVs5eSaw9KBh nWXbIP4SFxu65HPyqDxhAUHKJd9NDitjHaXxErokLyIBw8bHY5saDD65C4cuq0t/tUTf 2nB06fyIvj3xPzM0VXIbcU3UsT6Di1pTjU1sN8rp3Rzv+aF7dyzZs7/X7RdDB8gEa/8G xZ1KKUtWRkrMubeyUJeWqwi+sTEEPhUMLc914a+QrTigor8mjof6nkV+OQqfR6j4UFhL iYroSftfHQLRe5O/09+Jco2cpg1vaYK9it0FR2ahADgYQTVtPAHohD0554cuZp3UwBKN hm5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gEOnELvp; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a26-20020a50ff1a000000b00461dca37cd0si7848421edu.126.2022.11.21.04.13.48; Mon, 21 Nov 2022 04:14:17 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=gEOnELvp; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231430AbiKULn6 (ORCPT + 92 others); Mon, 21 Nov 2022 06:43:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231444AbiKULn1 (ORCPT ); Mon, 21 Nov 2022 06:43:27 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF8DC1C111 for ; Mon, 21 Nov 2022 03:42:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669030941; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=f0yfsdol+yJgmcL0Jiq/hqGtRju0QVsHN+RKjYJPQas=; b=gEOnELvplYAcYoop+/Jgazv41Hwc0vV30l3YGM+RyIWR2GZ42SaW43CdTocKMXv5REgmO5 R6F0trFkD7iYyxRZ6SteRDY0SCcUiwpwRmHNuu7H5zbO4V+uoDw9LaEV5hTciKsyPtUocY /Ii5LKrXaHZDSJQSC3UxWFojt7I3mkI= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-66-lXs-on3ANIC09UCGABNV9Q-1; Mon, 21 Nov 2022 06:42:19 -0500 X-MC-Unique: lXs-on3ANIC09UCGABNV9Q-1 Received: by mail-qv1-f71.google.com with SMTP id z18-20020a0cfed2000000b004bc28af6f7dso11133002qvs.4 for ; Mon, 21 Nov 2022 03:42:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=f0yfsdol+yJgmcL0Jiq/hqGtRju0QVsHN+RKjYJPQas=; b=X58TaR9jrcoyytwU0pKsluhpXU7wXV1TOihlFhPMJNwBqu0bLVb0+fuN4l0orHuU5l 5+1ltzAo7G6Cdwd6wlgAKLZ0n+3zLha5cfMNYt6hI+GmxHSFR8ameXYURyjFc1mNZ8mK 43wyYFFL5mtQbVmvgTJZ8EVeioztyJRSgIrGf+/Ym4T6J/pP3Y5cN63F/AZiWVssRH9x 0QA4ZB1KGogj5P5y7lUhGqtaQO3Ul5L5sfjnUo/QbnN3BgFgIssuVe6ka2Je/wmnK1h7 uOVsZ2TSESP+TksH8r0iYmzxjZUt3OMMDoSym/MVhCPJafGyTQZSQA0VPC2MywTvVVe5 cVwg== X-Gm-Message-State: ANoB5pn2OJ8/ks19Gzqs+0NqZUejig4rVfpan3Xntu0fEP/fdo0Pljrz paZOlw2TAfqVjCiOeIBVtSjXw01t1xP2l4IcmwLVoUnUnNc3eVfBy29/oVfNsY8CqoKzMaHphk4 deQZFVFK8QvKRDskxcylwKAqd X-Received: by 2002:a0c:ec04:0:b0:4c6:7622:3107 with SMTP id y4-20020a0cec04000000b004c676223107mr16719993qvo.118.1669030939405; Mon, 21 Nov 2022 03:42:19 -0800 (PST) X-Received: by 2002:a0c:ec04:0:b0:4c6:7622:3107 with SMTP id y4-20020a0cec04000000b004c676223107mr16719984qvo.118.1669030939203; Mon, 21 Nov 2022 03:42:19 -0800 (PST) Received: from bfoster (c-24-61-119-116.hsd1.ma.comcast.net. [24.61.119.116]) by smtp.gmail.com with ESMTPSA id u12-20020a05620a084c00b006ee949b8051sm7773590qku.51.2022.11.21.03.42.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Nov 2022 03:42:18 -0800 (PST) Date: Mon, 21 Nov 2022 06:42:24 -0500 From: Brian Foster To: Christian Brauner Cc: Ivan Babrou , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@cloudflare.com, Alexey Dobriyan , Al Viro , Theodore Ts'o , David Laight , Jonathan Corbet , Andrew Morton , David Hildenbrand , Johannes Weiner , Christoph Anton Mitterer , Mike Rapoport , Paul Gortmaker , Kalesh Singh Subject: Re: [PATCH v4] proc: report open files as size in stat() for /proc/pid/fd Message-ID: References: <20221024173140.30673-1-ivan@cloudflare.com> <20221119120111.2dh3tomoawwpyjrg@wittgenstein> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221119120111.2dh3tomoawwpyjrg@wittgenstein> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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 On Sat, Nov 19, 2022 at 01:01:11PM +0100, Christian Brauner wrote: > On Fri, Nov 18, 2022 at 02:33:27PM -0500, Brian Foster wrote: > > On Fri, Nov 18, 2022 at 11:18:36AM -0800, Ivan Babrou wrote: > > > On Fri, Nov 18, 2022 at 11:10 AM Brian Foster wrote: > > > > > +static int proc_fd_getattr(struct user_namespace *mnt_userns, > > > > > + const struct path *path, struct kstat *stat, > > > > > + u32 request_mask, unsigned int query_flags) > > > > > +{ > > > > > + struct inode *inode = d_inode(path->dentry); > > > > > + int rv = 0; > > > > > + > > > > > + generic_fillattr(&init_user_ns, inode, stat); > > > > > + > > > > > > > > Sorry I missed this on v3, but shouldn't this pass through the > > > > mnt_userns parameter? > > > > > > The mnt_userns parameter was added in 549c729 (fs: make helpers idmap > > > mount aware), and it's not passed anywhere in fs/proc. > > > > > > Looking at other uses of generic_fillattr, all of them use "init_user_ns": > > > > > > > Interesting. It looks like this would have used mnt_userns from > > vfs_getattr_nosec() before proc_fd_getattr() is wired up, right? I'm not > > familiar enough with that change to say whether /proc should use one > > value or the other, or perhaps it just doesn't matter.? > > > > Christian? > > Hey Brian, > > This should pass init_user_ns. So it is correct the way it is done now. > The init_user_ns is used to indicate that no idmappings are used and > since procfs doesn't support the creation of idmapped mounts and doesn't > need to, passing it here makes the most sense. Technically passing down > mnt_userns would work too but that would make it look like procfs could > support idmapped mounts which isn't the case and so we don't do it this > way. > Got it, thanks for the context. Ivan, Sorry for the noise. FWIW, for this version of the patch: Reviewed-by: Brian Foster > Starting soon this will be a lot clearer too since we're about to > introduce struct mnt_idmap and replace passing around userns here. > That'll make things also safer as the helpers that currently could be > passed a mnt_userns - which could be any userns - will now only be able > to take mnt_idmap which is a different type. > > Long story short, the way your patch does it is correct. > > Thanks! > Christian >