Netdev List
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: hannes@stressinduktion.org
Cc: manjeet.p@samsung.com, kuznet@ms2.inr.ac.ru, jmorris@namei.org,
	yoshfuji@linux-ipv6.org, kaber@trash.net, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, pankaj.m@samsung.com,
	ajeet.y@samsung.com, r.thapliyal@samsung.com
Subject: Re: [PATCH] ipv6:ipv6_pinfo dereferenced after NULL check
Date: Tue, 22 Nov 2016 10:06:13 -0500 (EST)	[thread overview]
Message-ID: <20161122.100613.2091017686933180253.davem@davemloft.net> (raw)
In-Reply-To: <611c167e-cef4-691b-f154-1b6b6aa86e53@stressinduktion.org>

From: Hannes Frederic Sowa <hannes@stressinduktion.org>
Date: Tue, 22 Nov 2016 13:26:45 +0100

> On 22.11.2016 07:27, Manjeet Pawar wrote:
>> From: Rohit Thapliyal <r.thapliyal@samsung.com>
>> 
>> np checked for NULL and then dereferenced. It should be modified
>> for NULL case.
>> 
>> Signed-off-by: Rohit Thapliyal <r.thapliyal@samsung.com>
>> Signed-off-by: Manjeet Pawar <manjeet.p@samsung.com>
>> ---
>>  net/ipv6/ip6_output.c | 9 +++++----
>>  1 file changed, 5 insertions(+), 4 deletions(-)
>> 
>> diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
>> index 1dfc402..c2afa14 100644
>> --- a/net/ipv6/ip6_output.c
>> +++ b/net/ipv6/ip6_output.c
>> @@ -205,14 +205,15 @@ int ip6_xmit(const struct sock *sk, struct sk_buff *skb, struct flowi6 *fl6,
>>  	/*
>>  	 *	Fill in the IPv6 header
>>  	 */
>> -	if (np)
>> +	if (np) {
>>  		hlimit = np->hop_limit;
>> +		ip6_flow_hdr(
>> +					hdr, tclass, ip6_make_flowlabel(
>> +					net, skb, fl6->flowlabel,
>> +					np->autoflowlabel, fl6));
>> +	}
>>  	if (hlimit < 0)
>>  		hlimit = ip6_dst_hoplimit(dst);
>>  
>> -	ip6_flow_hdr(hdr, tclass, ip6_make_flowlabel(net, skb, fl6->flowlabel,
>> -				np->autoflowlabel, fl6));
>> -
>>  	hdr->payload_len = htons(seg_len);
>>  	hdr->nexthdr = proto;
>>  	hdr->hop_limit = hlimit;
>> 
> 
> 
> We always should initialize hdr and not skip the ip6_flow_hdr call.
> 
> Do you saw a bug or did you find this by code review? I wonder if np can
> actually be NULL at this point. Maybe we can just eliminate the NULL check.

Also the indentation is really off.

  reply	other threads:[~2016-11-22 15:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-22  6:27 [PATCH] ipv6:ipv6_pinfo dereferenced after NULL check Manjeet Pawar
2016-11-22 12:26 ` Hannes Frederic Sowa
2016-11-22 15:06   ` David Miller [this message]
     [not found] ` <CGME20161122122650epcas3p200ae9d4f95577997c98c37eb3e375ae8@epcas3p2.samsung.com>
     [not found]   ` <20161123044535epcms5p37a2a3f2c2c071fdac1ddb6b1a6c02cf6@epcms5p3>
2016-11-23 11:32     ` Hannes Frederic Sowa

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=20161122.100613.2091017686933180253.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=ajeet.y@samsung.com \
    --cc=hannes@stressinduktion.org \
    --cc=jmorris@namei.org \
    --cc=kaber@trash.net \
    --cc=kuznet@ms2.inr.ac.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manjeet.p@samsung.com \
    --cc=netdev@vger.kernel.org \
    --cc=pankaj.m@samsung.com \
    --cc=r.thapliyal@samsung.com \
    --cc=yoshfuji@linux-ipv6.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