aboutsummaryrefslogtreecommitdiffstats
path: root/fs/pipe.c
diff options
context:
space:
mode:
authorAl Viro <viro@ZenIV.linux.org.uk>2013-03-11 22:59:49 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-03-12 11:29:17 -0400
commita930d8790552658140d7d0d2e316af4f0d76a512 (patch)
tree143e42bbaa41be61151389e386ba4cecc3bf6b3f /fs/pipe.c
parent7c6baa304b841673d3a55ea4fcf9a5cbf7a1674b (diff)
vfs: fix pipe counter breakage
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>
Diffstat (limited to 'fs/pipe.c')
-rw-r--r--fs/pipe.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/pipe.c b/fs/pipe.c
index 64a494cef0a0..2234f3f61f8d 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -863,6 +863,9 @@ pipe_rdwr_open(struct inode *inode, struct file *filp)
863{ 863{
864 int ret = -ENOENT; 864 int ret = -ENOENT;
865 865
866 if (!(filp->f_mode & (FMODE_READ|FMODE_WRITE)))
867 return -EINVAL;
868
866 mutex_lock(&inode->i_mutex); 869 mutex_lock(&inode->i_mutex);
867 870
868 if (inode->i_pipe) { 871 if (inode->i_pipe) {