aboutsummaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorAl Viro <viro@ZenIV.linux.org.uk>2013-03-12 02:59:49 +0000
committerBen Hutchings <ben@decadent.org.uk>2013-03-20 15:03:29 +0000
commit0edb34d87ec58f4f1f9309e4ca9d0fa85be474c3 (patch)
tree2b5c2391fb813a18259dffc8d903e35351219d6b /fs
parent8885a53947b37ab206c8e3d8ca30ee06cb179ddf (diff)
vfs: fix pipe counter breakage
commit a930d8790552658140d7d0d2e316af4f0d76a512 upstream. If you open a pipe for neither read nor write, the pipe code will not add any usage counters to the pipe, causing the 'struct pipe_inode_info" to be potentially released early. That doesn't normally matter, since you cannot actually use the pipe, but the pipe release code - particularly fasync handling - still expects the actual pipe infrastructure to all be there. And rather than adding NULL pointer checks, let's just disallow this case, the same way we already do for the named pipe ("fifo") case. This is ancient going back to pre-2.4 days, and until trinity, nobody naver noticed. Reported-by: Dave Jones <davej@redhat.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'fs')
-rw-r--r--fs/pipe.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/pipe.c b/fs/pipe.c
index 05ed5cabd45..8ca88fcba07 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -859,6 +859,9 @@ pipe_rdwr_open(struct inode *inode, struct file *filp)
{
int ret = -ENOENT;
+ if (!(filp->f_mode & (FMODE_READ|FMODE_WRITE)))
+ return -EINVAL;
+
mutex_lock(&inode->i_mutex);
if (inode->i_pipe) {