linux/net/tipc
Samuel Page 2b66974a1b tipc: fix out-of-bounds read in broadcast Gap ACK blocks
A broadcast PROTOCOL/STATE_MSG can carry a Gap ACK blocks record in its
data area. tipc_get_gap_ack_blks() only verifies that the record's len
field is self-consistent with its ugack_cnt/bgack_cnt counts
(sz == struct_size(p, gacks, ugack_cnt + bgack_cnt)); it does not check
that the record actually fits in the message data area, msg_data_sz().

The unicast caller tipc_link_proto_rcv() bounds it ("if (glen > dlen)
break;"), but the broadcast caller tipc_bcast_sync_rcv() discards the
returned size, so tipc_link_advance_transmq() copies the record off the
receive skb with an attacker-controlled count:

	this_ga = kmemdup(ga, struct_size(ga, gacks, ga->bgack_cnt),
			  GFP_ATOMIC);

A TIPC neighbour that negotiated TIPC_GAP_ACK_BLOCK triggers it with one
ordinary broadcast STATE_MSG (msg_bc_ack_invalid() clear), sized so its
data area is short, carrying a Gap ACK record with len = 0x400,
bgack_cnt = 0xff and ugack_cnt = 0. len then equals
struct_size(p, gacks, 255), so the consistency check passes and ga is
non-NULL; kmemdup() reads struct_size(ga, gacks, 255) = 1024 bytes out
of the much smaller skb:

  BUG: KASAN: slab-out-of-bounds in kmemdup_noprof+0x48/0x60
  Read of size 1024 at addr ffff0000c7030d38 by task poc864/69
  Call trace:
   kmemdup_noprof+0x48/0x60
   tipc_link_advance_transmq+0x86c/0xb80
   tipc_link_bc_ack_rcv+0x19c/0x1e0
   tipc_bcast_sync_rcv+0x1c4/0x2c4
   tipc_rcv+0x85c/0x1340
   tipc_l2_rcv_msg+0xac/0x104
  The buggy address belongs to the object at ffff0000c7030d00
   which belongs to the cache skbuff_small_head of size 704
  The buggy address is located 56 bytes inside of
   allocated 704-byte region [ffff0000c7030d00, ffff0000c7030fc0)

The copied-out bytes are subsequently consumed as gap/ack values, but
the read is already out of bounds at the kmemdup() regardless of how
they are used.

The unicast STATE path drops such a message: "if (glen > dlen) break;"
skips the rest of STATE_MSG handling and the skb is freed. Make the
broadcast path drop it too. tipc_bcast_sync_rcv() now bounds the record
against msg_data_sz() and, when it does not fit, reports it back through
tipc_node_bc_sync_rcv() to tipc_rcv() so the skb is discarded rather than
processed. ga is not cleared on this path: ga == NULL already means
"legacy peer without Selective ACK", a distinct legitimate state.

Fixes: d7626b5acf ("tipc: introduce Gap ACK blocks for broadcast link")
Cc: stable@vger.kernel.org
Signed-off-by: Samuel Page <sam@bynar.io>
Reviewed-by: Tung Nguyen <tung.quang.nguyen@est.tech>
Link: https://patch.msgid.link/20260625143815.1525412-1-sam@bynar.io
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-06-29 17:30:20 -07:00
..
addr.c tipc: adjust tipc_nodeid2string() to return string length 2025-09-30 11:22:39 +02:00
addr.h tipc: adjust tipc_nodeid2string() to return string length 2025-09-30 11:22:39 +02:00
bcast.c tipc: fix out-of-bounds read in broadcast Gap ACK blocks 2026-06-29 17:30:20 -07:00
bcast.h tipc: fix out-of-bounds read in broadcast Gap ACK blocks 2026-06-29 17:30:20 -07:00
bearer.c tipc: fix UAF in tipc_l2_send_msg() 2026-06-15 12:50:29 -07:00
bearer.h
core.c tipc: avoid busy looping in tipc_exit_net() 2026-06-25 08:53:00 -07:00
core.h kernel.h: drop hex.h and update all hex.h users 2026-01-20 19:44:19 -08:00
crypto.c tipc: fix slab-use-after-free Read in tipc_aead_decrypt_done 2026-06-18 18:35:35 -07:00
crypto.h
diag.c sock_diag: add module pointer to "struct sock_diag_handler" 2024-01-23 15:13:54 +01:00
discover.c tipc: fix use-after-free of the discoverer in tipc_disc_rcv() 2026-06-21 14:28:22 -07:00
discover.h
eth_media.c
group.c tipc: fix bc_ackers underflow on duplicate GRP_ACK_MSG 2026-04-03 15:31:17 -07:00
group.h
ib_media.c
Kconfig ipv6: convert CONFIG_IPV6 to built-in only and clean up Kconfigs 2026-03-29 11:21:22 -07:00
link.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
link.h
Makefile tipc: rename the module name diag to tipc_diag 2024-02-06 13:47:36 +01:00
monitor.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
monitor.h
msg.c tipc: fix double-free in tipc_buf_append() 2026-04-23 11:45:01 -07:00
msg.h
name_distr.c tipc: reject inverted service ranges from peer bindings 2026-06-11 16:01:16 -07:00
name_distr.h
name_table.c Including fixes from IPsec, Bluetooth and netfilter 2026-02-26 08:00:13 -08:00
name_table.h net: tipc: remove one synchronize_net() from tipc_nametbl_stop() 2024-12-06 17:41:28 -08:00
net.c tipc: Fix use-after-free in tipc_mon_reinit_self(). 2025-11-10 18:14:40 -08:00
net.h
netlink_compat.c Convert more 'alloc_obj' cases to default GFP_KERNEL arguments 2026-02-21 20:03:00 -08:00
netlink.c tipc: require net admin for TIPCv2 netlink mutators 2026-06-11 16:01:16 -07:00
netlink.h
node.c tipc: fix out-of-bounds read in broadcast Gap ACK blocks 2026-06-29 17:30:20 -07:00
node.h
socket.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2026-06-16 14:59:58 -07:00
socket.h
subscr.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
subscr.h
sysctl.c net: Remove ctl_table sentinel elements from several networking subsystems 2024-05-03 13:29:42 +01:00
topsrv.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
topsrv.h
trace.c
trace.h tracing/treewide: Remove second parameter of __assign_str() 2024-05-22 20:14:47 -04:00
udp_media.c tipc: avoid busy looping in tipc_exit_net() 2026-06-25 08:53:00 -07:00
udp_media.h