netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Florian Westphal <fw@strlen.de>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH net] net: skbuff: add overflow debug check to pull/push helpers
Date: Mon, 19 Feb 2024 15:16:38 +0000	[thread overview]
Message-ID: <20240219151638.GD40273@kernel.org> (raw)
In-Reply-To: <20240216113700.23013-1-fw@strlen.de>

On Fri, Feb 16, 2024 at 12:36:57PM +0100, Florian Westphal wrote:
> syzbot managed to trigger following splat:
> BUG: KASAN: use-after-free in __skb_flow_dissect+0x4a3b/0x5e50
> Read of size 1 at addr ffff888208a4000e by task a.out/2313
> [..]
>   __skb_flow_dissect+0x4a3b/0x5e50
>   __skb_get_hash+0xb4/0x400
>   ip_tunnel_xmit+0x77e/0x26f0
>   ipip_tunnel_xmit+0x298/0x410
>   ..
> 
> Analysis shows that the skb has a valid ->head, but bogus ->data
> pointer.
> 
> skb->data gets its bogus value via the neigh layer, which does:
> 
> 1556    __skb_pull(skb, skb_network_offset(skb));
> 
> ... and the skb was already dodgy at this point:
> 
> skb_network_offset(skb) returns a negative value due to an
> earlier overflow of skb->network_header (u16).  __skb_pull thus
> "adjusts" skb->data by a huge offset, pointing outside skb->head
> area.
> 
> Allow debug builds to splat when we try to pull/push more than
> INT_MAX bytes.
> 
> After this, the syzkaller reproducer yields a more precise splat
> before the flow dissector attempts to read off skb->data memory:
> 
> WARNING: CPU: 5 PID: 2313 at include/linux/skbuff.h:2653 neigh_connected_output+0x28e/0x400
>   ip_finish_output2+0xb25/0xed0
>   iptunnel_xmit+0x4ff/0x870
>   ipgre_xmit+0x78e/0xbb0
> 
> Signed-off-by: Florian Westphal <fw@strlen.de>

Reviewed-by: Simon Horman <horms@kernel.org>


  reply	other threads:[~2024-02-19 15:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-16 11:36 [PATCH net] net: skbuff: add overflow debug check to pull/push helpers Florian Westphal
2024-02-19 15:16 ` Simon Horman [this message]
2024-02-20 11:07 ` Paolo Abeni
2024-02-20 11:18   ` Florian Westphal
2024-02-20 11:30 ` patchwork-bot+netdevbpf

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=20240219151638.GD40273@kernel.org \
    --to=horms@kernel.org \
    --cc=fw@strlen.de \
    --cc=netdev@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).