diff mbox

kernel panic with time-stamping in phy devices (monitor mode)

Message ID 1291551879.2806.253.camel@edumazet-laptop
State Superseded, archived
Delegated to: David Miller
Headers show

Commit Message

Eric Dumazet Dec. 5, 2010, 12:24 p.m. UTC
Le samedi 04 décembre 2010 à 12:46 -0800, Andrew Watts a écrit :

> Eric, I echo the thanks on the lightning patch.
> Impressive turnaround!
> 
> There's an open bug report on the kernel's bugzilla
> for 2.6.36 (#24102). What is the best way to tie these
> together?

Thanks Andy, here is the official patch submission I am going to make.

[PATCH net-2.6] net: fix skb_defer_rx_timestamp()

After commit c1f19b51d1d8 (net: support time stamping in phy devices.),
kernel might crash if CONFIG_NETWORK_PHY_TIMESTAMPING=y and
skb_defer_rx_timestamp() handles a packet without an ethernet header.

Fixes kernel bugzilla #24102

Reference: https://bugzilla.kernel.org/show_bug.cgi?id=24102
Reported-and-tested-by: Andrew Watts <akwatts@ymail.com>
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Richard Cochran <richardcochran@gmail.com>
Cc: stable@kernel.org
---
 net/core/timestamping.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)



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

Comments

Changli Gao Dec. 6, 2010, 12:01 a.m. UTC | #1
On Sun, Dec 5, 2010 at 8:24 PM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
> Le samedi 04 décembre 2010 à 12:46 -0800, Andrew Watts a écrit :
>
>> Eric, I echo the thanks on the lightning patch.
>> Impressive turnaround!
>>
>> There's an open bug report on the kernel's bugzilla
>> for 2.6.36 (#24102). What is the best way to tie these
>> together?
>
> Thanks Andy, here is the official patch submission I am going to make.
>
> [PATCH net-2.6] net: fix skb_defer_rx_timestamp()
>
> After commit c1f19b51d1d8 (net: support time stamping in phy devices.),
> kernel might crash if CONFIG_NETWORK_PHY_TIMESTAMPING=y and
> skb_defer_rx_timestamp() handles a packet without an ethernet header.
>
> Fixes kernel bugzilla #24102
>
> Reference: https://bugzilla.kernel.org/show_bug.cgi?id=24102
> Reported-and-tested-by: Andrew Watts <akwatts@ymail.com>
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
> Cc: Richard Cochran <richardcochran@gmail.com>
> Cc: stable@kernel.org
> ---
>  net/core/timestamping.c |    6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/net/core/timestamping.c b/net/core/timestamping.c
> index 0ae6c22..c4fbf85 100644
> --- a/net/core/timestamping.c
> +++ b/net/core/timestamping.c
> @@ -96,11 +96,13 @@ bool skb_defer_rx_timestamp(struct sk_buff *skb)
>        struct phy_device *phydev;
>        unsigned int type;
>
> -       skb_push(skb, ETH_HLEN);
> +       if (skb->data - ETH_HLEN < skb->head)
> +               return false;

How about using skb_headroom(skb) < ETH_HLEN ?

And I checked the code of skb_push(). If the headroom of a skb is less
than the requested, Linux will panic with a message titled
"skb_under_panic()". But I can't find this info in the Oops. Maybe the
Oops isn't complete.
diff mbox

Patch

diff --git a/net/core/timestamping.c b/net/core/timestamping.c
index 0ae6c22..c4fbf85 100644
--- a/net/core/timestamping.c
+++ b/net/core/timestamping.c
@@ -96,11 +96,13 @@  bool skb_defer_rx_timestamp(struct sk_buff *skb)
 	struct phy_device *phydev;
 	unsigned int type;
 
-	skb_push(skb, ETH_HLEN);
+	if (skb->data - ETH_HLEN < skb->head)
+		return false;
+	__skb_push(skb, ETH_HLEN);
 
 	type = classify(skb);
 
-	skb_pull(skb, ETH_HLEN);
+	__skb_pull(skb, ETH_HLEN);
 
 	switch (type) {
 	case PTP_CLASS_V1_IPV4: