mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Jesper Juhl" <jesper.juhl@gmail.com>
To: "Jan Kara" <jack@suse.cz>
Cc: linux-kernel@vger.kernel.org, akpm@osdl.org
Subject: Re: [PATCH] fix potential null pointer deref in quota
Date: Sun, 26 Mar 2006 14:44:25 +0200	[thread overview]
Message-ID: <9a8748490603260444w4ecfc5b4u820dd5a99f1f0c3c@mail.gmail.com> (raw)
In-Reply-To: <20060320094601.GA11037@atrey.karlin.mff.cuni.cz>

On 3/20/06, Jan Kara <jack@suse.cz> wrote:
>   Hello,
>
> > The coverity checker noticed that we may pass a NULL super_block to
> > do_quotactl() that dereferences it.
> > Dereferencing NULL pointers is bad medicine, better check and fail
> > gracefully.
>   Umm, when do you think we can dereference NULL pointer to a super_block?
> check_quotactl_valid() allows sb==NULL only in the case of Q_SYNC command.
> And that is handled in do_quotactl() correctly even if sb==NULL...
>

Reading the code again it looks like you are right and that this is a
false positive by the coverity checker.

This is what the checker had to say :


346  	asmlinkage long sys_quotactl(unsigned int cmd, const char __user
*special, qid_t id, void __user *addr)
347  	{
348  		uint cmds, type;

Event assign_zero: Variable "sb" assigned value 0.
Also see events:
[var_deref_model][var_deref_model][var_deref_model][var_deref_model][var_deref_model][var_deref_model][var_deref_model][var_deref_model]

349  		struct super_block *sb = NULL;
350  		struct block_device *bdev;
351  		char *tmp;
352  		int ret;
353  	
354  		cmds = cmd >> SUBCMDSHIFT;
355  		type = cmd & SUBCMDMASK;
356  	

At conditional (1): "cmds != 8388609" taking false path
At conditional (2): "special != 0" taking false path

357  		if (cmds != Q_SYNC || special) {
358  			tmp = getname(special);
359  			if (IS_ERR(tmp))
360  				return PTR_ERR(tmp);
361  			bdev = lookup_bdev(tmp);
362  			putname(tmp);
363  			if (IS_ERR(bdev))
364  				return PTR_ERR(bdev);
365  			sb = get_super(bdev);
366  			bdput(bdev);
367  			if (!sb)
368  				return -ENODEV;
369  		}
370  	
371  		ret = check_quotactl_valid(sb, type, cmds, id);

At conditional (3): "ret >= 0" taking true path

372  		if (ret >= 0)

Event var_deref_model: Variable "sb" tracked as NULL was passed to a
function that dereferences it. [model]
Event var_deref_model: Variable "sb" tracked as NULL was passed to a
function that dereferences it. [model]
Event var_deref_model: Variable "sb" tracked as NULL was passed to a
function that dereferences it. [model]
Event var_deref_model: Variable "sb" tracked as NULL was passed to a
function that dereferences it. [model]
Event var_deref_model: Variable "sb" tracked as NULL was passed to a
function that dereferences it. [model]
Event var_deref_model: Variable "sb" tracked as NULL was passed to a
function that dereferences it. [model]
Event var_deref_model: Variable "sb" tracked as NULL was passed to a
function that dereferences it. [model]
Event var_deref_model: Variable "sb" tracked as NULL was passed to a
function that dereferences it. [model]
Also see events:
[assign_zero][var_deref_model][var_deref_model][var_deref_model][var_deref_model][var_deref_model][var_deref_model][var_deref_model]

373  			ret = do_quotactl(sb, type, cmds, id, addr);
374  		if (sb)
375  			drop_super(sb);
376  	
377  		return ret;
378  	}



--
Jesper Juhl <jesper.juhl@gmail.com>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html

      reply	other threads:[~2006-03-26 12:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-18 22:08 Jesper Juhl
2006-03-20  7:23 ` Andrew Morton
2006-03-20  8:01   ` Jesper Juhl
2006-03-20  9:46 ` Jan Kara
2006-03-26 12:44   ` Jesper Juhl [this message]

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=9a8748490603260444w4ecfc5b4u820dd5a99f1f0c3c@mail.gmail.com \
    --to=jesper.juhl@gmail.com \
    --cc=akpm@osdl.org \
    --cc=jack@suse.cz \
    --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

all inboxes | Powered by JetHome®