From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andy Lutomirski Subject: Re: /proc/pid/fd && anon_inode_fops Date: Sun, 25 Aug 2013 12:17:27 -0700 Message-ID: References: <20130822185317.GI31117@1wt.eu> <20130822201530.GL31117@1wt.eu> <20130824182939.GA23630@redhat.com> <20130824212432.GA9299@1wt.eu> <20130825052317.GZ27005@ZenIV.linux.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Cc: Al Viro , Willy Tarreau , Oleg Nesterov , "security@kernel.org" , Ingo Molnar , Linux Kernel Mailing List , Linux FS Devel , Brad Spengler To: Linus Torvalds Return-path: In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org On Sun, Aug 25, 2013 at 11:32 AM, Linus Torvalds wrote: > On Sat, Aug 24, 2013 at 10:23 PM, Al Viro wrote: >> >> We are really stuck with the current semantics here - switching to >> *BSD one would not only mean serious surgery on descriptor handling >> (it's one of the wartier areas in *BSD VFS, in large part because >> of magic-open-really-a-dup kludges they have to do), it would change >> a long-standing userland API that had been there for nearly 20 years >> _and_ one that tends to be used in corner cases of hell knows how many >> scripts. > > Actually, I'm pretty sure we did have the "dup" semantics at one point > (long ago), and they were really nice (because you could use them to > see where in the stream the fd was etc). It just fit so horribly badly > into the VFS semantics that it got changed into the current "new file > descriptor" one. Afaik, nothing broke. > We have fdinfo now, which is IMO much less scary. Programs can find the stream position, but they can't change it. OTOH... > So I'm not really sure about the "we're stuck with it" for semantic > reasons, and it turns out that very few programs/scripts actually use > /proc//fd/ at all (random use of /dev/stdin is likely the > most common case). But I agree about the "serious surgery on > descriptor handling" part. .../dev/stdin doesn't actually do what you expect if input comes from something seekable. $ cat /proc/self/fd/3 test $ cat /proc/self/fd/3 test $ cat /proc/self/fd/3 test $ cat <&3 est $ cat /proc/self/fd/3 test $ cat <&3 (I'm not going to advocate for changing this.) --Andy > > Linus -- Andy Lutomirski AMA Capital Management, LLC