All of lore.kernel.org
 help / color / mirror / Atom feed
From: Frank Zago <fzago@cray.com>
To: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Cc: Oleg Drokin <oleg.drokin@intel.com>,
	Andreas Dilger <andreas.dilger@intel.com>,
	"HPDD-discuss@lists.01.org" <HPDD-discuss@ml01.01.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"devel@driverdev.osuosl.org" <devel@driverdev.osuosl.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [HPDD-discuss] [PATCH] staging: lustre: include: lustre_update.h: Fix for possible null pointer dereference
Date: Thu, 29 Jan 2015 13:49:44 -0600	[thread overview]
Message-ID: <54CA8ED8.5040202@cray.com> (raw)
In-Reply-To: <CAKXHbyONc4FqCaKhm7KmLfdwKfgtWD4nBhqPsEHUKvx0CFGBRw@mail.gmail.com>

On 01/29/2015 01:47 PM, Rickard Strandqvist wrote:
> 2015-01-29 20:40 GMT+01:00 Frank Zago <fzago@cray.com>:
>> On 01/29/2015 12:47 PM, Rickard Strandqvist wrote:
>>>
>>> Fix a possible null pointer dereference, there is
>>> otherwise a risk of a possible null pointer dereference.
>>>
>>> This was found using a static code analysis program called cppcheck
>>>
>>> Signed-off-by: Rickard Strandqvist
>>> <rickard_strandqvist@spectrumdigital.se>
>>> ---
>>>    drivers/staging/lustre/lustre/include/lustre_update.h |    4 +++-
>>>    1 file changed, 3 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/staging/lustre/lustre/include/lustre_update.h
>>> b/drivers/staging/lustre/lustre/include/lustre_update.h
>>> index 84defce..00e1361 100644
>>> --- a/drivers/staging/lustre/lustre/include/lustre_update.h
>>> +++ b/drivers/staging/lustre/lustre/include/lustre_update.h
>>> @@ -165,12 +165,14 @@ static inline int update_get_reply_buf(struct
>>> update_reply *reply, void **buf,
>>>          int  result;
>>>
>>>          ptr = update_get_buf_internal(reply, index, &size);
>>> +
>>> +       LASSERT((ptr != NULL && size >= sizeof(int)));
>>
>>
>> Now size is tested before result. So it could assert if result < 0, while
>> the function would have returned before.
>>
>>
>>> +
>>>          result = *(int *)ptr;
>>>
>>>          if (result < 0)
>>>                  return result;
>>>
>>> -       LASSERT((ptr != NULL && size >= sizeof(int)));
>>>          *buf = ptr + sizeof(int);
>>>          return size - sizeof(int);
>>>    }
>>>
>>
>
>
>
> But if prt is null krachar on the line:
> result = *(int *)ptr;
>
> Maybe there should be two LASSERT then.


Yes, that would be safer.

Frank.

  reply	other threads:[~2015-01-29 19:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-29 18:47 [PATCH] staging: lustre: include: lustre_update.h: Fix for possible null pointer dereference Rickard Strandqvist
2015-01-29 19:40 ` [HPDD-discuss] " Frank Zago
2015-01-29 19:47   ` Rickard Strandqvist
2015-01-29 19:49     ` Frank Zago [this message]
2015-01-29 20:26       ` Drokin, Oleg

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=54CA8ED8.5040202@cray.com \
    --to=fzago@cray.com \
    --cc=HPDD-discuss@ml01.01.org \
    --cc=andreas.dilger@intel.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg.drokin@intel.com \
    --cc=rickard_strandqvist@spectrumdigital.se \
    /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.