[PATCH] ipv4: ip_check_defrag should correctly check return value of skb_copy_bits

Subsystems: networking [general], networking [ipv4/ipv6], the rest

STALE4262d

4 messages, 4 authors, 2015-02-20 · open the first message on its own page

[PATCH] ipv4: ip_check_defrag should correctly check return value of skb_copy_bits

From: Alexander Drozdov <hidden>
Date: 2015-02-17 10:34:15

skb_copy_bits() returns zero on success and negative value on error,
so it is needed to invert the condition in ip_check_defrag().

Fixes: 1bf3751ec90c ("ipv4: ip_check_defrag must not modify skb before unsharing")
Signed-off-by: Alexander Drozdov <redacted>
---
 net/ipv4/ip_fragment.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
index e5b6d0d..2c8d98e 100644
--- a/net/ipv4/ip_fragment.c
+++ b/net/ipv4/ip_fragment.c
@@ -664,7 +664,7 @@ struct sk_buff *ip_check_defrag(struct sk_buff *skb, u32 user)
 	if (skb->protocol != htons(ETH_P_IP))
 		return skb;
 
-	if (!skb_copy_bits(skb, 0, &iph, sizeof(iph)))
+	if (skb_copy_bits(skb, 0, &iph, sizeof(iph)) < 0)
 		return skb;
 
 	if (iph.ihl < 5 || iph.version != 4)
-- 
1.9.1

Re: [PATCH] ipv4: ip_check_defrag should correctly check return value of skb_copy_bits

From: Denis Kirjanov <hidden>
Date: 2015-02-17 13:33:49

On 2/17/15, Alexander Drozdov [off-list ref] wrote:
skb_copy_bits() returns zero on success and negative value on error,
so it is needed to invert the condition in ip_check_defrag().
Nice. Grepping through the net directory shows that the  skb_copy_bits()
return value is completely ignored in net/wireless/util.c

quoted hunk
Fixes: 1bf3751ec90c ("ipv4: ip_check_defrag must not modify skb before
unsharing")
Signed-off-by: Alexander Drozdov <redacted>
---
 net/ipv4/ip_fragment.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
index e5b6d0d..2c8d98e 100644
--- a/net/ipv4/ip_fragment.c
+++ b/net/ipv4/ip_fragment.c
@@ -664,7 +664,7 @@ struct sk_buff *ip_check_defrag(struct sk_buff *skb, u32
user)
 	if (skb->protocol != htons(ETH_P_IP))
 		return skb;

-	if (!skb_copy_bits(skb, 0, &iph, sizeof(iph)))
+	if (skb_copy_bits(skb, 0, &iph, sizeof(iph)) < 0)
 		return skb;

 	if (iph.ihl < 5 || iph.version != 4)
--
1.9.1

--
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

Re: [PATCH] ipv4: ip_check_defrag should correctly check return value of skb_copy_bits

From: Eric Dumazet <hidden>
Date: 2015-02-17 15:55:35

On Tue, 2015-02-17 at 13:33 +0300, Alexander Drozdov wrote:
quoted hunk
skb_copy_bits() returns zero on success and negative value on error,
so it is needed to invert the condition in ip_check_defrag().

Fixes: 1bf3751ec90c ("ipv4: ip_check_defrag must not modify skb before unsharing")
Signed-off-by: Alexander Drozdov <redacted>
---
 net/ipv4/ip_fragment.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
index e5b6d0d..2c8d98e 100644
--- a/net/ipv4/ip_fragment.c
+++ b/net/ipv4/ip_fragment.c
@@ -664,7 +664,7 @@ struct sk_buff *ip_check_defrag(struct sk_buff *skb, u32 user)
 	if (skb->protocol != htons(ETH_P_IP))
 		return skb;
 
-	if (!skb_copy_bits(skb, 0, &iph, sizeof(iph)))
+	if (skb_copy_bits(skb, 0, &iph, sizeof(iph)) < 0)
 		return skb;
 
 	if (iph.ihl < 5 || iph.version != 4)
Thanks, I wonder how this was not found/fixed earlier.

Acked-by: Eric Dumazet <redacted>
Cc: Johannes Berg <redacted>

Re: [PATCH] ipv4: ip_check_defrag should correctly check return value of skb_copy_bits

From: David Miller <davem@davemloft.net>
Date: 2015-02-20 20:23:21

From: Alexander Drozdov <redacted>
Date: Tue, 17 Feb 2015 13:33:46 +0300
skb_copy_bits() returns zero on success and negative value on error,
so it is needed to invert the condition in ip_check_defrag().

Fixes: 1bf3751ec90c ("ipv4: ip_check_defrag must not modify skb before unsharing")
Signed-off-by: Alexander Drozdov <redacted>
Applied and queued up for -stable, thanks.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help