From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE46E3F4DC5 for ; Thu, 30 Jul 2026 09:02:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785402138; cv=none; b=DUgMKujNXHCTmiXTZL8Jas5Q17x1+0bREAfCOQVmUjDrL8Qaj5mJ8PDkgoRbWppXvrGCWGq4iB/aCrhjMVBkUP6wVUlUc7t/gypgpkdGpmC68QTSaUJrYYdDU7fvs1XhNtUSxtnydTGnEfpusGSkD9UurNc6Ap73/ZXcAN06HIw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785402138; c=relaxed/simple; bh=7ZO1Hs1qH/JY5i06DvrUJ0HS2+O7RV7KvSY9xWkAOOg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Q8gKGmy/DP+J7gmyJSJnoZ6Lmm9sk/JGNbOZGVV08fIht0pnhfT7QB0vLyhJZI5zrd9SlZ2KXDxO7W679CNTPRR/7qTUzx9MLSOc7c41Y9YoyieXP7wH/NRSFvsS2fUXnPWOjzHT4zJLK1uIu1S6yUPQNRmfVgGAGPgV0SE3d4s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NX1/GIS+; arc=none smtp.client-ip=209.85.210.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NX1/GIS+" Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-84e0688b859so1185561b3a.0 for ; Thu, 30 Jul 2026 02:02:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785402135; x=1786006935; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=2nznSY9JJdaXURervFAHNSIkzxfbF08nZ/1yUlKod9U=; b=NX1/GIS+D8NPxnH5WEAY7ulKY6AKBfK8f3kYRsCtV0DwBHvNOjWWWfhtN+gKQ4yIDt Z+zU8tBHy6CC5VXnP6duB10uuQ+ajzCTSN0oA4t9CzmcIKfUi9Mxpc3+fnZBhXbA3dHX H0rUq0puhK1AYWyYUJoRl24kbK2TSabUaMe84tJ9AVkSpjrik18gBquEI1k+IcRAmmSP p4vty3hZqZT1HrAJzgbHoKWode3AFo/xQWkDPN0mWcAq6A+hPOpZyy9rq4jHH43S3NPD 8DB6ZUBQeRvYq2A1R1xoLhyjjQhU+DFjk00MptHW2j05JRaoAHYfJn7U5n4cbrqn5ZoF yGiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785402135; x=1786006935; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=2nznSY9JJdaXURervFAHNSIkzxfbF08nZ/1yUlKod9U=; b=UkwmHJhTtd2BCFFKnPc8A0AdK3CASGzI8KKpjYTj8o+n1XVL9veRtnJ5FM2JFbnrwU r8kGpnTP4JMEVVOTUGpoBENAoxL9QGKlP23RYzIsvYHF98e2igTGcpuYzqvlcP6ph525 7YHNCNbIAoyzA6GQezfjOFcRqILo2ft9jk3PGkTuetToQFPyQLeAA/VQZRaql8GdkGef 0zwAIICm8+Vrn4T01ib6//CWpDktlmxAvY7hmYXKyPxJVcMKrqWA/d34E+XZUz3pOx17 h80bKEUggGYk8QR6yDYCk7z8yOaKoTZwkGB5fy3baC95p40Z4COtpTTzOIL0aLBka9jj s4jQ== X-Forwarded-Encrypted: i=1; AHgh+RpQU/KhDEB/NXtx8oE6JCd82a7OQJE3R8PfYr8JJddaZDBXxLqTWyBhCPXY36j/3BiMXT1HfCAjZoo//uw=@vger.kernel.org X-Gm-Message-State: AOJu0YwZ7u+a9NsScfZPY6l0p60aDSy6xecOx++hYXDWxf+a3rjXnwTW jtFGB62Q58k7eqTjJWQsYsjmsFsjt5GIMubkGhoi6E/UETC9G+LXgMaj X-Gm-Gg: AR+sD1389Lnq+UP21gz4i5A1VKfbDZEVf1/XUWbLym9kO29IXxBQ8tkpzN3xkCfofT9 QiHDNTOjLwom8c4BdISzOzeea/CNNeEhdmw+JHlaX7hzwVwhKla4vRIrkQduZrFBxNwsNJoV27L IJP+6rQrYiJr31fi3Fy/wkrEqDo2SexxNq43BsqsSDtCi1NsYH9Zg/I592y0dKhTeeKAssSZycn eoyG+niYvtjZFPvLzZnnHjjev+hV5KDTrIvrYuRThW97Uu32P2aErhrM7Mh514i6cuDu/V5voYk OUVTMtiUsfYq9+4/+I/9X/OPaff7epawqQLMGRaK5P6y7lFqGep/4SgDNUPu4AAUfAMN9Had31p ewCRYzGX5ndKgYoHMpeIpcLoyPVE/Epztb9n/ENiNfHYzrO4GsuM5uY7LOnabDaCjryxiB6chOc hqUsqmf8eeqLYqZBySOKQ2jk+hLAAGQiIY0oJjvhy4AUAS93M7IDEiGMVB5TA8i5ir0B7MwADTS FTNDEhvl/VTRGoL562szs+QIw== X-Received: by 2002:a05:6a00:a15:b0:848:6b76:592f with SMTP id d2e1a72fcca58-84ebc1eb894mr1674847b3a.5.1785402134967; Thu, 30 Jul 2026 02:02:14 -0700 (PDT) Received: from JUNVYYANG-MC1.tencent.com ([43.132.141.24]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-84ea0375d6csm2743552b3a.43.2026.07.30.02.02.11 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 30 Jul 2026 02:02:14 -0700 (PDT) From: Jun Yang To: netdev@vger.kernel.org Cc: Jun Yang , stable@kernel.org, TencentOS Corvus AI , Marcelo Ricardo Leitner , Xin Long , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Vlad Yasevich , linux-sctp@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net] sctp: bound the auth_chunks copy length in SCTP_LOCAL_AUTH_CHUNKS Date: Thu, 30 Jul 2026 17:01:47 +0800 Message-ID: <20260730090149.24040-1-juny24602@gmail.com> X-Mailer: git-send-email 2.50.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Jun Yang sctp_getsockopt_local_auth_chunks() copies ntohs(length) - sizeof(paramhdr) bytes out of ch->chunks without bounding the count. For an association ch is the fixed-size asoc->c.auth_chunks[] array (sizeof(struct sctp_paramhdr) + SCTP_AUTH_MAX_CHUNKS bytes), whose length field is restored from the received state cookie by sctp_unpack_cookie() and is not validated against the array size. A cookie carrying an oversized length makes copy_to_user() read past the array (out-of-bounds read). Bound the chunk count to SCTP_AUTH_MAX_CHUNKS before the copy. That is the most valid chunk bytes either source can hold, so legitimate output is unchanged, and it also covers a stored length smaller than the parameter header, which would otherwise underflow. Fixes: 65b07e5d0d09 ("[SCTP]: API updates to suport SCTP-AUTH extensions.") Cc: stable@kernel.org Reported-by: TencentOS Corvus AI Signed-off-by: Jun Yang --- net/sctp/socket.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 9a6da4e0d741..3e9dacb772a0 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -7109,6 +7109,12 @@ static int sctp_getsockopt_local_auth_chunks(struct sock *sk, int len, goto num; num_chunks = ntohs(ch->param_hdr.length) - sizeof(struct sctp_paramhdr); + /* asoc->c.auth_chunks[] holds at most SCTP_AUTH_MAX_CHUNKS bytes but its + * length is restored from the state cookie and is not bounded here; + * clamp so an oversized length cannot read past the array. + */ + if (num_chunks > SCTP_AUTH_MAX_CHUNKS) + num_chunks = SCTP_AUTH_MAX_CHUNKS; if (len < sizeof(struct sctp_authchunks) + num_chunks) return -EINVAL; -- 2.55.0