Message ID | 1495836052-8377-1-git-send-email-cugyly@163.com |
---|---|
State | Accepted, archived |
Delegated to: | David Miller |
Headers | show |
From: yuan linyu <cugyly@163.com> Date: Sat, 27 May 2017 06:00:52 +0800 > From: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn> > > Signed-off-by: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn> Applied, thanks.
On Mon, 2017-05-29 at 23:30 -0400, David Miller wrote: > From: yuan linyu <cugyly@163.com> > Date: Sat, 27 May 2017 06:00:52 +0800 > > > From: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn> > > > > Signed-off-by: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn> > > Applied, thanks. OK, but is it really safe though? Could "space" (an int) ever be negative after subtracting "pad" and "data_len"?
On 5/29/17 9:41 PM, Joe Perches wrote: > On Mon, 2017-05-29 at 23:30 -0400, David Miller wrote: >> From: yuan linyu <cugyly@163.com> >> Date: Sat, 27 May 2017 06:00:52 +0800 >> >>> From: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn> >>> >>> Signed-off-by: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn> >> Applied, thanks. > OK, but is it really safe though? > > Could "space" (an int) ever be negative after > subtracting "pad" and "data_len"? > that function should be converted to skb_put_zero once it hits net-next.
Hi joe, > -----Original Message----- > From: netdev-owner@vger.kernel.org [mailto:netdev-owner@vger.kernel.org] > On Behalf Of Joe Perches > Sent: Tuesday, May 30, 2017 11:41 AM > To: David Miller; cugyly@163.com > Cc: netdev@vger.kernel.org; dsahern@gmail.com; YUAN Linyu > Subject: Re: [PATCH net-next] net: ndisc.c: reduce size of > __ndisc_fill_addr_option() > > On Mon, 2017-05-29 at 23:30 -0400, David Miller wrote: > > From: yuan linyu <cugyly@163.com> > > Date: Sat, 27 May 2017 06:00:52 +0800 > > > > > From: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn> > > > > > > Signed-off-by: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn> > > > > Applied, thanks. > > OK, but is it really safe though? > > Could "space" (an int) ever be negative after > subtracting "pad" and "data_len"? It's safe, check int space = __ndisc_opt_addr_space(data_len, pad); space is maximum aligned value. And I check current pad, the maximum value is 2.
> -----Original Message----- > From: David Ahern [mailto:dsahern@gmail.com] > Sent: Tuesday, May 30, 2017 11:42 AM > To: Joe Perches; David Miller; cugyly@163.com > Cc: netdev@vger.kernel.org; YUAN Linyu > Subject: Re: [PATCH net-next] net: ndisc.c: reduce size of > __ndisc_fill_addr_option() > > On 5/29/17 9:41 PM, Joe Perches wrote: > > On Mon, 2017-05-29 at 23:30 -0400, David Miller wrote: > >> From: yuan linyu <cugyly@163.com> > >> Date: Sat, 27 May 2017 06:00:52 +0800 > >> > >>> From: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn> > >>> > >>> Signed-off-by: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn> > >> Applied, thanks. > > OK, but is it really safe though? > > > > Could "space" (an int) ever be negative after > > subtracting "pad" and "data_len"? > > > > that function should be converted to skb_put_zero once it hits net-next. I will check it
> > -----Original Message----- > > From: David Ahern [mailto:dsahern@gmail.com] > > Sent: Tuesday, May 30, 2017 11:42 AM > > To: Joe Perches; David Miller; cugyly@163.com > > Cc: netdev@vger.kernel.org; YUAN Linyu > > Subject: Re: [PATCH net-next] net: ndisc.c: reduce size of > > __ndisc_fill_addr_option() > > > > On 5/29/17 9:41 PM, Joe Perches wrote: > > > On Mon, 2017-05-29 at 23:30 -0400, David Miller wrote: > > >> From: yuan linyu <cugyly@163.com> > > >> Date: Sat, 27 May 2017 06:00:52 +0800 > > >> > > >>> From: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn> > > >>> > > >>> Signed-off-by: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn> > > >> Applied, thanks. > > > OK, but is it really safe though? > > > > > > Could "space" (an int) ever be negative after > > > subtracting "pad" and "data_len"? > > > > > > > that function should be converted to skb_put_zero once it hits net-next. > I will check it I can't find skb_put_zero
On 5/30/17 6:29 PM, YUAN Linyu wrote: >>> that function should be converted to skb_put_zero once it hits net-next. >> I will check it > I can't find skb_put_zero I believe the decision was to put it in Johannes' tree and it will make its way to DaveM's tree. Give some time.
Ok, I will send v2 later > -----Original Message----- > From: David Ahern [mailto:dsahern@gmail.com] > Sent: Wednesday, May 31, 2017 8:40 AM > To: YUAN Linyu; David Ahern; Joe Perches; David Miller; cugyly@163.com > Cc: netdev@vger.kernel.org > Subject: Re: [PATCH net-next] net: ndisc.c: reduce size of > __ndisc_fill_addr_option() > > On 5/30/17 6:29 PM, YUAN Linyu wrote: > >>> that function should be converted to skb_put_zero once it hits net-next. > >> I will check it > > I can't find skb_put_zero > > I believe the decision was to put it in Johannes' tree and it will make > its way to DaveM's tree. Give some time.
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c index d310dc4..414e929 100644 --- a/net/ipv6/ndisc.c +++ b/net/ipv6/ndisc.c @@ -148,17 +148,18 @@ void __ndisc_fill_addr_option(struct sk_buff *skb, int type, void *data, opt[0] = type; opt[1] = space>>3; + opt += 2; + space -= 2; - memset(opt + 2, 0, pad); + memset(opt, 0, pad); opt += pad; space -= pad; - memcpy(opt+2, data, data_len); - data_len += 2; + memcpy(opt, data, data_len); opt += data_len; space -= data_len; - if (space > 0) - memset(opt, 0, space); + + memset(opt, 0, space); } EXPORT_SYMBOL_GPL(__ndisc_fill_addr_option);