All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: David Howells <dhowells@redhat.com>
Cc: kernel-janitors@vger.kernel.org, linux-afs@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [patch] afs: potential null dereference
Date: Mon, 22 Mar 2010 12:56:26 +0000	[thread overview]
Message-ID: <20100322125626.GM21571@bicker> (raw)
In-Reply-To: <28809.1269259520@redhat.com>

On Mon, Mar 22, 2010 at 12:05:20PM +0000, David Howells wrote:
> Dan Carpenter <error27@gmail.com> wrote:
> 
> > It seems clear from the surrounding code that xpermits is allowed to be 
> > NULL here.
> 
> Interesting.  The memcpy() won't oops due to this because if it is given a
> NULL pointer, it will also be given a zero count.  I wonder if this means the
> if-statement your patch adds is actually unnecessary...
> 

I was concerned about the dereference here:

+       if (xpermits)
+               memcpy(permits->permits, xpermits->permits,
                                         ^^^^^^^^^^^^^^^^^
+                       count * sizeof(struct afs_permit));

This code has been there for three years, so yeah, you would think if it
were a problem someone would have complained.  My theory was "xpermits"
was almost always non-null.

regards,
dan carpenter

> David

WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <error27@gmail.com>
To: David Howells <dhowells@redhat.com>
Cc: kernel-janitors@vger.kernel.org, linux-afs@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [patch] afs: potential null dereference
Date: Mon, 22 Mar 2010 15:56:26 +0300	[thread overview]
Message-ID: <20100322125626.GM21571@bicker> (raw)
In-Reply-To: <28809.1269259520@redhat.com>

On Mon, Mar 22, 2010 at 12:05:20PM +0000, David Howells wrote:
> Dan Carpenter <error27@gmail.com> wrote:
> 
> > It seems clear from the surrounding code that xpermits is allowed to be 
> > NULL here.
> 
> Interesting.  The memcpy() won't oops due to this because if it is given a
> NULL pointer, it will also be given a zero count.  I wonder if this means the
> if-statement your patch adds is actually unnecessary...
> 

I was concerned about the dereference here:

+       if (xpermits)
+               memcpy(permits->permits, xpermits->permits,
                                         ^^^^^^^^^^^^^^^^^
+                       count * sizeof(struct afs_permit));

This code has been there for three years, so yeah, you would think if it
were a problem someone would have complained.  My theory was "xpermits"
was almost always non-null.

regards,
dan carpenter

> David

  reply	other threads:[~2010-03-22 12:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-20 11:19 [patch] afs: potential null dereference Dan Carpenter
2010-03-20 11:19 ` Dan Carpenter
2010-03-22 12:05 ` David Howells
2010-03-22 12:56   ` Dan Carpenter [this message]
2010-03-22 12:56     ` Dan Carpenter
2010-03-22 13:05     ` David Howells
  -- strict thread matches above, loose matches on Subject: below --
2010-03-22 13:07 [PATCH] AFS: Potential " David Howells

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=20100322125626.GM21571@bicker \
    --to=error27@gmail.com \
    --cc=dhowells@redhat.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-afs@lists.infradead.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.