Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8AACC3E49C7; Tue, 21 Jul 2026 17:03:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784653418; cv=none; b=idd1DXauVqJ7utBQ+oClZmor3jTaYgMflKuVvC2BisSM9uLnGHL90JSCeWfoIf1BjqOgMsSAon5lJ6bWO5LeK0u7rNriELMBON8ZkJPwu/XiK3LZgiU4Ss71OzeeybvkpX19AmKIQ/nXooPOU+PUrZKWjo6LzAbLCQnQPRnDD0s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784653418; c=relaxed/simple; bh=p+CO7e/gVjs09dAuZfZDGw66ajHMeM8usnLFlLVYMOw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NypW8d5ZWtlCxbrPf9XUjCopoHyRuLB/t0eSxRrYwB0FNObn/kwLZkBzIsmDvAAa6od0cHYzpJtp+aqq4iu75iFTri3gKr7M/GtuwLFpQSZbl1+/RK9v4LzYFSdBXJAkOM6TXggJt07yWXPN8FMwkQerSDPxBtJeL+Alt3UqGYo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=rr0gO/1J; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="rr0gO/1J" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BBB201F000E9; Tue, 21 Jul 2026 17:03:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784653417; bh=KFBEAeFLwNKX8dYr05cZHO7BRfCPU5l5DoWA59ER4OE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=rr0gO/1JUqMuxAWBW6byyeFd42dgP+odFAF4j7DwpFz3KlBk7ef1wgJlOPpwJUKZS TjmrLLa61A5FTKDRgqzOF4VyrwoQwhviiN3+OHnnJX49NxhReGAvZZLqVA+1NqHvaY NOvuRbvFx71LY9HKx6GgC426LL3DQnoKIVy9P4XY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Xin Long , Yousef Alhouseen , Jakub Kicinski , Sasha Levin Subject: [PATCH 7.1 1318/2077] sctp: fix SCTP_RESET_STREAMS stream list length limit Date: Tue, 21 Jul 2026 17:16:31 +0200 Message-ID: <20260721152623.905551195@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152552.646164743@linuxfoundation.org> References: <20260721152552.646164743@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yousef Alhouseen [ Upstream commit 2b9f5ef534184bd81b8a4772780626c40eed1fd5 ] SCTP_RESET_STREAMS carries a flexible array of u16 stream IDs, but the optlen clamps treat USHRT_MAX as a byte count and then multiply sizeof(__u16) by the fixed header size. That caps the copied and validated option buffer at about 64 KiB, which rejects valid requests containing more than about half of the u16 stream ID range. Use struct_size_t() for the maximum struct sctp_reset_streams layout instead, so the bound matches the flexible array described by srs_number_streams. Fixes: 5960cefab9df ("sctp: add a ceiling to optlen in some sockopts") Acked-by: Xin Long Signed-off-by: Yousef Alhouseen Link: https://patch.msgid.link/20260625142354.2600-1-alhouseenyousef@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/sctp/socket.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/net/sctp/socket.c b/net/sctp/socket.c index c8481461f7d8b9..c7b9e325ec1cd3 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -4111,8 +4111,9 @@ static int sctp_setsockopt_reset_streams(struct sock *sk, if (optlen < sizeof(*params)) return -EINVAL; /* srs_number_streams is u16, so optlen can't be bigger than this. */ - optlen = min_t(unsigned int, optlen, USHRT_MAX + - sizeof(__u16) * sizeof(*params)); + optlen = min_t(unsigned int, optlen, + struct_size_t(struct sctp_reset_streams, srs_stream_list, + USHRT_MAX)); if (params->srs_number_streams * sizeof(__u16) > optlen - sizeof(*params)) @@ -4598,8 +4599,8 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname, if (optlen > 0) { /* Trim it to the biggest size sctp sockopt may need if necessary */ optlen = min_t(unsigned int, optlen, - PAGE_ALIGN(USHRT_MAX + - sizeof(__u16) * sizeof(struct sctp_reset_streams))); + PAGE_ALIGN(struct_size_t(struct sctp_reset_streams, + srs_stream_list, USHRT_MAX))); kopt = memdup_sockptr(optval, optlen); if (IS_ERR(kopt)) return PTR_ERR(kopt); -- 2.53.0