linux-stable/arch/arm64/lib
Will Deacon ba0b46166b arm64: csum: Fix OoB access in IP checksum code for negative lengths
commit 8bd795fedb upstream.

Although commit c2c24edb1d ("arm64: csum: Fix pathological zero-length
calls") added an early return for zero-length input, syzkaller has
popped up with an example of a _negative_ length which causes an
undefined shift and an out-of-bounds read:

 | BUG: KASAN: slab-out-of-bounds in do_csum+0x44/0x254 arch/arm64/lib/csum.c:39
 | Read of size 4294966928 at addr ffff0000d7ac0170 by task syz-executor412/5975
 |
 | CPU: 0 PID: 5975 Comm: syz-executor412 Not tainted 6.4.0-rc4-syzkaller-g908f31f2a05b #0
 | Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/25/2023
 | Call trace:
 |  dump_backtrace+0x1b8/0x1e4 arch/arm64/kernel/stacktrace.c:233
 |  show_stack+0x2c/0x44 arch/arm64/kernel/stacktrace.c:240
 |  __dump_stack lib/dump_stack.c:88 [inline]
 |  dump_stack_lvl+0xd0/0x124 lib/dump_stack.c:106
 |  print_address_description mm/kasan/report.c:351 [inline]
 |  print_report+0x174/0x514 mm/kasan/report.c:462
 |  kasan_report+0xd4/0x130 mm/kasan/report.c:572
 |  kasan_check_range+0x264/0x2a4 mm/kasan/generic.c:187
 |  __kasan_check_read+0x20/0x30 mm/kasan/shadow.c:31
 |  do_csum+0x44/0x254 arch/arm64/lib/csum.c:39
 |  csum_partial+0x30/0x58 lib/checksum.c:128
 |  gso_make_checksum include/linux/skbuff.h:4928 [inline]
 |  __udp_gso_segment+0xaf4/0x1bc4 net/ipv4/udp_offload.c:332
 |  udp6_ufo_fragment+0x540/0xca0 net/ipv6/udp_offload.c:47
 |  ipv6_gso_segment+0x5cc/0x1760 net/ipv6/ip6_offload.c:119
 |  skb_mac_gso_segment+0x2b4/0x5b0 net/core/gro.c:141
 |  __skb_gso_segment+0x250/0x3d0 net/core/dev.c:3401
 |  skb_gso_segment include/linux/netdevice.h:4859 [inline]
 |  validate_xmit_skb+0x364/0xdbc net/core/dev.c:3659
 |  validate_xmit_skb_list+0x94/0x130 net/core/dev.c:3709
 |  sch_direct_xmit+0xe8/0x548 net/sched/sch_generic.c:327
 |  __dev_xmit_skb net/core/dev.c:3805 [inline]
 |  __dev_queue_xmit+0x147c/0x3318 net/core/dev.c:4210
 |  dev_queue_xmit include/linux/netdevice.h:3085 [inline]
 |  packet_xmit+0x6c/0x318 net/packet/af_packet.c:276
 |  packet_snd net/packet/af_packet.c:3081 [inline]
 |  packet_sendmsg+0x376c/0x4c98 net/packet/af_packet.c:3113
 |  sock_sendmsg_nosec net/socket.c:724 [inline]
 |  sock_sendmsg net/socket.c:747 [inline]
 |  __sys_sendto+0x3b4/0x538 net/socket.c:2144

Extend the early return to reject negative lengths as well, aligning our
implementation with the generic code in lib/checksum.c

Cc: Robin Murphy <robin.murphy@arm.com>
Fixes: 5777eaed56 ("arm64: Implement optimised checksum routine")
Reported-by: syzbot+4a9f9820bd8d302e22f7@syzkaller.appspotmail.com
Link: https://lore.kernel.org/r/000000000000e0e94c0603f8d213@google.com
Signed-off-by: Will Deacon <will@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-09-13 09:43:01 +02:00
..
clear_page.S arm64: clean up symbol aliasing 2022-02-22 16:21:34 +00:00
clear_user.S arm64: extable: consolidate definitions 2021-10-21 10:45:22 +01:00
copy_from_user.S arm64: lib: __arch_copy_from_user(): fold fixups into body 2021-10-21 10:45:21 +01:00
copy_page.S arm64: clean up symbol aliasing 2022-02-22 16:21:34 +00:00
copy_template.S
copy_to_user.S arm64: lib: __arch_copy_to_user(): fold fixups into body 2021-10-21 10:45:21 +01:00
crc32.S arm64: lib: accelerate crc32_be 2022-01-31 11:21:43 +11:00
csum.c arm64: csum: Fix OoB access in IP checksum code for negative lengths 2023-09-13 09:43:01 +02:00
delay.c arm64: Use WFxT for __delay() when possible 2022-04-20 13:24:44 +01:00
error-inject.c
insn.c arm64: Add LDR (literal) instruction 2022-07-11 21:04:58 +02:00
kasan_sw_tags.S arm64: Use BTI C directly and unconditionally 2021-12-14 18:12:58 +00:00
Makefile isystem: delete global -isystem compile option 2021-09-22 09:26:24 +09:00
memchr.S arm64: clean up symbol aliasing 2022-02-22 16:21:34 +00:00
memcmp.S arm64: clean up symbol aliasing 2022-02-22 16:21:34 +00:00
memcpy.S arm64: clean up symbol aliasing 2022-02-22 16:21:34 +00:00
memset.S arm64: clean up symbol aliasing 2022-02-22 16:21:34 +00:00
mte.S arm64/mte: Standardise GMID field name definitions 2022-07-05 11:45:46 +01:00
strchr.S arm64: clean up symbol aliasing 2022-02-22 16:21:34 +00:00
strcmp.S Merge branch 'for-next/strings' into for-next/core 2022-03-14 19:02:52 +00:00
strlen.S arm64: clean up symbol aliasing 2022-02-22 16:21:34 +00:00
strncmp.S Merge branch 'for-next/strings' into for-next/core 2022-03-14 19:02:52 +00:00
strnlen.S arm64: clean up symbol aliasing 2022-02-22 16:21:34 +00:00
strrchr.S arm64: clean up symbol aliasing 2022-02-22 16:21:34 +00:00
tishift.S arm64: lib: Use modern annotations for assembly functions 2020-01-08 12:23:02 +00:00
uaccess_flushcache.c arm64: Rename arm64-internal cache maintenance functions 2021-05-25 19:27:49 +01:00
xor-neon.c lib/xor: make xor prototypes more friendly to compiler vectorization 2022-02-11 20:39:39 +11:00