lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANn89iKjdynvAddoWrQ-Akm=fQeHD9Ww=rAwfGCmYMDSRk6iJw@mail.gmail.com>
Date: Mon, 18 Mar 2024 20:46:44 +0100
From: Eric Dumazet <edumazet@...gle.com>
To: Chenyuan Yang <chenyuan0y@...il.com>
Cc: jhs@...atatu.com, xiyou.wangcong@...il.com, jiri@...nulli.us, 
	davem@...emloft.net, kuba@...nel.org, pabeni@...hat.com, 
	netdev@...r.kernel.org, zzjas98@...il.com
Subject: Re: [net/sched] Question about possible misuse checksum in tcf_csum_ipv6_icmp()

On Mon, Mar 18, 2024 at 8:31 PM Chenyuan Yang <chenyuan0y@...il.com> wrote:
>
> Dear TC subsystem maintainers,
>
> We are curious whether the function `tcf_csum_ipv6_icmp()` would have a misuse of `csum_partial()` leading to an out-of-bounds access.
>
> The function `tcf_csum_ipv6_icmp` is https://elixir.bootlin.com/linux/v6.8/source/net/sched/act_csum.c#L183 and the relevant code is
> ```
> static int tcf_csum_ipv6_icmp(struct sk_buff *skb, unsigned int ihl,
>                               unsigned int ipl)
> {
>   ...
>         ip6h = ipv6_hdr(skb);
>         icmp6h->icmp6_cksum = 0;
>         skb->csum = csum_partial(icmp6h, ipl - ihl, 0);
>         icmp6h->icmp6_cksum = csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr,
>                                               ipl - ihl, IPPROTO_ICMPV6,
>                                               skb->csum);
>   ...
> }
> ```
>
> Based on this patch: https://lore.kernel.org/netdev/20240201083817.12774-1-atenart@kernel.org/T/, it seems that the `skb` here for ICMPv6 could be non-linear, and `csum_partial` is not suitable for non-linear SKBs, which could lead to an out-of-bound access. The correct approach is to use `skb_checksum` which properly handles non-linear SKBs.
>
> Based on the above information, a possible fix would be
> ```
> -       skb->csum = csum_partial(icmp6h, ipl - ihl, 0);
> +       skb->csum = skb_checksum(skb, skb_transport_offset(skb), ipl - ihl, 0);
> ```

Why would this code be an issue only in  tcf_csum_ipv6_icmp(), and not
in other functions ?

It seems we have proper pskb_may_pull() calls.

If you have a syzbot/syzkaller trace, please share it.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ