aboutsummaryrefslogtreecommitdiffstats
path: root/arch/ia64
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2014-11-18 23:38:21 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2014-12-10 21:32:15 -0500
commitbd9b51e79cb0b8bc00a7e0076a4a8963ca4a797c (patch)
treebee3cc60bfbe1d7f837826bf495c0cf92747404b /arch/ia64
parent1f55a6ec940fb45e3edaa52b6e9fc40cf8e18dcb (diff)
make default ->i_fop have ->open() fail with ENXIO
As it is, default ->i_fop has NULL ->open() (along with all other methods). The only case where it matters is reopening (via procfs symlink) a file that didn't get its ->f_op from ->i_fop - anything else will have ->i_fop assigned to something sane (default would fail on read/write/ioctl/etc.). Unfortunately, such case exists - alloc_file() users, especially anon_get_file() ones. There we have tons of opened files of very different kinds sharing the same inode. As the result, attempt to reopen those via procfs succeeds and you get a descriptor you can't do anything with. Moreover, in case of sockets we set ->i_fop that will only be used on such reopen attempts - and put a failing ->open() into it to make sure those do not succeed. It would be simpler to put such ->open() into default ->i_fop and leave it unchanged both for anon inode (as we do anyway) and for socket ones. Result: * everything going through do_dentry_open() works as it used to * sock_no_open() kludge is gone * attempts to reopen anon-inode files fail as they really ought to * ditto for aio_private_file() * ditto for perfmon - this one actually tried to imitate sock_no_open() trick, but failed to set ->i_fop, so in the current tree reopens succeed and yield completely useless descriptor. Intent clearly had been to fail with -ENXIO on such reopens; now it actually does. * everything else that used alloc_file() keeps working - it has ->i_fop set for its inodes anyway Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'arch/ia64')
-rw-r--r--arch/ia64/kernel/perfmon.c10
1 files changed, 0 insertions, 10 deletions
diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
index 5845ffea67c3..ac4528f5acd1 100644
--- a/arch/ia64/kernel/perfmon.c
+++ b/arch/ia64/kernel/perfmon.c
@@ -2145,22 +2145,12 @@ doit:
2145 return 0; 2145 return 0;
2146} 2146}
2147 2147
2148static int
2149pfm_no_open(struct inode *irrelevant, struct file *dontcare)
2150{
2151 DPRINT(("pfm_no_open called\n"));
2152 return -ENXIO;
2153}
2154
2155
2156
2157static const struct file_operations pfm_file_ops = { 2148static const struct file_operations pfm_file_ops = {
2158 .llseek = no_llseek, 2149 .llseek = no_llseek,
2159 .read = pfm_read, 2150 .read = pfm_read,
2160 .write = pfm_write, 2151 .write = pfm_write,
2161 .poll = pfm_poll, 2152 .poll = pfm_poll,
2162 .unlocked_ioctl = pfm_ioctl, 2153 .unlocked_ioctl = pfm_ioctl,
2163 .open = pfm_no_open, /* special open code to disallow open via /proc */
2164 .fasync = pfm_fasync, 2154 .fasync = pfm_fasync,
2165 .release = pfm_close, 2155 .release = pfm_close,
2166 .flush = pfm_flush 2156 .flush = pfm_flush