[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CALCETrVekFGzzu1VyZf7s42hFZoT9TVV6FuW5AmrBELUxkZhwQ@mail.gmail.com>
Date: Wed, 24 Apr 2024 20:31:51 -0700
From: Andy Lutomirski <luto@...capital.net>
To: Al Viro <viro@...iv.linux.org.uk>
Cc: stsp <stsp2@...dex.ru>, linux-kernel@...r.kernel.org,
Stefan Metzmacher <metze@...ba.org>, Eric Biederman <ebiederm@...ssion.com>,
Andy Lutomirski <luto@...nel.org>, Christian Brauner <brauner@...nel.org>, Jan Kara <jack@...e.cz>,
Jeff Layton <jlayton@...nel.org>, Chuck Lever <chuck.lever@...cle.com>,
Alexander Aring <alex.aring@...il.com>, linux-fsdevel@...r.kernel.org,
linux-api@...r.kernel.org, Paolo Bonzini <pbonzini@...hat.com>,
Christian Göttsche <cgzones@...glemail.com>,
Aleksa Sarai <cyphar@...har.com>
Subject: Re: [PATCH v2 0/2] implement OA2_INHERIT_CRED flag for openat2()
On Wed, Apr 24, 2024 at 6:44 PM Al Viro <viro@...iv.linux.org.uk> wrote:
>
> On Wed, Apr 24, 2024 at 05:43:02PM -0700, Andy Lutomirski wrote:
>
> > I like that, but you're blocking it the wrong way. My concern is that
> > someone does dfd = open("/proc/PID/fd/3") and then openat(dfd, ...,
> > OA2_INHERIT_CRED); IIRC open("/proc/PID/fd/3") is extremely magical
> > and returns the _same open file description_ (struct file) as PID's fd
> > 3.
>
> No, it doesn't. We could implement that, but if we do that'll be
> *not* a part of procfs and it's going to be limited to current task
> only.
Egads -- why would we want to implement that? In the apparently
incorrect model in my head, Linux's behavior was ridiculous and only
made sense for some historical reason. But I wonder why I thought
that.
Diving a tiny bit down the rabbit hole, I have a copy of TLPI on my
bookshelf, and I bought it quite a long time ago and read a bunch of
it when I got it, and my copy is *wrong*! Section 5.11 has the
behavior of /dev/fd very clearly documented as working like dup().
And here it is: erratum 107. Whoopsies!
https://man7.org/tlpi/errata/index.html
Anyway, I retract that particular objection to the series. But I
wouldn't be shocked if one can break a normal modern systemd using the
patchset -- systemd does all kinds of fun things involving passing
file descriptors around.
--Andy
Powered by blists - more mailing lists