The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH net-next v4] sctp: socket: set *err = 0 on receive shutdown
@ 2026-07-21  2:25 luoqing
  2026-07-27 23:29 ` Jakub Kicinski
  0 siblings, 1 reply; 2+ messages in thread
From: luoqing @ 2026-07-21  2:25 UTC (permalink / raw)
  To: marcelo.leitner, lucien.xin, davem, edumazet, kuba, pabeni
  Cc: horms, linux-sctp, netdev, linux-kernel

From: Qing Luo <luoqing@kylinos.cn>

When sctp_skb_recv_datagram() detects RCV_SHUTDOWN, it breaks out
of the loop and returns NULL without setting *err. While current
callers happen to work correctly (sctp_recvmsg pre-initializes
err to 0, sctp_ulpevent_read_nxtinfo doesn't use err), this is
inconsistent with the generic __skb_wait_for_more_packets() in
net/core/datagram.c which explicitly sets *err = 0 on shutdown.

Set *err = 0 explicitly for correctness and robustness against
future callers.

Signed-off-by: Qing Luo <luoqing@kylinos.cn>
---
 net/sctp/socket.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index c7b9e325ec1c..b8ec295e3a2f 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -9117,9 +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.  */
 		error = -EAGAIN;
-- 
2.25.1
Thanks for the review.

On reflection, I agree that the ERR_PTR refactoring should be dropped. Honestly, the refactored version ends up being more convoluted rather than simplifying things, so I’ll revert to the original &err interface to keep it consistent with skb_recv_datagram().

Regarding the *err = 0 fix for the shutdown path — my intention there was purely defensive, aligning with the pattern used in __skb_wait_for_more_packets(). As the commit message notes, the current callers are not actually affected by this, so no real bug is introduced. That said, if you feel this change is still unnecessary, I’m happy to drop it as well.


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

* Re: [PATCH net-next v4] sctp: socket: set *err = 0 on receive shutdown
  2026-07-21  2:25 [PATCH net-next v4] sctp: socket: set *err = 0 on receive shutdown luoqing
@ 2026-07-27 23:29 ` Jakub Kicinski
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Kicinski @ 2026-07-27 23:29 UTC (permalink / raw)
  To: luoqing
  Cc: marcelo.leitner, lucien.xin, davem, edumazet, pabeni, horms,
	linux-sctp, netdev, linux-kernel

On Tue, 21 Jul 2026 10:25:22 +0800 luoqing wrote:
> From: Qing Luo <luoqing@kylinos.cn>
> 
> When sctp_skb_recv_datagram() detects RCV_SHUTDOWN, it breaks out
> of the loop and returns NULL without setting *err. While current
> callers happen to work correctly (sctp_recvmsg pre-initializes
> err to 0, sctp_ulpevent_read_nxtinfo doesn't use err), this is
> inconsistent with the generic __skb_wait_for_more_packets() in
> net/core/datagram.c which explicitly sets *err = 0 on shutdown.
> 
> Set *err = 0 explicitly for correctness and robustness against
> future callers.
> 
> Signed-off-by: Qing Luo <luoqing@kylinos.cn>

AFAICT Xin Long asked you to toss this patch:

https://lore.kernel.org/all/CADvbK_e4StN7-vSRjYC_FPMN-_3xjwhCxYUb+Jddz-akO-ryPw@mail.gmail.com/

so I'm dropping it from our queue.

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

end of thread, other threads:[~2026-07-27 23:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-21  2:25 [PATCH net-next v4] sctp: socket: set *err = 0 on receive shutdown luoqing
2026-07-27 23:29 ` Jakub Kicinski

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