From mboxrd@z Thu Jan 1 00:00:00 1970 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 A5E6B280CD5; Tue, 13 Oct 2026 12:49:12 +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=1791895753; cv=none; b=WxwnLJADWut8mmx+DnoCwPKOdeZ6VCYfi9WARRQaGQ1QlSPibXVg7Edc3U6q9lxTkzlU0PtvhEJl83wFWJJfTpe+cwpsieGh5bFI5cpvq3YocWlK6mjK6V8QinRaL3tgZ8aoD9giCebvNMF9prvu2APR0bFjP04CO25HCXh8Cqg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791895753; c=relaxed/simple; bh=7X12fq0uyo20Oc2SYwKjsw6X9hj2kI3cuMmZ0a/rK4I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uZ1McNpdQY1k8HzS12UfginqK7pWEgsjg5OaCpHHbf2D+VAPaRjaSOqJy6gdIP16exnOTonzVo48/c2aXi84Md7AgbzRBCsET7THqR4rw2PpohIEwNfk/JZdJ3StatdtwUvqU5ck4HAadbxPUMw2QLE4BnBfx2oQTT8VxFLDWdM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=EjZDjcJ8; 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="EjZDjcJ8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ED24B1F000FF; Tue, 13 Oct 2026 12:49:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1791895752; bh=UzIWkYmajGF2P0M8IWD+o/C92R0AgHuR/VYwwYbBX6E=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=EjZDjcJ87f/iDWs5KmnWKiaAfWtv+ccimdaxNB0alWan5MOX7jAcIFwwfHvkzOamY PoLUHFBknTai0jx3UeL9dHMeh2Su1nkBWsk3pNvSAfXLEFei7pnEb/235G+m+WP1f0 /YMGmnyqkWaGHZTqV6ho8pDPzW1jilk+SiDbxOuo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Xin Long , Hui Peng , Jakub Kicinski Subject: [PATCH 6.12 382/497] sctp: copy zeroed stats to user in sctp_getsockopt_pr_streamstatus() when !streamoute Date: Tue, 13 Oct 2026 13:39:09 +0200 Message-ID: <20261013112916.962809289@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261013112907.864180619@linuxfoundation.org> References: <20261013112907.864180619@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 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Hui Peng commit 538b529509c7ab0d909cb65bb7264edca1788d30 upstream. When an SCTP stream output extension structure (streamoute) has not yet been allocated, sctp_getsockopt_pr_streamstatus() sets the local stack variables params.sprstat_abandoned_unsent = 0 and params.sprstat_abandoned_sent = 0, but then immediately jumps to 'out:', bypassing copy_to_user(). As a result, when an uninitialized user buffer is passed to getsockopt(SCTP_PR_STREAM_STATUS), the kernel returns success (0) without copying the zeroed stats back to user space, leaving uninitialized data in the user buffer. Refactor the !streamoute check into an if-else chain so that when streamoute is NULL, params is zeroed and falls through to copy_to_user(), copying the zeroed stats to user space and setting retval = 0 once before returning. Tested in QEMU against Linux 7.3.0-rc3 using an uninitialized sctp_prstatus user struct passed to getsockopt(SCTP_PR_STREAM_STATUS) on a freshly created stream: on the unfixed kernel the user struct contains uninitialized stack garbage; whereas with this fix applied, getsockopt() copies zeroed stats into user space and returns 0. Cc: stable@vger.kernel.org Reviewed-by: Xin Long Signed-off-by: Hui Peng Fixes: f952be79cebd ("sctp: introduce struct sctp_stream_out_ext") Link: https://patch.msgid.link/20260930044611.204739-1-benquike@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/sctp/socket.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -7529,11 +7529,7 @@ static int sctp_getsockopt_pr_streamstat /* Not allocated yet, means all stats are 0 */ params.sprstat_abandoned_unsent = 0; params.sprstat_abandoned_sent = 0; - retval = 0; - goto out; - } - - if (policy == SCTP_PR_SCTP_ALL) { + } else if (policy == SCTP_PR_SCTP_ALL) { params.sprstat_abandoned_unsent = 0; params.sprstat_abandoned_sent = 0; for (policy = 0; policy <= SCTP_PR_INDEX(MAX); policy++) {