Commit 1d37307a authored by Al Viro's avatar Al Viro Committed by Greg Kroah-Hartman

vfs: fix pipe counter breakage

commit a930d879 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: default avatarDave Jones <davej@redhat.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 5f4027c6
...@@ -863,6 +863,9 @@ pipe_rdwr_open(struct inode *inode, struct file *filp) ...@@ -863,6 +863,9 @@ pipe_rdwr_open(struct inode *inode, struct file *filp)
{ {
int ret = -ENOENT; int ret = -ENOENT;
if (!(filp->f_mode & (FMODE_READ|FMODE_WRITE)))
return -EINVAL;
mutex_lock(&inode->i_mutex); mutex_lock(&inode->i_mutex);
if (inode->i_pipe) { if (inode->i_pipe) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment