public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: "Justin T. Gibbs" <gibbs@scsiguy.com>
To: Jesper Juhl <jesper.juhl@gmail.com>
Cc: James Bottomley <James.Bottomley@steeleye.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	James Bottomley <jejb@kernel.org>,
	linux-scsi@vger.kernel.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH][RESEND] Fix a potential NULL pointer deref in the aic7xxx, ahc_print_register() function
Date: Sun, 05 Aug 2007 09:42:31 -0600	[thread overview]
Message-ID: <46B5EFE7.6090008@scsiguy.com> (raw)
In-Reply-To: <9a8748490708050836m20b5dd38gf6a8968cd4b106f9@mail.gmail.com>

All of this logic was simplified back in '05 in the BSD drivers by adding
this to the top of the function:

        u_int   dummy_column;
  
        if (cur_column == NULL) {
                dummy_column = 0;
                cur_column = &dummy_column;
        }

and then stripping out the cur_column == NULL checks in the routine.

--
Justin

Jesper Juhl wrote:
> On 04/08/07, James Bottomley <James.Bottomley@steeleye.com> wrote:
>> On Sat, 2007-08-04 at 20:30 +0200, Jesper Juhl wrote:
>>> (resend of patch previously submitted on 28-Jul-2007 23:06)
>>>
>>>
>>> Ehlo,
>>>
>>> The Coverity checker noticed that we have a potential NULL pointer
>>> deref in drivers/scsi/aic7xxx/aic7xxx_core.c::ahc_print_register().
>>> This patch handles it by adding the same test against NULL that is
>>> used elsewhere in the same function.
>> It's on my list of things to look at ... but not very high.  I suspect
>> it actually isn't triggerable, but if you can tell me how, it will save
>> me from looking.
>>
> 
> Here's what Coverity reported :
> ...
> 6525 	int
> 6526 	ahc_print_register(ahc_reg_parse_entry_t *table, u_int num_entries,
> 6527 			   const char *name, u_int address, u_int value,
> 6528 			   u_int *cur_column, u_int wrap_point)
> 6529 	{
> 6530 		int	printed;
> 6531 		u_int	printed_mask;
> 6532 	
> 
> Event var_compare_op: Added "cur_column" due to comparison "cur_column != 0"
> Also see events: [var_deref_op]
> At conditional (1): "cur_column != 0" taking false path
> 
> 6533 		if (cur_column != NULL && *cur_column >= wrap_point) {
> 6534 			printf("\n");
> 6535 			*cur_column = 0;
> 6536 		}
> 6537 		printed = printf("%s[0x%x]", name, value);
> 
> At conditional (2): "table == 0" taking true path
> 
> 6538 		if (table == NULL) {
> 6539 			printed += printf(" ");
> 
> Event var_deref_op: Variable "cur_column" tracked as NULL was dereferenced.
> Also see events: [var_compare_op]
> 
> 6540 			*cur_column += printed;
> 6541 			return (printed);
> 6542 		}
> ...
> 
> So it requires a NULL 'table' and a != NULL 'cur_column' to trigger.
> Whether or not that's actually possible I'm not sure, but it seems
> safer to guard against it :)
> 
> 
> By the way; if this can actually be triggered, then
> ahd_print_register() has the same problem.
> 
> 

  reply	other threads:[~2007-08-05 16:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200708042030.52405.jesper.juhl@gmail.com>
2007-08-04 19:43 ` [PATCH][RESEND] Fix a potential NULL pointer deref in the aic7xxx, ahc_print_register() function James Bottomley
2007-08-05 15:36   ` Jesper Juhl
2007-08-05 15:42     ` Justin T. Gibbs [this message]
2007-08-05 15:52       ` Jesper Juhl
2007-08-05 15:53     ` James Bottomley

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=46B5EFE7.6090008@scsiguy.com \
    --to=gibbs@scsiguy.com \
    --cc=James.Bottomley@steeleye.com \
    --cc=akpm@linux-foundation.org \
    --cc=jejb@kernel.org \
    --cc=jesper.juhl@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@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