* [PATCH RFC net-next] net: Assert napi_gro_cb size against skb->cb[]
@ 2015-07-31 18:51 Florian Fainelli
2015-07-31 20:14 ` Tom Herbert
2015-07-31 20:24 ` Florian Westphal
0 siblings, 2 replies; 5+ messages in thread
From: Florian Fainelli @ 2015-07-31 18:51 UTC (permalink / raw)
To: netdev; +Cc: herbert, daniel, edumazet, davem, Florian Fainelli
On 64-bits hosts, napi_gro_cb is 48 bytes, which is exactly the size of
skb->cb[], while on 32-bits hosts it is 36 bytes, but if it were to
grow, we would not be catching a size inflation as we should.
Make sure that we have enough room for a napi_gro_cb to be hosted in
skb->cb[], and put this build-time assertion in skb_gro_reset_offset()
since this function is invoked by the GRO layers entry points.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
net/core/dev.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/core/dev.c b/net/core/dev.c
index 4870c3556a5a..20bc82604b75 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -4115,6 +4115,8 @@ static void skb_gro_reset_offset(struct sk_buff *skb)
const struct skb_shared_info *pinfo = skb_shinfo(skb);
const skb_frag_t *frag0 = &pinfo->frags[0];
+ BUILD_BUG_ON(sizeof(skb->cb) < sizeof(struct napi_gro_cb));
+
NAPI_GRO_CB(skb)->data_offset = 0;
NAPI_GRO_CB(skb)->frag0 = NULL;
NAPI_GRO_CB(skb)->frag0_len = 0;
--
2.1.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH RFC net-next] net: Assert napi_gro_cb size against skb->cb[]
2015-07-31 18:51 [PATCH RFC net-next] net: Assert napi_gro_cb size against skb->cb[] Florian Fainelli
@ 2015-07-31 20:14 ` Tom Herbert
2015-07-31 20:24 ` Florian Westphal
1 sibling, 0 replies; 5+ messages in thread
From: Tom Herbert @ 2015-07-31 20:14 UTC (permalink / raw)
To: Florian Fainelli
Cc: Linux Kernel Network Developers, Herbert Xu, daniel, Eric Dumazet,
David S. Miller
On Fri, Jul 31, 2015 at 11:51 AM, Florian Fainelli <f.fainelli@gmail.com> wrote:
> On 64-bits hosts, napi_gro_cb is 48 bytes, which is exactly the size of
> skb->cb[], while on 32-bits hosts it is 36 bytes, but if it were to
> grow, we would not be catching a size inflation as we should.
>
> Make sure that we have enough room for a napi_gro_cb to be hosted in
> skb->cb[], and put this build-time assertion in skb_gro_reset_offset()
> since this function is invoked by the GRO layers entry points.
>
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> ---
> net/core/dev.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/net/core/dev.c b/net/core/dev.c
> index 4870c3556a5a..20bc82604b75 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -4115,6 +4115,8 @@ static void skb_gro_reset_offset(struct sk_buff *skb)
> const struct skb_shared_info *pinfo = skb_shinfo(skb);
> const skb_frag_t *frag0 = &pinfo->frags[0];
>
> + BUILD_BUG_ON(sizeof(skb->cb) < sizeof(struct napi_gro_cb));
> +
Maybe sizeof(struct napi_gro_cb) > sizeof(skb->cb) since this about
napi_gro_cb being too big, not cb being too small.
> NAPI_GRO_CB(skb)->data_offset = 0;
> NAPI_GRO_CB(skb)->frag0 = NULL;
> NAPI_GRO_CB(skb)->frag0_len = 0;
> --
> 2.1.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH RFC net-next] net: Assert napi_gro_cb size against skb->cb[]
2015-07-31 18:51 [PATCH RFC net-next] net: Assert napi_gro_cb size against skb->cb[] Florian Fainelli
2015-07-31 20:14 ` Tom Herbert
@ 2015-07-31 20:24 ` Florian Westphal
2015-07-31 20:44 ` David Miller
1 sibling, 1 reply; 5+ messages in thread
From: Florian Westphal @ 2015-07-31 20:24 UTC (permalink / raw)
To: Florian Fainelli; +Cc: netdev, herbert, daniel, edumazet, davem
Florian Fainelli <f.fainelli@gmail.com> wrote:
> On 64-bits hosts, napi_gro_cb is 48 bytes, which is exactly the size of
> skb->cb[], while on 32-bits hosts it is 36 bytes, but if it were to
> grow, we would not be catching a size inflation as we should.
> ---
> net/core/dev.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/net/core/dev.c b/net/core/dev.c
> index 4870c3556a5a..20bc82604b75 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -4115,6 +4115,8 @@ static void skb_gro_reset_offset(struct sk_buff *skb)
> const struct skb_shared_info *pinfo = skb_shinfo(skb);
> const skb_frag_t *frag0 = &pinfo->frags[0];
>
> + BUILD_BUG_ON(sizeof(skb->cb) < sizeof(struct napi_gro_cb));
commit c3c7c254b2e8cd99b0adf288c2a1bddacd7ba255
already added a check for this.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH RFC net-next] net: Assert napi_gro_cb size against skb->cb[]
2015-07-31 20:24 ` Florian Westphal
@ 2015-07-31 20:44 ` David Miller
2015-07-31 21:50 ` Florian Fainelli
0 siblings, 1 reply; 5+ messages in thread
From: David Miller @ 2015-07-31 20:44 UTC (permalink / raw)
To: fw; +Cc: f.fainelli, netdev, herbert, daniel, edumazet
From: Florian Westphal <fw@strlen.de>
Date: Fri, 31 Jul 2015 22:24:03 +0200
> Florian Fainelli <f.fainelli@gmail.com> wrote:
>> On 64-bits hosts, napi_gro_cb is 48 bytes, which is exactly the size of
>> skb->cb[], while on 32-bits hosts it is 36 bytes, but if it were to
>> grow, we would not be catching a size inflation as we should.
>> ---
>> net/core/dev.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/net/core/dev.c b/net/core/dev.c
>> index 4870c3556a5a..20bc82604b75 100644
>> --- a/net/core/dev.c
>> +++ b/net/core/dev.c
>> @@ -4115,6 +4115,8 @@ static void skb_gro_reset_offset(struct sk_buff *skb)
>> const struct skb_shared_info *pinfo = skb_shinfo(skb);
>> const skb_frag_t *frag0 = &pinfo->frags[0];
>>
>> + BUILD_BUG_ON(sizeof(skb->cb) < sizeof(struct napi_gro_cb));
>
> commit c3c7c254b2e8cd99b0adf288c2a1bddacd7ba255
> already added a check for this.
Indeed.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH RFC net-next] net: Assert napi_gro_cb size against skb->cb[]
2015-07-31 20:44 ` David Miller
@ 2015-07-31 21:50 ` Florian Fainelli
0 siblings, 0 replies; 5+ messages in thread
From: Florian Fainelli @ 2015-07-31 21:50 UTC (permalink / raw)
To: David Miller, fw; +Cc: netdev, herbert, daniel, edumazet
On 31/07/15 13:44, David Miller wrote:
> From: Florian Westphal <fw@strlen.de>
> Date: Fri, 31 Jul 2015 22:24:03 +0200
>
>> Florian Fainelli <f.fainelli@gmail.com> wrote:
>>> On 64-bits hosts, napi_gro_cb is 48 bytes, which is exactly the size of
>>> skb->cb[], while on 32-bits hosts it is 36 bytes, but if it were to
>>> grow, we would not be catching a size inflation as we should.
>>> ---
>>> net/core/dev.c | 2 ++
>>> 1 file changed, 2 insertions(+)
>>>
>>> diff --git a/net/core/dev.c b/net/core/dev.c
>>> index 4870c3556a5a..20bc82604b75 100644
>>> --- a/net/core/dev.c
>>> +++ b/net/core/dev.c
>>> @@ -4115,6 +4115,8 @@ static void skb_gro_reset_offset(struct sk_buff *skb)
>>> const struct skb_shared_info *pinfo = skb_shinfo(skb);
>>> const skb_frag_t *frag0 = &pinfo->frags[0];
>>>
>>> + BUILD_BUG_ON(sizeof(skb->cb) < sizeof(struct napi_gro_cb));
>>
>> commit c3c7c254b2e8cd99b0adf288c2a1bddacd7ba255
>> already added a check for this.
>
> Indeed.
Whoops, missed that part, thanks Florian!
--
Florian
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-07-31 21:52 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-31 18:51 [PATCH RFC net-next] net: Assert napi_gro_cb size against skb->cb[] Florian Fainelli
2015-07-31 20:14 ` Tom Herbert
2015-07-31 20:24 ` Florian Westphal
2015-07-31 20:44 ` David Miller
2015-07-31 21:50 ` Florian Fainelli
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).