linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Walker <dwalker@fifo99.com>
To: Earl Chew <earl_chew@agilent.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/1]: fs: pipe.c null pointer dereference + sign off
Date: Mon, 19 Oct 2009 12:43:15 -0700	[thread overview]
Message-ID: <1255981395.23353.46.camel@desktop> (raw)
In-Reply-To: <4ADCAC33.4070908@agilent.com>

On Mon, 2009-10-19 at 11:13 -0700, Earl Chew wrote:
> [ Exactly as before, but with sign off ]
> 

You've got a few more submission related issues, see below.

> This patch fixes a null pointer exception in pipe_rdwr_open() which
> generates the stack trace:
> 
> 
>  > Unable to handle kernel NULL pointer dereference at 0000000000000028 RIP:
>  >  [<ffffffff802899a5>] pipe_rdwr_open+0x35/0x70
>  >  [<ffffffff8028125c>] __dentry_open+0x13c/0x230
>  >  [<ffffffff8028143d>] do_filp_open+0x2d/0x40
>  >  [<ffffffff802814aa>] do_sys_open+0x5a/0x100
>  >  [<ffffffff8021faf3>] sysenter_do_call+0x1b/0x67
> 
> This defect is also described in:
>    http://lkml.org/lkml/2009/10/14/184
>    http://bugzilla.kernel.org/show_bug.cgi?id=14416
> 
> 
> The failure mode is triggered by an attempt to open an anonymous
> pipe via /proc/pid/fd/* as exemplified by this script:
> 
> =============================================================
> #!/bin/sh
> while : ; do
>     { echo y ; sleep 1 ; } | { while read ; do echo z$REPLY; done ; } &
>     PID=$!
>     OUT=$(ps -efl | grep 'sleep 1' | grep -v grep |
>          { read PID REST ; echo $PID; } )
>     OUT="${OUT%% *}"
>     DELAY=$((RANDOM * 1000 / 32768))
>     usleep $((DELAY * 1000 + RANDOM % 1000 ))
>     echo n > /proc/$OUT/fd/1                 # Trigger defect
> done
> =============================================================
> 
> Note that the failure window is quite small and I could only
> reliably reproduce the defect by inserting a small delay
> in pipe_rdwr_open(). For example:
> 
>   static int
>   pipe_rdwr_open(struct inode *inode, struct file *filp)
>   {
>         msleep(100);
>         mutex_lock(&inode->i_mutex);
> 
> 
> Although the defect was observed in pipe_rdwr_open(), I think it
> makes sense to replicate the change through all the pipe_*_open()
> functions.
> 
> The core of the change is to verify that inode->i_pipe has not
> been released before attempting to manipulate it. If inode->i_pipe
> is no longer present, return ENOENT to indicate so.
> 
> The comment about potentially using atomic_t for i_pipe->readers
> and i_pipe->writers has also been removed because it is no longer
> relevant in this context. The inode->i_mutex lock must be used so
> that inode->i_pipe can be dealt with correctly.
> 
> 
> Signed-off-by: Earl Chew <earl_chew@agilent.com>
> 
> 
> --- linux-2.6.21_mvlcge500/fs/pipe.c.orig    2009-10-15 
> 20:33:53.000000000 -0700
> +++ linux-2.6.21_mvlcge500/fs/pipe.c    2009-10-15 21:21:25.000000000 -0700
> @@ -712,36 +712,55 @@ pipe_rdwr_release(struct inode *inode, s
>   static int

You patch looks like it might be line wrapped .. Sometimes mailers will
do that if you don't tell them the content is already formatted.

Also I see your using a MontaVista kernel, which is older than current
mainline .. I would assume you tested this on a recent kernel also?

>   pipe_read_open(struct inode *inode, struct file *filp)
>   {
> -    /* We could have perhaps used atomic_t, but this and friends
> -       below are the only places.  So it doesn't seem worthwhile.  */
> +    int ret = -ENOENT;

>From checkpatch,

ERROR: code indent should use tabs where possible
#125: FILE: fs/pipe.c:720:
+        ret = 0;$

It looks like maybe your mailer (or copy and paste) may have stripped
all the tabs off your patch. This makes is very difficult to apply.


Daniel


  reply	other threads:[~2009-10-19 19:43 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-16 14:37 [PATCH v1 1/1]: fs: pipe.c null pointer dereference Earl Chew
2009-10-16 21:50 ` Jiri Kosina
2009-10-19 18:13 ` [PATCH v2 1/1]: fs: pipe.c null pointer dereference + sign off Earl Chew
2009-10-19 19:43   ` Daniel Walker [this message]
2009-10-19 21:29     ` Earl Chew
2009-10-19 21:35   ` [PATCH v3 1/1]: fs: pipe.c null pointer dereference + sign off + unmangled diffs Earl Chew
2009-10-19 22:55     ` [PATCH v4 1/1]: fs: pipe.c null pointer dereference + really " Earl Chew
2009-10-21  9:38       ` Américo Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1255981395.23353.46.camel@desktop \
    --to=dwalker@fifo99.com \
    --cc=earl_chew@agilent.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).