* [PATCH] NET: Fix skb_truesize_check() assertion
@ 2007-11-08 16:59 Chuck Lever
2007-11-11 5:53 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Chuck Lever @ 2007-11-08 16:59 UTC (permalink / raw)
To: netdev
The intent of the assertion in skb_truesize_check() is to check
for skb->truesize being decremented too much by other code,
resulting in a wraparound below zero.
The type of the right side of the comparison causes the compiler to
promote the left side to an unsigned type, despite the presence of an
explicit type cast. This defeats the check for negativity.
Ensure both sides of the comparison are a signed type to prevent the
implicit type conversion.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
include/linux/skbuff.h | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 94e4991..91140fe 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -387,7 +387,9 @@ extern void skb_truesize_bug(struct sk_buff *skb);
static inline void skb_truesize_check(struct sk_buff *skb)
{
- if (unlikely((int)skb->truesize < sizeof(struct sk_buff) + skb->len))
+ int len = sizeof(struct sk_buff) + skb->len;
+
+ if (unlikely((int)skb->truesize < len))
skb_truesize_bug(skb);
}
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] NET: Fix skb_truesize_check() assertion
2007-11-08 16:59 [PATCH] NET: Fix skb_truesize_check() assertion Chuck Lever
@ 2007-11-11 5:53 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2007-11-11 5:53 UTC (permalink / raw)
To: chuck.lever; +Cc: netdev
From: Chuck Lever <chuck.lever@oracle.com>
Date: Thu, 08 Nov 2007 11:59:19 -0500
> The intent of the assertion in skb_truesize_check() is to check
> for skb->truesize being decremented too much by other code,
> resulting in a wraparound below zero.
>
> The type of the right side of the comparison causes the compiler to
> promote the left side to an unsigned type, despite the presence of an
> explicit type cast. This defeats the check for negativity.
>
> Ensure both sides of the comparison are a signed type to prevent the
> implicit type conversion.
>
> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Applied, thanks Chuck.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-11-11 5:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-08 16:59 [PATCH] NET: Fix skb_truesize_check() assertion Chuck Lever
2007-11-11 5:53 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox