* [PATCH] net/sctp: Prevent autoclose integer overflow in sctp_association_init()
@ 2024-12-19 16:21 Nikolay Kuratov
2024-12-23 15:27 ` Xin Long
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Nikolay Kuratov @ 2024-12-19 16:21 UTC (permalink / raw)
To: linux-kernel
Cc: netdev, linux-sctp, Marcelo Ricardo Leitner, Xin Long, Xi Wang,
Neil Horman, Vlad Yasevich, Nikolay Kuratov, stable
While by default max_autoclose equals to INT_MAX / HZ, one may set
net.sctp.max_autoclose to UINT_MAX. There is code in
sctp_association_init() that can consequently trigger overflow.
Cc: stable@vger.kernel.org
Fixes: 9f70f46bd4c7 ("sctp: properly latch and use autoclose value from sock to association")
Signed-off-by: Nikolay Kuratov <kniv@yandex-team.ru>
---
net/sctp/associola.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/sctp/associola.c b/net/sctp/associola.c
index c45c192b7878..0b0794f164cf 100644
--- a/net/sctp/associola.c
+++ b/net/sctp/associola.c
@@ -137,7 +137,8 @@ static struct sctp_association *sctp_association_init(
= 5 * asoc->rto_max;
asoc->timeouts[SCTP_EVENT_TIMEOUT_SACK] = asoc->sackdelay;
- asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE] = sp->autoclose * HZ;
+ asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE] =
+ (unsigned long)sp->autoclose * HZ;
/* Initializes the timers */
for (i = SCTP_EVENT_TIMEOUT_NONE; i < SCTP_NUM_TIMEOUT_TYPES; ++i)
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] net/sctp: Prevent autoclose integer overflow in sctp_association_init()
2024-12-19 16:21 [PATCH] net/sctp: Prevent autoclose integer overflow in sctp_association_init() Nikolay Kuratov
@ 2024-12-23 15:27 ` Xin Long
2024-12-23 18:20 ` patchwork-bot+netdevbpf
2024-12-28 12:10 ` David Laight
2 siblings, 0 replies; 5+ messages in thread
From: Xin Long @ 2024-12-23 15:27 UTC (permalink / raw)
To: Nikolay Kuratov
Cc: linux-kernel, netdev, linux-sctp, Marcelo Ricardo Leitner,
Xi Wang, Neil Horman, Vlad Yasevich, stable
On Thu, Dec 19, 2024 at 11:21 AM Nikolay Kuratov <kniv@yandex-team.ru> wrote:
>
> While by default max_autoclose equals to INT_MAX / HZ, one may set
> net.sctp.max_autoclose to UINT_MAX. There is code in
> sctp_association_init() that can consequently trigger overflow.
>
> Cc: stable@vger.kernel.org
> Fixes: 9f70f46bd4c7 ("sctp: properly latch and use autoclose value from sock to association")
> Signed-off-by: Nikolay Kuratov <kniv@yandex-team.ru>
> ---
> net/sctp/associola.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/net/sctp/associola.c b/net/sctp/associola.c
> index c45c192b7878..0b0794f164cf 100644
> --- a/net/sctp/associola.c
> +++ b/net/sctp/associola.c
> @@ -137,7 +137,8 @@ static struct sctp_association *sctp_association_init(
> = 5 * asoc->rto_max;
>
> asoc->timeouts[SCTP_EVENT_TIMEOUT_SACK] = asoc->sackdelay;
> - asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE] = sp->autoclose * HZ;
> + asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE] =
> + (unsigned long)sp->autoclose * HZ;
>
> /* Initializes the timers */
> for (i = SCTP_EVENT_TIMEOUT_NONE; i < SCTP_NUM_TIMEOUT_TYPES; ++i)
> --
> 2.34.1
>
Acked-by: Xin Long <lucien.xin@gmail.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] net/sctp: Prevent autoclose integer overflow in sctp_association_init()
2024-12-19 16:21 [PATCH] net/sctp: Prevent autoclose integer overflow in sctp_association_init() Nikolay Kuratov
2024-12-23 15:27 ` Xin Long
@ 2024-12-23 18:20 ` patchwork-bot+netdevbpf
2024-12-28 12:10 ` David Laight
2 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-12-23 18:20 UTC (permalink / raw)
To: Nikolay Kuratov
Cc: linux-kernel, netdev, linux-sctp, marcelo.leitner, lucien.xin,
xi.wang, nhorman, vyasevich, stable
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Thu, 19 Dec 2024 19:21:14 +0300 you wrote:
> While by default max_autoclose equals to INT_MAX / HZ, one may set
> net.sctp.max_autoclose to UINT_MAX. There is code in
> sctp_association_init() that can consequently trigger overflow.
>
> Cc: stable@vger.kernel.org
> Fixes: 9f70f46bd4c7 ("sctp: properly latch and use autoclose value from sock to association")
> Signed-off-by: Nikolay Kuratov <kniv@yandex-team.ru>
>
> [...]
Here is the summary with links:
- net/sctp: Prevent autoclose integer overflow in sctp_association_init()
https://git.kernel.org/netdev/net/c/4e86729d1ff3
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] 5+ messages in thread
* Re: [PATCH] net/sctp: Prevent autoclose integer overflow in sctp_association_init()
2024-12-19 16:21 [PATCH] net/sctp: Prevent autoclose integer overflow in sctp_association_init() Nikolay Kuratov
2024-12-23 15:27 ` Xin Long
2024-12-23 18:20 ` patchwork-bot+netdevbpf
@ 2024-12-28 12:10 ` David Laight
2025-02-02 20:47 ` Fedor Pchelkin
2 siblings, 1 reply; 5+ messages in thread
From: David Laight @ 2024-12-28 12:10 UTC (permalink / raw)
To: Nikolay Kuratov
Cc: linux-kernel, netdev, linux-sctp, Marcelo Ricardo Leitner,
Xin Long, Xi Wang, Neil Horman, Vlad Yasevich, stable
On Thu, 19 Dec 2024 19:21:14 +0300
Nikolay Kuratov <kniv@yandex-team.ru> wrote:
> While by default max_autoclose equals to INT_MAX / HZ, one may set
> net.sctp.max_autoclose to UINT_MAX. There is code in
> sctp_association_init() that can consequently trigger overflow.
>
> Cc: stable@vger.kernel.org
> Fixes: 9f70f46bd4c7 ("sctp: properly latch and use autoclose value from sock to association")
> Signed-off-by: Nikolay Kuratov <kniv@yandex-team.ru>
> ---
> net/sctp/associola.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/net/sctp/associola.c b/net/sctp/associola.c
> index c45c192b7878..0b0794f164cf 100644
> --- a/net/sctp/associola.c
> +++ b/net/sctp/associola.c
> @@ -137,7 +137,8 @@ static struct sctp_association *sctp_association_init(
> = 5 * asoc->rto_max;
>
> asoc->timeouts[SCTP_EVENT_TIMEOUT_SACK] = asoc->sackdelay;
> - asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE] = sp->autoclose * HZ;
> + asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE] =
> + (unsigned long)sp->autoclose * HZ;
That doesn't fix 32bit systems.
Looking through sctp/structs.h there are a lot of 'long' used for
timeouts.
it can't be right that any of these change size between 32bit and 64bit.
So they should either be __u32 or __u64 (or similar).
David
>
> /* Initializes the timers */
> for (i = SCTP_EVENT_TIMEOUT_NONE; i < SCTP_NUM_TIMEOUT_TYPES; ++i)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] net/sctp: Prevent autoclose integer overflow in sctp_association_init()
2024-12-28 12:10 ` David Laight
@ 2025-02-02 20:47 ` Fedor Pchelkin
0 siblings, 0 replies; 5+ messages in thread
From: Fedor Pchelkin @ 2025-02-02 20:47 UTC (permalink / raw)
To: David Laight
Cc: Nikolay Kuratov, linux-kernel, netdev, linux-sctp,
Marcelo Ricardo Leitner, Xin Long, Xi Wang, Neil Horman,
Vlad Yasevich, stable
David Laight wrote:
> That doesn't fix 32bit systems.
>
> Looking through sctp/structs.h there are a lot of 'long' used for
> timeouts.
> it can't be right that any of these change size between 32bit and 64bit.
> So they should either be __u32 or __u64 (or similar).
I guess all the 'long' timeout values - not only in sctp, this concerns
other modules in general - follow the jiffies thing itself which is
declared as 'unsigned long'.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-02-02 20:47 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-19 16:21 [PATCH] net/sctp: Prevent autoclose integer overflow in sctp_association_init() Nikolay Kuratov
2024-12-23 15:27 ` Xin Long
2024-12-23 18:20 ` patchwork-bot+netdevbpf
2024-12-28 12:10 ` David Laight
2025-02-02 20:47 ` Fedor Pchelkin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox