lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 8 Mar 2013 09:53:07 -0500
From:	Dave Jones <davej@...hat.com>
To:	Linus Torvalds <torvalds@...ux-foundation.org>
Cc:	Linux Kernel <linux-kernel@...r.kernel.org>,
	Al Viro <viro@...iv.linux.org.uk>
Subject: Re: pipe_release oops.

On Thu, Mar 07, 2013 at 04:21:13PM -0800, Linus Torvalds wrote:
 > On Thu, Mar 7, 2013 at 2:36 PM, Dave Jones <davej@...hat.com> wrote:
 > >
 > > The hits keep on coming..
 > >
 > > [  255.609172] BUG: unable to handle kernel NULL pointer dereference at 0000000000000064
 > > [  255.610393] IP: [<ffffffff811bad62>] pipe_release+0x42/0xd0
 > 
 > Ok, I think this is the same issue as your fasync thing.
 > 
 > So add a "if (pipe) { }" in pipe_release() too.

Yeah, that does the trick.
I changed your other diff a little to use a goto, which reduces a level of indentation..

Signed-off-by: Dave Jones <davej@...hat.com>

diff --git a/fs/pipe.c b/fs/pipe.c
index 64a494c..49ba9cc 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -740,6 +740,9 @@ pipe_release(struct inode *inode, int decr, int decw)
 
 	mutex_lock(&inode->i_mutex);
 	pipe = inode->i_pipe;
+	if (!pipe)
+		goto out_unlock;
+
 	pipe->readers -= decr;
 	pipe->writers -= decw;
 
@@ -750,6 +753,8 @@ pipe_release(struct inode *inode, int decr, int decw)
 		kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
 		kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
 	}
+
+out_unlock:
 	mutex_unlock(&inode->i_mutex);
 
 	return 0;
@@ -759,10 +764,11 @@ static int
 pipe_read_fasync(int fd, struct file *filp, int on)
 {
 	struct inode *inode = file_inode(filp);
-	int retval;
+	int retval = 0;
 
 	mutex_lock(&inode->i_mutex);
-	retval = fasync_helper(fd, filp, on, &inode->i_pipe->fasync_readers);
+	if (inode->i_pipe)
+		retval = fasync_helper(fd, filp, on, &inode->i_pipe->fasync_readers);
 	mutex_unlock(&inode->i_mutex);
 
 	return retval;
@@ -773,10 +779,11 @@ static int
 pipe_write_fasync(int fd, struct file *filp, int on)
 {
 	struct inode *inode = file_inode(filp);
-	int retval;
+	int retval = 0;
 
 	mutex_lock(&inode->i_mutex);
-	retval = fasync_helper(fd, filp, on, &inode->i_pipe->fasync_writers);
+	if (inode->i_pipe)
+		retval = fasync_helper(fd, filp, on, &inode->i_pipe->fasync_writers);
 	mutex_unlock(&inode->i_mutex);
 
 	return retval;
@@ -787,16 +794,22 @@ static int
 pipe_rdwr_fasync(int fd, struct file *filp, int on)
 {
 	struct inode *inode = file_inode(filp);
-	struct pipe_inode_info *pipe = inode->i_pipe;
-	int retval;
+	struct pipe_inode_info *pipe;
+	int retval = 0;
 
 	mutex_lock(&inode->i_mutex);
+	pipe = inode->i_pipe;
+	if (!pipe)
+		goto out_unlock;
+
 	retval = fasync_helper(fd, filp, on, &pipe->fasync_readers);
 	if (retval >= 0) {
 		retval = fasync_helper(fd, filp, on, &pipe->fasync_writers);
 		if (retval < 0) /* this can happen only if on == T */
 			fasync_helper(-1, filp, 0, &pipe->fasync_readers);
 	}
+
+out_unlock:
 	mutex_unlock(&inode->i_mutex);
 	return retval;
 }
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ