From: Eric Dumazet <eric.dumazet@gmail.com>
To: "Niccolò Belli" <darkbasic@linuxsystems.it>,
"David Miller" <davem@davemloft.net>
Cc: Linux Networking Developer Mailing List <netdev@vger.kernel.org>,
openadsl-users@lists.sourceforge.net,
openadsl-devel@lists.sourceforge.net, 660804@bugs.debian.org,
support@traverse.com.au, support@rocksolidelectronics.com
Subject: Re: [Bug 42809] New: kernel panic when receiving an ipsec packet
Date: Thu, 23 Feb 2012 15:36:26 +0100 [thread overview]
Message-ID: <1330007786.15610.26.camel@edumazet-laptop> (raw)
In-Reply-To: <4F46430D.3060802@linuxsystems.it>
> Your patch does solve the problem, thanks!
>
Thanks for testing.
Here is the official patch I submit for review then.
[PATCH] ipsec: be careful of non existing mac headers
Nicollo Belli reported ipsec crashes in case we handle a frame without
mac header (atm in his case)
Before copying mac header, better make sure it is present.
Bugzilla reference: https://bugzilla.kernel.org/show_bug.cgi?id=42809
Reported-by: Niccolò Belli <darkbasic@linuxsystems.it>
Tested-by: Niccolò Belli <darkbasic@linuxsystems.it>
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
---
net/ipv4/xfrm4_mode_beet.c | 9 +++++----
net/ipv4/xfrm4_mode_tunnel.c | 10 ++++++----
net/ipv6/xfrm6_mode_beet.c | 9 +++++----
net/ipv6/xfrm6_mode_tunnel.c | 10 ++++++----
4 files changed, 22 insertions(+), 16 deletions(-)
diff --git a/net/ipv4/xfrm4_mode_beet.c b/net/ipv4/xfrm4_mode_beet.c
index 6341818..d3451f6 100644
--- a/net/ipv4/xfrm4_mode_beet.c
+++ b/net/ipv4/xfrm4_mode_beet.c
@@ -111,10 +111,11 @@ static int xfrm4_beet_input(struct xfrm_state *x, struct sk_buff *skb)
skb_push(skb, sizeof(*iph));
skb_reset_network_header(skb);
- memmove(skb->data - skb->mac_len, skb_mac_header(skb),
- skb->mac_len);
- skb_set_mac_header(skb, -skb->mac_len);
-
+ if (skb_mac_header_was_set(skb)) {
+ memmove(skb->data - skb->mac_len, skb_mac_header(skb),
+ skb->mac_len);
+ skb_set_mac_header(skb, -skb->mac_len);
+ }
xfrm4_beet_make_header(skb);
iph = ip_hdr(skb);
diff --git a/net/ipv4/xfrm4_mode_tunnel.c b/net/ipv4/xfrm4_mode_tunnel.c
index 534972e..a646f30 100644
--- a/net/ipv4/xfrm4_mode_tunnel.c
+++ b/net/ipv4/xfrm4_mode_tunnel.c
@@ -66,7 +66,6 @@ static int xfrm4_mode_tunnel_output(struct xfrm_state *x, struct sk_buff *skb)
static int xfrm4_mode_tunnel_input(struct xfrm_state *x, struct sk_buff *skb)
{
- const unsigned char *old_mac;
int err = -EINVAL;
if (XFRM_MODE_SKB_CB(skb)->protocol != IPPROTO_IPIP)
@@ -84,9 +83,12 @@ static int xfrm4_mode_tunnel_input(struct xfrm_state *x, struct sk_buff *skb)
if (!(x->props.flags & XFRM_STATE_NOECN))
ipip_ecn_decapsulate(skb);
- old_mac = skb_mac_header(skb);
- skb_set_mac_header(skb, -skb->mac_len);
- memmove(skb_mac_header(skb), old_mac, skb->mac_len);
+ if (skb_mac_header_was_set(skb)) {
+ const unsigned char *old_mac = skb_mac_header(skb);
+
+ skb_set_mac_header(skb, -skb->mac_len);
+ memmove(skb_mac_header(skb), old_mac, skb->mac_len);
+ }
skb_reset_network_header(skb);
err = 0;
diff --git a/net/ipv6/xfrm6_mode_beet.c b/net/ipv6/xfrm6_mode_beet.c
index a81ce94..74c4b92 100644
--- a/net/ipv6/xfrm6_mode_beet.c
+++ b/net/ipv6/xfrm6_mode_beet.c
@@ -80,7 +80,6 @@ static int xfrm6_beet_output(struct xfrm_state *x, struct sk_buff *skb)
static int xfrm6_beet_input(struct xfrm_state *x, struct sk_buff *skb)
{
struct ipv6hdr *ip6h;
- const unsigned char *old_mac;
int size = sizeof(struct ipv6hdr);
int err;
@@ -91,10 +90,12 @@ static int xfrm6_beet_input(struct xfrm_state *x, struct sk_buff *skb)
__skb_push(skb, size);
skb_reset_network_header(skb);
- old_mac = skb_mac_header(skb);
- skb_set_mac_header(skb, -skb->mac_len);
- memmove(skb_mac_header(skb), old_mac, skb->mac_len);
+ if (skb_mac_header_was_set(skb)) {
+ const unsigned char *old_mac = skb_mac_header(skb);
+ skb_set_mac_header(skb, -skb->mac_len);
+ memmove(skb_mac_header(skb), old_mac, skb->mac_len);
+ }
xfrm6_beet_make_header(skb);
ip6h = ipv6_hdr(skb);
diff --git a/net/ipv6/xfrm6_mode_tunnel.c b/net/ipv6/xfrm6_mode_tunnel.c
index 261e6e6..edb7091 100644
--- a/net/ipv6/xfrm6_mode_tunnel.c
+++ b/net/ipv6/xfrm6_mode_tunnel.c
@@ -63,7 +63,6 @@ static int xfrm6_mode_tunnel_output(struct xfrm_state *x, struct sk_buff *skb)
static int xfrm6_mode_tunnel_input(struct xfrm_state *x, struct sk_buff *skb)
{
int err = -EINVAL;
- const unsigned char *old_mac;
if (XFRM_MODE_SKB_CB(skb)->protocol != IPPROTO_IPV6)
goto out;
@@ -80,9 +79,12 @@ static int xfrm6_mode_tunnel_input(struct xfrm_state *x, struct sk_buff *skb)
if (!(x->props.flags & XFRM_STATE_NOECN))
ipip6_ecn_decapsulate(skb);
- old_mac = skb_mac_header(skb);
- skb_set_mac_header(skb, -skb->mac_len);
- memmove(skb_mac_header(skb), old_mac, skb->mac_len);
+ if (skb_mac_header_was_set(skb)) {
+ const unsigned char *old_mac = skb_mac_header(skb);
+
+ skb_set_mac_header(skb, -skb->mac_len);
+ memmove(skb_mac_header(skb), old_mac, skb->mac_len);
+ }
skb_reset_network_header(skb);
err = 0;
next prev parent reply other threads:[~2012-02-23 14:36 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <bug-42809-100@https.bugzilla.kernel.org/>
2012-02-22 17:20 ` [Bug 42809] New: kernel panic when receiving an ipsec packet Stephen Hemminger
2012-02-22 17:41 ` Niccolò Belli
2012-02-23 0:59 ` Niccolò Belli
2012-02-23 1:38 ` Eric Dumazet
2012-02-23 1:46 ` [openadsl-users] " Jason White
2012-02-23 1:54 ` Eric Dumazet
2012-02-23 13:48 ` Bug#660804: " chas williams - CONTRACTOR
2012-02-23 1:55 ` Niccolò Belli
2012-02-23 2:02 ` Niccolò Belli
2012-02-23 2:06 ` Eric Dumazet
2012-02-23 2:12 ` Niccolò Belli
2012-02-23 13:45 ` Niccolò Belli
2012-02-23 14:36 ` Eric Dumazet [this message]
2012-02-23 14:39 ` Eric Dumazet
2012-02-23 19:08 ` Niccolò Belli
2012-02-23 20:11 ` David Miller
2012-02-23 20:17 ` Eric Dumazet
2012-02-23 20:23 ` David Miller
2012-02-23 20:28 ` Eric Dumazet
2012-02-23 20:55 ` [PATCH V2] ipsec: be careful of non existing mac headers Eric Dumazet
2012-02-23 21:53 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1330007786.15610.26.camel@edumazet-laptop \
--to=eric.dumazet@gmail.com \
--cc=660804@bugs.debian.org \
--cc=darkbasic@linuxsystems.it \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=openadsl-devel@lists.sourceforge.net \
--cc=openadsl-users@lists.sourceforge.net \
--cc=support@rocksolidelectronics.com \
--cc=support@traverse.com.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox