* [PATCH] ipv4: ip_check_defrag should not assume that skb_network_offset is zero
@ 2015-03-05 7:29 Alexander Drozdov
2015-03-06 2:44 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Alexander Drozdov @ 2015-03-05 7:29 UTC (permalink / raw)
To: David S. Miller, Alexey Kuznetsov, James Morris,
Hideaki YOSHIFUJI, Patrick McHardy
Cc: netdev, linux-kernel, Alexander Drozdov
ip_check_defrag() may be used by af_packet to defragment outgoing packets.
skb_network_offset() of af_packet's outgoing packets is not zero.
Signed-off-by: Alexander Drozdov <al.drozdov@gmail.com>
---
net/ipv4/ip_fragment.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
index 2c8d98e..145a50c 100644
--- a/net/ipv4/ip_fragment.c
+++ b/net/ipv4/ip_fragment.c
@@ -659,27 +659,30 @@ EXPORT_SYMBOL(ip_defrag);
struct sk_buff *ip_check_defrag(struct sk_buff *skb, u32 user)
{
struct iphdr iph;
+ int netoff;
u32 len;
if (skb->protocol != htons(ETH_P_IP))
return skb;
- if (skb_copy_bits(skb, 0, &iph, sizeof(iph)) < 0)
+ netoff = skb_network_offset(skb);
+
+ if (skb_copy_bits(skb, netoff, &iph, sizeof(iph)) < 0)
return skb;
if (iph.ihl < 5 || iph.version != 4)
return skb;
len = ntohs(iph.tot_len);
- if (skb->len < len || len < (iph.ihl * 4))
+ if (skb->len < netoff + len || len < (iph.ihl * 4))
return skb;
if (ip_is_fragment(&iph)) {
skb = skb_share_check(skb, GFP_ATOMIC);
if (skb) {
- if (!pskb_may_pull(skb, iph.ihl*4))
+ if (!pskb_may_pull(skb, netoff + iph.ihl * 4))
return skb;
- if (pskb_trim_rcsum(skb, len))
+ if (pskb_trim_rcsum(skb, netoff + len))
return skb;
memset(IPCB(skb), 0, sizeof(struct inet_skb_parm));
if (ip_defrag(skb, user))
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ipv4: ip_check_defrag should not assume that skb_network_offset is zero
2015-03-05 7:29 [PATCH] ipv4: ip_check_defrag should not assume that skb_network_offset is zero Alexander Drozdov
@ 2015-03-06 2:44 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2015-03-06 2:44 UTC (permalink / raw)
To: al.drozdov; +Cc: kuznet, jmorris, yoshfuji, kaber, netdev, linux-kernel
From: Alexander Drozdov <al.drozdov@gmail.com>
Date: Thu, 5 Mar 2015 10:29:39 +0300
> ip_check_defrag() may be used by af_packet to defragment outgoing packets.
> skb_network_offset() of af_packet's outgoing packets is not zero.
>
> Signed-off-by: Alexander Drozdov <al.drozdov@gmail.com>
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-03-06 2:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-05 7:29 [PATCH] ipv4: ip_check_defrag should not assume that skb_network_offset is zero Alexander Drozdov
2015-03-06 2:44 ` 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).