Skip to content

Commit a069d4d

Browse files
YueHaibinggregkh
authored andcommitted
tcp: restrict net.ipv4.tcp_app_win
[ Upstream commit dc5110c ] UBSAN: shift-out-of-bounds in net/ipv4/tcp_input.c:555:23 shift exponent 255 is too large for 32-bit type 'int' CPU: 1 PID: 7907 Comm: ssh Not tainted 6.3.0-rc4-00161-g62bad54b26db-dirty torvalds#206 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014 Call Trace: <TASK> dump_stack_lvl+0x136/0x150 __ubsan_handle_shift_out_of_bounds+0x21f/0x5a0 tcp_init_transfer.cold+0x3a/0xb9 tcp_finish_connect+0x1d0/0x620 tcp_rcv_state_process+0xd78/0x4d60 tcp_v4_do_rcv+0x33d/0x9d0 __release_sock+0x133/0x3b0 release_sock+0x58/0x1b0 'maxwin' is int, shifting int for 32 or more bits is undefined behaviour. Fixes: 1da177e ("Linux-2.6.12-rc2") Signed-off-by: YueHaibing <yuehaibing@huawei.com> Reviewed-by: Eric Dumazet <edumazet@google.com> Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent cc9f9a4 commit a069d4d

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

Documentation/networking/ip-sysctl.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,8 @@ tcp_app_win - INTEGER
272272
Reserve max(window/2^tcp_app_win, mss) of window for application
273273
buffer. Value 0 is special, it means that nothing is reserved.
274274

275+
Possible values are [0, 31], inclusive.
276+
275277
Default: 31
276278

277279
tcp_autocorking - BOOLEAN

net/ipv4/sysctl_net_ipv4.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ static int ip_local_port_range_min[] = { 1, 1 };
3737
static int ip_local_port_range_max[] = { 65535, 65535 };
3838
static int tcp_adv_win_scale_min = -31;
3939
static int tcp_adv_win_scale_max = 31;
40+
static int tcp_app_win_max = 31;
4041
static int tcp_min_snd_mss_min = TCP_MIN_SND_MSS;
4142
static int tcp_min_snd_mss_max = 65535;
4243
static int ip_privileged_port_min;
@@ -1115,6 +1116,8 @@ static struct ctl_table ipv4_net_table[] = {
11151116
.maxlen = sizeof(u8),
11161117
.mode = 0644,
11171118
.proc_handler = proc_dou8vec_minmax,
1119+
.extra1 = SYSCTL_ZERO,
1120+
.extra2 = &tcp_app_win_max,
11181121
},
11191122
{
11201123
.procname = "tcp_adv_win_scale",

0 commit comments

Comments
 (0)