[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJfpegs4GVirNVtf4OqunzNwbXQywZVkxpGPtpN=ZonHU2SpiA@mail.gmail.com>
Date: Thu, 12 May 2022 14:56:22 +0200
From: Miklos Szeredi <miklos@...redi.hu>
To: Simon Ser <contact@...rsion.fr>
Cc: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-fsdevel@...r.kernel.org" <linux-fsdevel@...r.kernel.org>
Subject: Re: procfs: open("/proc/self/fd/...") allows bypassing O_RDONLY
On Thu, 12 May 2022 at 14:41, Simon Ser <contact@...rsion.fr> wrote:
>
> On Thursday, May 12th, 2022 at 12:37, Simon Ser <contact@...rsion.fr> wrote:
>
> > what would be a good way to share a FD to another
> > process without allowing it to write to the underlying file?
>
> (I'm reminded that memfd + seals exist for this purpose. Still, I'd be
> interested to know whether that O_RDONLY/O_RDWR behavior is intended,
> because it's pretty surprising. The motivation for using O_RDONLY over
> memfd seals is that it isn't Linux-specific.)
Yes, this is intended. The /proc/$PID/fd/$FD file represents the
inode pointed to by $FD. So the open flags for $FD are irrelevant
when operating on the proc fd file.
Thanks,
Miklos
Powered by blists - more mailing lists