Netdev List
 help / color / mirror / Atom feed
* [PATCH 1/2] sctp: socket: Fix uninitialized error on socket shutdown
@ 2026-07-16  6:52 luoqing
  2026-07-16  6:52 ` [PATCH 2/2] sctp: auth: Fix safety issue when skb_clone fails in auth_chunk handling luoqing
  2026-07-16  7:42 ` [PATCH 1/2] sctp: socket: Fix uninitialized error on socket shutdown Jagielski, Jedrzej
  0 siblings, 2 replies; 6+ messages in thread
From: luoqing @ 2026-07-16  6:52 UTC (permalink / raw)
  To: marcelo.leitner, lucien.xin, davem, edumazet, kuba, pabeni
  Cc: horms, linux-sctp, netdev, linux-kernel, luoqing

From: luoqing <luoqing@kylinos.cn>

When sctp_skb_recv_datagram() detects sk->sk_shutdown & RCV_SHUTDOWN,
it breaks out of the loop and returns NULL without setting *err.
This leaves the error pointer uninitialized or with a stale value,
which can confuse callers expecting a clean shutdown indication.

Compare with the generic __skb_wait_for_more_packets() in
net/core/datagram.c which properly handles shutdown by setting *err = 0.

Fix this by setting *err = 0 before breaking when the socket is shut down,
indicating an orderly shutdown rather than an error condition.

Signed-off-by: luoqing <luoqing@kylinos.cn>
---
 net/sctp/socket.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index c7b9e325ec1c..ea7050b27715 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -9117,8 +9117,10 @@ struct sk_buff *sctp_skb_recv_datagram(struct sock *sk, int flags, int *err)
 		if (error)
 			goto no_packet;
 
-		if (sk->sk_shutdown & RCV_SHUTDOWN)
+		if (sk->sk_shutdown & RCV_SHUTDOWN) {
+			*err = 0;
 			break;
+		}
 
 
 		/* User doesn't want to wait.  */
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-07-17 18:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-16  6:52 [PATCH 1/2] sctp: socket: Fix uninitialized error on socket shutdown luoqing
2026-07-16  6:52 ` [PATCH 2/2] sctp: auth: Fix safety issue when skb_clone fails in auth_chunk handling luoqing
2026-07-16  7:42 ` [PATCH 1/2] sctp: socket: Fix uninitialized error on socket shutdown Jagielski, Jedrzej
2026-07-17  8:20   ` [PATCH net v3] sctp: socket: remove unused 'err' parameter from sctp_skb_recv_datagram luoqing
2026-07-17 15:10     ` Xin Long
2026-07-17 18:19       ` David Laight

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox