netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Satyam Sharma <satyam@infradead.org>
To: Domen Puncer <domen@coderock.org>
Cc: Jesper Juhl <jesper.juhl@gmail.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	netdev@vger.kernel.org, Steven Hirsch <shirsch@adelphia.net>,
	"David S. Miller" <davem@davemloft.net>,
	Franco Venturi <fventuri@mediaone.net>
Subject: Re: [PATCH] sb1000: prevent a potential NULL pointer dereference in sb1000_dev_ioctl()
Date: Sun, 29 Jul 2007 11:34:47 +0530 (IST)	[thread overview]
Message-ID: <alpine.LFD.0.999.0707291106500.30928@enigma.security.iitk.ac.in> (raw)
In-Reply-To: <20070729043707.GA8343@nd47.coderock.org>



On Sun, 29 Jul 2007, Domen Puncer wrote:

> On 29/07/07 00:02 +0200, Jesper Juhl wrote:
> > Hi,
> > 
> > Here's a small patch, prompted by a find by the Coverity checker, 
> > that removes a potential NULL pointer dereference from 
> > drivers/net/sb1000.c::sb1000_dev_ioctl().
> > The checker spotted that we do a NULL test of 'dev', yet we 
> > dereference the pointer prior to that check.
> > This patch simply moves the dereference after the NULL test.
> 
> But... it can't be called without a valid 'dev', no?
> A quick 'grep do_ioctl net/' confirms that all calls are in
> the form of 'dev->do_ioctl(dev, ...'.

Yup, I think so too ...


> > @@ -991,11 +991,13 @@ static int sb1000_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
> >  	short PID[4];
> >  	int ioaddr[2], status, frequency;
> >  	unsigned int stats[5];
> > -	struct sb1000_private *lp = netdev_priv(dev);
> > +	struct sb1000_private *lp;
> >  
> >  	if (!(dev && dev->flags & IFF_UP))
> >  		return -ENODEV;

I think we could get rid of the !dev check itself. Actually, the IFF_UP
check /also/ looks suspect to me for two reasons: (1) I remember Stephen
Hemminger once telling me dev->flags is legacy and unsafe, and one of
the netif_xxx() functions be used instead, and, (2) I wonder if we really
require the interface to be up and *running* when we do this ioctl.


Satyam

  reply	other threads:[~2007-07-29  5:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200707290002.42722.jesper.juhl@gmail.com>
2007-07-29  4:37 ` [PATCH] sb1000: prevent a potential NULL pointer dereference in sb1000_dev_ioctl() Domen Puncer
2007-07-29  6:04   ` Satyam Sharma [this message]
2007-07-29 18:34     ` Satyam Sharma
2007-07-29 18:48       ` Michael Buesch
2007-07-29 19:09         ` Satyam Sharma
2007-07-29 20:49           ` Michael Buesch

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=alpine.LFD.0.999.0707291106500.30928@enigma.security.iitk.ac.in \
    --to=satyam@infradead.org \
    --cc=davem@davemloft.net \
    --cc=domen@coderock.org \
    --cc=fventuri@mediaone.net \
    --cc=jesper.juhl@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=shirsch@adelphia.net \
    /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).