From: Johannes Berg <hidden> Date: 2012-12-10 09:29:48
On Fri, 2012-12-07 at 23:23 +0100, Johannes Berg wrote:
Oh I should say ... IP is like black magic to me ;-)
quoted
- if (!pskb_may_pull(skb, sizeof(struct iphdr)))
+ if (!skb_copy_bits(skb, 0, &iph, sizeof(iph)))
return skb;
- iph = ip_hdr(skb);
- if (iph->ihl < 5 || iph->version != 4)
+ if (iph.ihl < 5 || iph.version != 4)
return skb;
- if (!pskb_may_pull(skb, iph->ihl*4))
- return skb;
- iph = ip_hdr(skb);
- len = ntohs(iph->tot_len);
- if (skb->len < len || len < (iph->ihl * 4))
+
+ len = ntohs(iph.tot_len);
+ if (skb->len < len || len < (iph.ihl * 4))
return skb;
- if (ip_is_fragment(ip_hdr(skb))) {
+ if (ip_is_fragment(&iph)) {
skb = skb_share_check(skb, GFP_ATOMIC);
if (skb) {
+ if (!pskb_may_pull(skb, iph.ihl*4))
+ return skb;
I moved this here but I have no idea what it does.
Well, ok, looking further it does seem kinda obvious -- ip_defrag()
assumes the IP header is (fully?) present in the skb header, so that's
what this does.
Eric (Leblond), could you test this patch?
johannes
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
From: Johannes Berg <johannes@sipsolutions.net> Date: 2012-12-10 09:40:45
From: Johannes Berg <redacted>
ip_check_defrag() might be called from af_packet within the
RX path where shared SKBs are used, so it must not modify
the input SKB before it has unshared it for defragmentation.
Use skb_copy_bits() to get the IP header and only pull in
everything later.
The same is true for the other caller in macvlan as it is
called from dev->rx_handler which can also get a shared SKB.
Reported-by: Eric Leblond <redacted>
Cc: stable@vger.kernel.org
Signed-off-by: Johannes Berg <redacted>
---
For some versions of the kernel, this code goes into af_packet.c
net/ipv4/ip_fragment.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
From: Eric Leblond <hidden> Date: 2012-12-10 11:03:42
Hello,
On Mon, 2012-12-10 at 10:41 +0100, Johannes Berg wrote:
From: Johannes Berg <redacted>
ip_check_defrag() might be called from af_packet within the
RX path where shared SKBs are used, so it must not modify
the input SKB before it has unshared it for defragmentation.
Use skb_copy_bits() to get the IP header and only pull in
everything later.
The same is true for the other caller in macvlan as it is
called from dev->rx_handler which can also get a shared SKB.
I've applied the patch and built a new kernel. I did not manage to get
it crashed when using the two techniques (suspend to ram and down/up
interface) that were working well to crash kernel without the patch.
BR,
quoted hunk
Reported-by: Eric Leblond <redacted>
Cc: stable@vger.kernel.org
Signed-off-by: Johannes Berg <redacted>
---
For some versions of the kernel, this code goes into af_packet.c
net/ipv4/ip_fragment.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
From: David Miller <davem@davemloft.net> Date: 2012-12-10 18:41:49
From: Johannes Berg <johannes@sipsolutions.net>
Date: Mon, 10 Dec 2012 10:41:06 +0100
From: Johannes Berg <redacted>
ip_check_defrag() might be called from af_packet within the
RX path where shared SKBs are used, so it must not modify
the input SKB before it has unshared it for defragmentation.
Use skb_copy_bits() to get the IP header and only pull in
everything later.
The same is true for the other caller in macvlan as it is
called from dev->rx_handler which can also get a shared SKB.
Reported-by: Eric Leblond <redacted>
Cc: stable@vger.kernel.org
Signed-off-by: Johannes Berg <redacted>
---
For some versions of the kernel, this code goes into af_packet.c
So the bug is that ip_check_defrag() has a precondition which is met
properly by all callers except AF_PACKET.
If this is the case, remind me why are we changing ip_check_defrag()
rather than the violator of the precondition?
From: Johannes Berg <johannes@sipsolutions.net> Date: 2012-12-10 18:45:32
On Mon, 2012-12-10 at 13:41 -0500, David Miller wrote:
From: Johannes Berg <johannes@sipsolutions.net>
Date: Mon, 10 Dec 2012 10:41:06 +0100
quoted
From: Johannes Berg <redacted>
ip_check_defrag() might be called from af_packet within the
RX path where shared SKBs are used, so it must not modify
the input SKB before it has unshared it for defragmentation.
Use skb_copy_bits() to get the IP header and only pull in
everything later.
The same is true for the other caller in macvlan as it is
called from dev->rx_handler which can also get a shared SKB.
Reported-by: Eric Leblond <redacted>
Cc: stable@vger.kernel.org
Signed-off-by: Johannes Berg <redacted>
---
For some versions of the kernel, this code goes into af_packet.c
So the bug is that ip_check_defrag() has a precondition which is met
properly by all callers except AF_PACKET.
If this is the case, remind me why are we changing ip_check_defrag()
rather than the violator of the precondition?
I don't think this is the case.
If you're referring to my note about af_packet: the kernels where this
goes into af_packet.c are the kernels that don't even have
ip_check_defrag() because macvlan didn't exist/didn't have ip defrag
support and af_packet had this code there -- see commit bc416d9768a.
If you're not referring to my note about af_packet: both callers (there
are only two) of ip_check_defrag() have this bug as far as I can tell
because they're both in the part of the RX path where shared SKBs might
happen.
johannes