From: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
To: Frank Zago <fzago@cray.com>
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 20:47:21 +0100 [thread overview]
Message-ID: <CAKXHbyONc4FqCaKhm7KmLfdwKfgtWD4nBhqPsEHUKvx0CFGBRw@mail.gmail.com> (raw)
In-Reply-To: <54CA8CA7.2070403@cray.com>
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.
Kind regards
Rickard Strandqvist
next prev parent reply other threads:[~2015-01-29 19:47 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 [this message]
2015-01-29 19:49 ` Frank Zago
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=CAKXHbyONc4FqCaKhm7KmLfdwKfgtWD4nBhqPsEHUKvx0CFGBRw@mail.gmail.com \
--to=rickard_strandqvist@spectrumdigital.se \
--cc=HPDD-discuss@ml01.01.org \
--cc=andreas.dilger@intel.com \
--cc=devel@driverdev.osuosl.org \
--cc=fzago@cray.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg.drokin@intel.com \
/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.