* [PATCH] ipv4: ip_check_defrag should correctly check return value of skb_copy_bits
@ 2015-02-17 10:33 Alexander Drozdov
2015-02-17 13:33 ` Denis Kirjanov
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Alexander Drozdov @ 2015-02-17 10:33 UTC (permalink / raw)
To: David S. Miller, Alexey Kuznetsov, James Morris,
Hideaki YOSHIFUJI, Patrick McHardy
Cc: netdev, linux-kernel, Alexander Drozdov
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 <al.drozdov@gmail.com>
---
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] ipv4: ip_check_defrag should correctly check return value of skb_copy_bits
2015-02-17 10:33 [PATCH] ipv4: ip_check_defrag should correctly check return value of skb_copy_bits Alexander Drozdov
@ 2015-02-17 13:33 ` Denis Kirjanov
2015-02-17 15:55 ` Eric Dumazet
2015-02-20 20:23 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Denis Kirjanov @ 2015-02-17 13:33 UTC (permalink / raw)
To: Alexander Drozdov
Cc: David S. Miller, Alexey Kuznetsov, James Morris,
Hideaki YOSHIFUJI, Patrick McHardy, netdev, linux-kernel
On 2/17/15, Alexander Drozdov <al.drozdov@gmail.com> 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
> Fixes: 1bf3751ec90c ("ipv4: ip_check_defrag must not modify skb before
> unsharing")
> Signed-off-by: Alexander Drozdov <al.drozdov@gmail.com>
> ---
> 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
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ipv4: ip_check_defrag should correctly check return value of skb_copy_bits
2015-02-17 10:33 [PATCH] ipv4: ip_check_defrag should correctly check return value of skb_copy_bits Alexander Drozdov
2015-02-17 13:33 ` Denis Kirjanov
@ 2015-02-17 15:55 ` Eric Dumazet
2015-02-20 20:23 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Eric Dumazet @ 2015-02-17 15:55 UTC (permalink / raw)
To: Alexander Drozdov, Johannes Berg
Cc: David S. Miller, Alexey Kuznetsov, James Morris,
Hideaki YOSHIFUJI, Patrick McHardy, netdev, linux-kernel
On Tue, 2015-02-17 at 13:33 +0300, Alexander Drozdov 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().
>
> Fixes: 1bf3751ec90c ("ipv4: ip_check_defrag must not modify skb before unsharing")
> Signed-off-by: Alexander Drozdov <al.drozdov@gmail.com>
> ---
> 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 <edumazet@google.com>
Cc: Johannes Berg <johannes.berg@intel.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ipv4: ip_check_defrag should correctly check return value of skb_copy_bits
2015-02-17 10:33 [PATCH] ipv4: ip_check_defrag should correctly check return value of skb_copy_bits Alexander Drozdov
2015-02-17 13:33 ` Denis Kirjanov
2015-02-17 15:55 ` Eric Dumazet
@ 2015-02-20 20:23 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2015-02-20 20:23 UTC (permalink / raw)
To: al.drozdov; +Cc: kuznet, jmorris, yoshfuji, kaber, netdev, linux-kernel
From: Alexander Drozdov <al.drozdov@gmail.com>
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 <al.drozdov@gmail.com>
Applied and queued up for -stable, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-02-20 20:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-17 10:33 [PATCH] ipv4: ip_check_defrag should correctly check return value of skb_copy_bits Alexander Drozdov
2015-02-17 13:33 ` Denis Kirjanov
2015-02-17 15:55 ` Eric Dumazet
2015-02-20 20:23 ` David Miller
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).