* [PATCH net] tcp: restrict net.ipv4.tcp_app_win
@ 2023-04-06 6:34 YueHaibing
2023-04-06 8:13 ` Eric Dumazet
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: YueHaibing @ 2023-04-06 6:34 UTC (permalink / raw)
To: davem, edumazet, kuba, pabeni, corbet, dsahern, kuniyu
Cc: netdev, linux-doc, linux-kernel, YueHaibing
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 #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.
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
Documentation/networking/ip-sysctl.rst | 2 ++
net/ipv4/sysctl_net_ipv4.c | 3 +++
2 files changed, 5 insertions(+)
diff --git a/Documentation/networking/ip-sysctl.rst b/Documentation/networking/ip-sysctl.rst
index 87dd1c5283e6..58a78a316697 100644
--- a/Documentation/networking/ip-sysctl.rst
+++ b/Documentation/networking/ip-sysctl.rst
@@ -340,6 +340,8 @@ tcp_app_win - INTEGER
Reserve max(window/2^tcp_app_win, mss) of window for application
buffer. Value 0 is special, it means that nothing is reserved.
+ Possible values are [0, 31], inclusive.
+
Default: 31
tcp_autocorking - BOOLEAN
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index 0d0cc4ef2b85..40fe70fc2015 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -25,6 +25,7 @@ static int ip_local_port_range_min[] = { 1, 1 };
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_min_snd_mss_min = TCP_MIN_SND_MSS;
static int tcp_min_snd_mss_max = 65535;
static int ip_privileged_port_min;
@@ -1198,6 +1199,8 @@ static struct ctl_table ipv4_net_table[] = {
.maxlen = sizeof(u8),
.mode = 0644,
.proc_handler = proc_dou8vec_minmax,
+ .extra1 = SYSCTL_ZERO,
+ .extra2 = &tcp_app_win_max,
},
{
.procname = "tcp_adv_win_scale",
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net] tcp: restrict net.ipv4.tcp_app_win
2023-04-06 6:34 [PATCH net] tcp: restrict net.ipv4.tcp_app_win YueHaibing
@ 2023-04-06 8:13 ` Eric Dumazet
2023-04-06 20:36 ` Kuniyuki Iwashima
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Eric Dumazet @ 2023-04-06 8:13 UTC (permalink / raw)
To: YueHaibing
Cc: davem, kuba, pabeni, corbet, dsahern, kuniyu, netdev, linux-doc,
linux-kernel
On Thu, Apr 6, 2023 at 8:35 AM YueHaibing <yuehaibing@huawei.com> wrote:
>
>
> 'maxwin' is int, shifting int for 32 or more bits is undefined behaviour.
>
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> ---
SGTM, thanks.
Reviewed-by: Eric Dumazet <edumazet@google.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net] tcp: restrict net.ipv4.tcp_app_win
2023-04-06 6:34 [PATCH net] tcp: restrict net.ipv4.tcp_app_win YueHaibing
2023-04-06 8:13 ` Eric Dumazet
@ 2023-04-06 20:36 ` Kuniyuki Iwashima
2023-04-07 1:59 ` Jakub Kicinski
2023-04-07 8:10 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 6+ messages in thread
From: Kuniyuki Iwashima @ 2023-04-06 20:36 UTC (permalink / raw)
To: yuehaibing
Cc: corbet, davem, dsahern, edumazet, kuba, kuniyu, linux-doc,
linux-kernel, netdev, pabeni
From: YueHaibing <yuehaibing@huawei.com>
Date: Thu, 6 Apr 2023 14:34:50 +0800
> 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 #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.
>
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Thanks!
> ---
> Documentation/networking/ip-sysctl.rst | 2 ++
> net/ipv4/sysctl_net_ipv4.c | 3 +++
> 2 files changed, 5 insertions(+)
>
> diff --git a/Documentation/networking/ip-sysctl.rst b/Documentation/networking/ip-sysctl.rst
> index 87dd1c5283e6..58a78a316697 100644
> --- a/Documentation/networking/ip-sysctl.rst
> +++ b/Documentation/networking/ip-sysctl.rst
> @@ -340,6 +340,8 @@ tcp_app_win - INTEGER
> Reserve max(window/2^tcp_app_win, mss) of window for application
> buffer. Value 0 is special, it means that nothing is reserved.
>
> + Possible values are [0, 31], inclusive.
> +
> Default: 31
>
> tcp_autocorking - BOOLEAN
> diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
> index 0d0cc4ef2b85..40fe70fc2015 100644
> --- a/net/ipv4/sysctl_net_ipv4.c
> +++ b/net/ipv4/sysctl_net_ipv4.c
> @@ -25,6 +25,7 @@ static int ip_local_port_range_min[] = { 1, 1 };
> 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_min_snd_mss_min = TCP_MIN_SND_MSS;
> static int tcp_min_snd_mss_max = 65535;
> static int ip_privileged_port_min;
> @@ -1198,6 +1199,8 @@ static struct ctl_table ipv4_net_table[] = {
> .maxlen = sizeof(u8),
> .mode = 0644,
> .proc_handler = proc_dou8vec_minmax,
> + .extra1 = SYSCTL_ZERO,
> + .extra2 = &tcp_app_win_max,
> },
> {
> .procname = "tcp_adv_win_scale",
> --
> 2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net] tcp: restrict net.ipv4.tcp_app_win
2023-04-06 6:34 [PATCH net] tcp: restrict net.ipv4.tcp_app_win YueHaibing
2023-04-06 8:13 ` Eric Dumazet
2023-04-06 20:36 ` Kuniyuki Iwashima
@ 2023-04-07 1:59 ` Jakub Kicinski
2023-04-07 2:19 ` Kuniyuki Iwashima
2023-04-07 8:10 ` patchwork-bot+netdevbpf
3 siblings, 1 reply; 6+ messages in thread
From: Jakub Kicinski @ 2023-04-07 1:59 UTC (permalink / raw)
To: YueHaibing
Cc: davem, edumazet, pabeni, corbet, dsahern, kuniyu, netdev,
linux-doc, linux-kernel
On Thu, 6 Apr 2023 14:34:50 +0800 YueHaibing wrote:
> 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 #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.
>
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Fixes tag?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net] tcp: restrict net.ipv4.tcp_app_win
2023-04-07 1:59 ` Jakub Kicinski
@ 2023-04-07 2:19 ` Kuniyuki Iwashima
0 siblings, 0 replies; 6+ messages in thread
From: Kuniyuki Iwashima @ 2023-04-07 2:19 UTC (permalink / raw)
To: kuba
Cc: corbet, davem, dsahern, edumazet, kuniyu, linux-doc, linux-kernel,
netdev, pabeni, yuehaibing
From: Jakub Kicinski <kuba@kernel.org>
Date: Thu, 6 Apr 2023 18:59:26 -0700
> On Thu, 6 Apr 2023 14:34:50 +0800 YueHaibing wrote:
> > 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 #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.
> >
> > Signed-off-by: YueHaibing <yuehaibing@huawei.com>
>
> Fixes tag?
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
It's been broken since the beginning.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net] tcp: restrict net.ipv4.tcp_app_win
2023-04-06 6:34 [PATCH net] tcp: restrict net.ipv4.tcp_app_win YueHaibing
` (2 preceding siblings ...)
2023-04-07 1:59 ` Jakub Kicinski
@ 2023-04-07 8:10 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-04-07 8:10 UTC (permalink / raw)
To: YueHaibing
Cc: davem, edumazet, kuba, pabeni, corbet, dsahern, kuniyu, netdev,
linux-doc, linux-kernel
Hello:
This patch was applied to netdev/net.git (main)
by David S. Miller <davem@davemloft.net>:
On Thu, 6 Apr 2023 14:34:50 +0800 you wrote:
> 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 #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
>
> [...]
Here is the summary with links:
- [net] tcp: restrict net.ipv4.tcp_app_win
https://git.kernel.org/netdev/net/c/dc5110c2d959
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-04-07 8:10 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-06 6:34 [PATCH net] tcp: restrict net.ipv4.tcp_app_win YueHaibing
2023-04-06 8:13 ` Eric Dumazet
2023-04-06 20:36 ` Kuniyuki Iwashima
2023-04-07 1:59 ` Jakub Kicinski
2023-04-07 2:19 ` Kuniyuki Iwashima
2023-04-07 8:10 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).