Cong Wang
6f9fdf5806
tcp_bpf: fix return value of tcp_bpf_sendmsg()
[ Upstream commit fe1910f9337bd46a9343967b547ccab26b4b2c6e ]
When we cork messages in psock->cork, the last message triggers the
flushing will result in sending a sk_msg larger than the current
message size. In this case, in tcp_bpf_send_verdict(), 'copied' becomes
negative at least in the following case:
468 case __SK_DROP:
469 default:
470 sk_msg_free_partial(sk, msg, tosend);
471 sk_msg_apply_bytes(psock, tosend);
472 *copied -= (tosend + delta); // <==== HERE
473 return -EACCES;
Therefore, it could lead to the following BUG with a proper value of
'copied' (thanks to syzbot). We should not use negative 'copied' as a
return value here.
------------[ cut here ]------------
kernel BUG at net/socket.c:733!
Internal error: Oops - BUG: 00000000f2000800 [#1] PREEMPT SMP
Modules linked in:
CPU: 0 UID: 0 PID: 3265 Comm: syz-executor510 Not tainted 6.11.0-rc3-syzkaller-00060-gd07b43284ab3 #0
Hardware name: linux,dummy-virt (DT)
pstate: 61400009 (nZCv daif +PAN -UAO -TCO +DIT -SSBS BTYPE=--)
pc : sock_sendmsg_nosec net/socket.c:733 [inline]
pc : sock_sendmsg_nosec net/socket.c:728 [inline]
pc : __sock_sendmsg+0x5c/0x60 net/socket.c:745
lr : sock_sendmsg_nosec net/socket.c:730 [inline]
lr : __sock_sendmsg+0x54/0x60 net/socket.c:745
sp : ffff800088ea3b30
x29: ffff800088ea3b30 x28: fbf00000062bc900 x27: 0000000000000000
x26: ffff800088ea3bc0 x25: ffff800088ea3bc0 x24: 0000000000000000
x23: f9f00000048dc000 x22: 0000000000000000 x21: ffff800088ea3d90
x20: f9f00000048dc000 x19: ffff800088ea3d90 x18: 0000000000000001
x17: 0000000000000000 x16: 0000000000000000 x15: 000000002002ffaf
x14: 0000000000000000 x13: 0000000000000000 x12: 0000000000000000
x11: 0000000000000000 x10: ffff8000815849c0 x9 : ffff8000815b49c0
x8 : 0000000000000000 x7 : 000000000000003f x6 : 0000000000000000
x5 : 00000000000007e0 x4 : fff07ffffd239000 x3 : fbf00000062bc900
x2 : 0000000000000000 x1 : 0000000000000000 x0 : 00000000fffffdef
Call trace:
sock_sendmsg_nosec net/socket.c:733 [inline]
__sock_sendmsg+0x5c/0x60 net/socket.c:745
____sys_sendmsg+0x274/0x2ac net/socket.c:2597
___sys_sendmsg+0xac/0x100 net/socket.c:2651
__sys_sendmsg+0x84/0xe0 net/socket.c:2680
__do_sys_sendmsg net/socket.c:2689 [inline]
__se_sys_sendmsg net/socket.c:2687 [inline]
__arm64_sys_sendmsg+0x24/0x30 net/socket.c:2687
__invoke_syscall arch/arm64/kernel/syscall.c:35 [inline]
invoke_syscall+0x48/0x110 arch/arm64/kernel/syscall.c:49
el0_svc_common.constprop.0+0x40/0xe0 arch/arm64/kernel/syscall.c:132
do_el0_svc+0x1c/0x28 arch/arm64/kernel/syscall.c:151
el0_svc+0x34/0xec arch/arm64/kernel/entry-common.c:712
el0t_64_sync_handler+0x100/0x12c arch/arm64/kernel/entry-common.c:730
el0t_64_sync+0x19c/0x1a0 arch/arm64/kernel/entry.S:598
Code: f9404463 d63f0060 3108441f 54fffe81 (d4210000)
---[ end trace 0000000000000000 ]---
Fixes: 4f738adba3 ("bpf: create tcp_bpf_ulp allowing BPF to monitor socket TX/RX data")
Reported-by: [email protected]
Cc: Jakub Sitnicki <[email protected]>
Signed-off-by: Cong Wang <[email protected]>
Reviewed-by: John Fastabend <[email protected]>
Acked-by: Martin KaFai Lau <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
|
2024-09-12 11:03:52 +02:00 |
| .. |
|
bpfilter
|
|
|
|
netfilter
|
netfilter: tproxy: bail out if IP has been disabled on the device
|
2024-06-16 13:28:47 +02:00 |
|
af_inet.c
|
net: relax socket state check at accept time.
|
2024-07-27 10:38:33 +02:00 |
|
ah4.c
|
|
|
|
arp.c
|
ipv4: Invalidate neighbour for broadcast address upon address addition
|
2022-04-15 14:18:33 +02:00 |
|
cipso_ipv4.c
|
cipso: fix total option length computation
|
2024-07-05 09:08:22 +02:00 |
|
datagram.c
|
|
|
|
devinet.c
|
ipv4: properly combine dev_base_seq and ipv4.dev_addr_genid
|
2024-03-01 13:13:37 +01:00 |
|
esp4.c
|
net: ipv4: fix return value check in esp_remove_trailer
|
2023-10-25 11:53:21 +02:00 |
|
esp4_offload.c
|
xfrm: Linearize the skb after offloading if needed.
|
2023-06-28 10:18:38 +02:00 |
|
fib_frontend.c
|
ipv4: Fix incorrect table ID in IOCTL path
|
2023-03-22 13:28:06 +01:00 |
|
fib_lookup.h
|
|
|
|
fib_notifier.c
|
|
|
|
fib_rules.c
|
ipv6: fix memory leak in fib6_rule_suppress
|
2021-12-08 09:01:13 +01:00 |
|
fib_semantics.c
|
ipv4: fib: annotate races around nh->nh_saddr_genid and nh->nh_saddr
|
2023-10-25 11:53:21 +02:00 |
|
fib_trie.c
|
ipv4: annotate data-races around fi->fib_dead
|
2023-09-23 10:59:58 +02:00 |
|
fou.c
|
|
|
|
gre_demux.c
|
|
|
|
gre_offload.c
|
|
|
|
icmp.c
|
icmp: guard against too small mtu
|
2023-04-20 12:07:33 +02:00 |
|
igmp.c
|
ipv4: igmp: fix refcnt uaf issue when receiving igmp query packet
|
2023-12-08 08:44:27 +01:00 |
|
inet_connection_sock.c
|
tcp: properly terminate timers for kernel sockets
|
2024-04-13 12:51:33 +02:00 |
|
inet_diag.c
|
inet_diag: Initialize pad field in struct inet_diag_req_v2
|
2024-07-18 11:40:50 +02:00 |
|
inet_fragment.c
|
inet: frags: annotate races around fqdir->dead and fqdir->high_thresh
|
2022-01-27 09:19:54 +01:00 |
|
inet_hashtables.c
|
net: set SOCK_RCU_FREE before inserting socket into hashtable
|
2024-09-12 11:03:50 +02:00 |
|
inet_timewait_sock.c
|
tcp: Fix NEW_SYN_RECV handling in inet_twsk_purge()
|
2024-05-02 16:18:37 +02:00 |
|
inetpeer.c
|
inetpeer: Fix data-races around sysctl.
|
2022-07-21 20:59:20 +02:00 |
|
ip_forward.c
|
|
|
|
ip_fragment.c
|
inet: frags: annotate races around fqdir->dead and fqdir->high_thresh
|
2022-01-27 09:19:54 +01:00 |
|
ip_gre.c
|
ip_gre: do not report erspan version on GRE interface
|
2024-04-13 12:51:40 +02:00 |
|
ip_input.c
|
tcp/udp: Make early_demux back namespacified.
|
2022-11-10 17:57:55 +01:00 |
|
ip_options.c
|
|
|
|
ip_output.c
|
net: ipv4: fix a memleak in ip_setup_cork
|
2024-02-23 08:25:05 +01:00 |
|
ip_sockglue.c
|
ipv{4,6}/raw: fix output xfrm lookup wrt protocol
|
2023-06-05 08:17:33 +02:00 |
|
ip_tunnel.c
|
net: ip_tunnel: make sure to pull inner header in ip_tunnel_rcv()
|
2024-03-26 18:22:17 -04:00 |
|
ip_tunnel_core.c
|
|
|
|
ip_vti.c
|
ip_vti: fix potential slab-use-after-free in decode_session6
|
2023-08-30 16:27:16 +02:00 |
|
ipcomp.c
|
|
|
|
ipconfig.c
|
|
|
|
ipip.c
|
|
|
|
ipmr.c
|
ipmr,ip6mr: acquire RTNL before calling ip[6]mr_free_table() on failure path
|
2022-02-16 12:52:51 +01:00 |
|
ipmr_base.c
|
|
|
|
Kconfig
|
tcp: configurable source port perturb table size
|
2022-12-08 11:23:00 +01:00 |
|
Makefile
|
|
|
|
metrics.c
|
ipv4: prevent potential spectre v1 gadget in ip_metrics_convert()
|
2023-02-06 07:52:45 +01:00 |
|
netfilter.c
|
|
|
|
netlink.c
|
|
|
|
nexthop.c
|
net: nexthop: Initialize all fields in dumped nexthops
|
2024-08-19 05:33:41 +02:00 |
|
ping.c
|
ping: fix address binding wrt vrf
|
2022-05-18 09:47:28 +02:00 |
|
proc.c
|
|
|
|
protocol.c
|
|
|
|
raw.c
|
ipv{4,6}/raw: fix output xfrm lookup wrt protocol
|
2023-06-05 08:17:33 +02:00 |
|
raw_diag.c
|
|
|
|
route.c
|
ipv4: Fix incorrect source address in Record Route option
|
2024-08-19 05:33:41 +02:00 |
|
syncookies.c
|
tcp: fix cookie_init_timestamp() overflows
|
2023-11-20 10:30:10 +01:00 |
|
sysctl_net_ipv4.c
|
tcp/udp: Make early_demux back namespacified.
|
2022-11-10 17:57:55 +01:00 |
|
tcp.c
|
tcp: add TCP_INFO status for failed client TFO
|
2024-07-18 11:40:53 +02:00 |
|
tcp_bbr.c
|
tcp_bbr: fix u32 wrap bug in round logic if bbr_init() called after 2B packets
|
2021-08-18 08:57:01 +02:00 |
|
tcp_bic.c
|
|
|
|
tcp_bpf.c
|
tcp_bpf: fix return value of tcp_bpf_sendmsg()
|
2024-09-12 11:03:52 +02:00 |
|
tcp_cdg.c
|
tcp: cdg: allow tcp_cdg_release() to be called multiple times
|
2022-11-25 17:42:21 +01:00 |
|
tcp_cong.c
|
|
|
|
tcp_cubic.c
|
tcp_cubic: fix spurious Hystart ACK train detections for not-cwnd-limited flows
|
2021-12-01 09:23:33 +01:00 |
|
tcp_dctcp.c
|
tcp: Fix shift-out-of-bounds in dctcp_update_alpha().
|
2024-06-16 13:28:45 +02:00 |
|
tcp_dctcp.h
|
|
|
|
tcp_diag.c
|
|
|
|
tcp_fastopen.c
|
tcp: add TCP_INFO status for failed client TFO
|
2024-07-18 11:40:53 +02:00 |
|
tcp_highspeed.c
|
|
|
|
tcp_htcp.c
|
|
|
|
tcp_hybla.c
|
|
|
|
tcp_illinois.c
|
|
|
|
tcp_input.c
|
tcp: fix incorrect undo caused by DSACK of TLP retransmit
|
2024-07-18 11:40:53 +02:00 |
|
tcp_ipv4.c
|
tcp: avoid premature drops in tcp_add_backlog()
|
2024-06-16 13:28:35 +02:00 |
|
tcp_lp.c
|
|
|
|
tcp_metrics.c
|
tcp_metrics: validate source addr length
|
2024-07-18 11:40:50 +02:00 |
|
tcp_minisocks.c
|
tcp: tcp_check_req() can be called from process context
|
2023-03-11 16:44:12 +01:00 |
|
tcp_nv.c
|
|
|
|
tcp_offload.c
|
|
|
|
tcp_output.c
|
tcp: defer shutdown(SEND_SHUTDOWN) for TCP_SYN_RECV sockets
|
2024-05-17 11:43:53 +02:00 |
|
tcp_rate.c
|
tcp: ensure to use the most recently sent skb when filling the rate sample
|
2022-05-09 09:03:24 +02:00 |
|
tcp_recovery.c
|
tcp: fix excessive TLP and RACK timeouts from HZ rounding
|
2023-10-25 11:53:21 +02:00 |
|
tcp_scalable.c
|
|
|
|
tcp_timer.c
|
tcp: avoid too many retransmit packets
|
2024-07-18 11:40:56 +02:00 |
|
tcp_ulp.c
|
|
|
|
tcp_vegas.c
|
|
|
|
tcp_vegas.h
|
|
|
|
tcp_veno.c
|
|
|
|
tcp_westwood.c
|
|
|
|
tcp_yeah.c
|
|
|
|
tunnel4.c
|
|
|
|
udp.c
|
udp: Set SOCK_RCU_FREE earlier in udp_lib_get_port().
|
2024-07-18 11:40:53 +02:00 |
|
udp_diag.c
|
|
|
|
udp_impl.h
|
|
|
|
udp_offload.c
|
|
|
|
udp_tunnel.c
|
net/tunnel: wait until all sk_user_data reader finish before releasing the sock
|
2023-01-18 11:41:14 +01:00 |
|
udplite.c
|
udplite: Fix NULL pointer dereference in __sk_mem_raise_allocated().
|
2023-05-30 12:44:09 +01:00 |
|
xfrm4_input.c
|
xfrm: Preserve vlan tags for transport mode software GRO
|
2024-05-17 11:43:53 +02:00 |
|
xfrm4_output.c
|
|
|
|
xfrm4_policy.c
|
|
|
|
xfrm4_protocol.c
|
net: xfrm: unexport __init-annotated xfrm4_protocol_init()
|
2022-06-14 18:11:58 +02:00 |
|
xfrm4_state.c
|
|
|
|
xfrm4_tunnel.c
|
|
|