From mboxrd@z Thu Jan 1 00:00:00 1970 From: Oleg Nesterov Subject: /proc/pid/fd && anon_inode_fops Date: Sat, 24 Aug 2013 20:29:39 +0200 Message-ID: <20130824182939.GA23630@redhat.com> References: <20130822185317.GI31117@1wt.eu> <20130822201530.GL31117@1wt.eu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Andy Lutomirski , Linus Torvalds , "security@kernel.org" , Ingo Molnar , Linux Kernel Mailing List , Al Viro , Linux FS Devel , Brad Spengler To: Willy Tarreau Return-path: Content-Disposition: inline In-Reply-To: <20130822201530.GL31117@1wt.eu> Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org Sorry for off-topic, I am just curios. On 08/22, Willy Tarreau wrote: > > It's not only that, it also supports sockets and pipes that you can access > via /proc/pid/fd and not via a real symlink which would try to open eg > "pipe:[23456]" instead of the real file. But sock_no_open() disallows this, and for good reason I guess. I am wondering, perhaps anon_inode should do the same? I do not see any problem, but it looks pointless and misleading to allow to open a file you can do nothing with. Or is there any reason why, say, open("anon_inode:[perf_event]") should succeed? Thanks, Oleg. --- x/fs/anon_inodes.c +++ x/fs/anon_inodes.c @@ -24,7 +24,15 @@ static struct vfsmount *anon_inode_mnt __read_mostly; static struct inode *anon_inode_inode; -static const struct file_operations anon_inode_fops; + +static int anon_open(struct inode *inode, struct file *file) +{ + return -ENXIO; +} + +static const struct file_operations anon_inode_fops = { + .open = anon_open, +}; /* * anon_inodefs_dname() is called from d_path().