net/sctp: Prevent autoclose integer overflow in sctp_association_init()
authorNikolay Kuratov <kniv@yandex-team.ru>
Thu, 19 Dec 2024 16:21:14 +0000 (19:21 +0300)
committerJakub Kicinski <kuba@kernel.org>
Mon, 23 Dec 2024 18:10:13 +0000 (10:10 -0800)
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>
Acked-by: Xin Long <lucien.xin@gmail.com>
Link: https://patch.msgid.link/20241219162114.2863827-1-kniv@yandex-team.ru
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/sctp/associola.c

index c45c192b787873bdfa57e78022b415511a39f3a5..0b0794f164cf2e05db01fcffaec94c1a8546273a 100644 (file)
@@ -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)