linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christian Brauner <brauner@kernel.org>
To: "Thomas Weißschuh" <linux@weissschuh.net>
Cc: Willy Tarreau <w@1wt.eu>, Shuah Khan <shuah@kernel.org>,
	linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-fsdevel@vger.kernel.org, Zhangjin Wu <falcon@tinylab.org>,
	Arnd Bergmann <arnd@arndb.de>
Subject: Re: [PATCH 2/2] proc: use generic setattr() for /proc/$PID/net
Date: Thu, 13 Jul 2023 13:49:39 +0200	[thread overview]
Message-ID: <20230713-abitur-alliierte-93460a210b1b@brauner> (raw)
In-Reply-To: <20230624-proc-net-setattr-v1-2-73176812adee@weissschuh.net>

On Sat, Jun 24, 2023 at 12:30:47PM +0200, Thomas Weißschuh wrote:
> All other files in /proc/$PID/ use proc_setattr().
> 
> Not using it allows the usage of chmod() on /proc/$PID/net, even on
> other processes owned by the same user.
> The same would probably also be true for other attributes to be changed.
> 
> As this technically represents an ABI change it is not marked for
> stable so any unlikely regressions are caught during a full release cycle.
> 
> Fixes: e9720acd728a ("[NET]: Make /proc/net a symlink on /proc/self/net (v3)")
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> ---
>  fs/proc/proc_net.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
> index a0c0419872e3..78f9e6b469c0 100644
> --- a/fs/proc/proc_net.c
> +++ b/fs/proc/proc_net.c
> @@ -321,6 +321,7 @@ static int proc_tgid_net_getattr(struct mnt_idmap *idmap,
>  const struct inode_operations proc_net_inode_operations = {
>  	.lookup		= proc_tgid_net_lookup,
>  	.getattr	= proc_tgid_net_getattr,
> +	.setattr        = proc_setattr,
>  };
>  
>  static int proc_tgid_net_readdir(struct file *file, struct dir_context *ctx)

So your concern really is specifically about /proc/$pid/net itself as
that's owned by the user and thus the user itself can chmod it and thus
also restrict access for other processess running with the same uid:

chmod 0000 /proc/1234/net
ls -al /proc/self/net
ls: cannot open directory '/proc/self/net/': Permission denied

Yeah, it's not a huge deal but it's arguably a bug especially since the
original commit from 2006 that introduced proc_setattr() was clear that
it should apply to anything beneath /proc/<pid>/ owned by the user.

So I agree and we should probably try and have the same behavior for
/proc/$pid/net as well. We can see if that breaks something.

  reply	other threads:[~2023-07-13 11:49 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-24 10:30 [PATCH 0/2] proc: proc_setattr for /proc/$PID/net Thomas Weißschuh
2023-06-24 10:30 ` [PATCH 1/2] selftests/nolibc: drop test chmod_net Thomas Weißschuh
2023-06-24 10:30 ` [PATCH 2/2] proc: use generic setattr() for /proc/$PID/net Thomas Weißschuh
2023-07-13 11:49   ` Christian Brauner [this message]
2023-06-30 14:06 ` [PATCH 0/2] proc: proc_setattr " Zhangjin Wu
2023-07-09  9:29   ` Willy Tarreau
2023-07-09 17:10     ` Thomas Weißschuh
2023-07-09 17:27       ` Willy Tarreau
2023-07-09 17:57         ` Thomas Weißschuh
2023-07-09 18:04           ` Willy Tarreau
2023-07-09 18:22             ` Thomas Weißschuh
2023-07-10  7:09               ` Willy Tarreau
2023-07-10  7:36                 ` Thomas Weißschuh
2023-07-13 11:51       ` Christian Brauner
2023-07-13 12:04         ` Thomas Weißschuh
2023-07-13 11:58 ` Christian Brauner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230713-abitur-alliierte-93460a210b1b@brauner \
    --to=brauner@kernel.org \
    --cc=arnd@arndb.de \
    --cc=falcon@tinylab.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux@weissschuh.net \
    --cc=shuah@kernel.org \
    --cc=w@1wt.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).