RE: [PATCH 1/2] sctp: socket: Fix uninitialized error on socket shutdown
"Jagielski, Jedrzej" <[email protected]> Thu, 16 Jul 2026 07:42:43 +0000
| Newsgroups | org.kernel.vger.linux-sctp,org.kernel.vger.linux-kernel,org.kernel.vger.netdev |
|---|---|
| Message-ID | <PH0PR11MB5902DBD696C30DB0A2308A49F0C72@PH0PR11MB5902.namprd11.prod.outlook.com> |
From: luoqing <[email protected]>=20 Sent: Thursday, July 16, 2026 8:53 AM >From: luoqing <[email protected]> > >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 =3D 0. > >Fix this by setting *err =3D 0 before breaking when the socket is shut dow= n, >indicating an orderly shutdown rather than an error condition. Hi luoqing patch title should contain target tree fix patches should contain 'fixes' tag and be targeted to net tree please put Name + Surname for the signed-off-by tag > >Signed-off-by: luoqing <[email protected]> >--- > 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; >=20 >- if (sk->sk_shutdown & RCV_SHUTDOWN) >+ if (sk->sk_shutdown & RCV_SHUTDOWN) { >+ *err =3D 0; from what i see any of the sctp_skb_recv_datagram() callers doesn't use @err - so at this point that fix doesn't affect any code i'm wondering if we could just drop @err > break; >+ } >=20 >=20 > /* User doesn't want to wait. */ >--=20 >2.25.1