Skip to content

Commit

Permalink
vfs: fix pipe counter breakage
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Al Viro authored and Linus Torvalds committed Mar 12, 2013
1 parent 7c6baa3 commit a930d87
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions fs/pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,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) {
Expand Down

0 comments on commit a930d87

Please sign in to comment.