mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
tcp: limit tcp_tso_rtt_log to a valid shift count
tcp_tso_autosize() right-shifts the u32 returned by tcp_min_rtt() by
sysctl_tcp_tso_rtt_log. The sysctl uses proc_dou8vec_minmax() without
an upper bound, so it accepts values through 255. Values above 31 make
the shift undefined.
A process with CAP_NET_ADMIN in the target network namespace can set the
per-netns sysctl. With CONFIG_UBSAN_SHIFT=y, setting it to 32 and sending
TCP data over loopback triggers:
UBSAN: shift-out-of-bounds in net/ipv4/tcp_output.c:2264:30
shift exponent 32 is too large for 32-bit type 'unsigned int'
Call Trace:
__ubsan_handle_shift_out_of_bounds
tcp_tso_segs
tcp_write_xmit
__tcp_push_pending_frames
tcp_push
tcp_sendmsg_locked
Limit the sysctl to 31, the largest valid shift count for a u32, and
document the accepted range. Writes of larger values now fail with
-EINVAL.
On a UBSAN/KASAN build of the net tree, values 0 and 31 remained
accepted, values 32 and 255 returned -EINVAL, and TCP traffic with the
valid boundary values produced no sanitizer diagnostics.
Fixes: 65466904b0 ("tcp: adjust TSO packet sizes based on min_rtt")
Cc: stable@vger.kernel.org
Signed-off-by: Yingjie Wang <1075151112@qq.com>
Reviewed-by: Jiayuan Chen <jiayuan.chen@linux.dev>
Reviewed-by: Neal Cardwell <ncardwell@google.com>
Reviewed-by: Eric Dumazet <edumazet@kernel.org>
Link: https://patch.msgid.link/tencent_31D2FFCCE76C50A695A1270151F825E90906@qq.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
5308a2049b
commit
850a7225bc
|
|
@ -1128,6 +1128,8 @@ tcp_tso_rtt_log - INTEGER
|
|||
|
||||
If you want to use the old autosizing, set this sysctl to 0.
|
||||
|
||||
Possible values are [0, 31], inclusive.
|
||||
|
||||
Default: 9 (2^9 = 512 usec)
|
||||
|
||||
tcp_pacing_ss_ratio - INTEGER
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ static int ip_local_port_range_max[] = { 65535, 65535 };
|
|||
static int tcp_adv_win_scale_min = -31;
|
||||
static int tcp_adv_win_scale_max = 31;
|
||||
static int tcp_app_win_max = 31;
|
||||
static int tcp_tso_rtt_log_max = 31;
|
||||
static int tcp_min_snd_mss_min = TCP_MIN_SND_MSS;
|
||||
static int tcp_min_snd_mss_max = 65535;
|
||||
static int tcp_rto_max_max = TCP_RTO_MAX_SEC * MSEC_PER_SEC;
|
||||
|
|
@ -1406,6 +1407,7 @@ static const struct ctl_table ipv4_net_table[] = {
|
|||
.maxlen = sizeof(u8),
|
||||
.mode = 0644,
|
||||
.proc_handler = proc_dou8vec_minmax,
|
||||
.extra2 = &tcp_tso_rtt_log_max,
|
||||
},
|
||||
{
|
||||
.procname = "tcp_min_rtt_wlen",
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user