All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] sctp: linearize cloned gso packets in sctp_rcv
@ 2025-08-07 19:40 Xin Long
  2025-08-07 21:47 ` Marcelo Ricardo Leitner
  2025-08-08 20:20 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Xin Long @ 2025-08-07 19:40 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: davem, kuba, Eric Dumazet, Paolo Abeni, Simon Horman,
	Marcelo Ricardo Leitner, Nikita Zhandarovich

A cloned head skb still shares these frag skbs in fraglist with the
original head skb. It's not safe to access these frag skbs.

syzbot reported two use-of-uninitialized-memory bugs caused by this:

  BUG: KMSAN: uninit-value in sctp_inq_pop+0x15b7/0x1920 net/sctp/inqueue.c:211
   sctp_inq_pop+0x15b7/0x1920 net/sctp/inqueue.c:211
   sctp_assoc_bh_rcv+0x1a7/0xc50 net/sctp/associola.c:998
   sctp_inq_push+0x2ef/0x380 net/sctp/inqueue.c:88
   sctp_backlog_rcv+0x397/0xdb0 net/sctp/input.c:331
   sk_backlog_rcv+0x13b/0x420 include/net/sock.h:1122
   __release_sock+0x1da/0x330 net/core/sock.c:3106
   release_sock+0x6b/0x250 net/core/sock.c:3660
   sctp_wait_for_connect+0x487/0x820 net/sctp/socket.c:9360
   sctp_sendmsg_to_asoc+0x1ec1/0x1f00 net/sctp/socket.c:1885
   sctp_sendmsg+0x32b9/0x4a80 net/sctp/socket.c:2031
   inet_sendmsg+0x25a/0x280 net/ipv4/af_inet.c:851
   sock_sendmsg_nosec net/socket.c:718 [inline]

and

  BUG: KMSAN: uninit-value in sctp_assoc_bh_rcv+0x34e/0xbc0 net/sctp/associola.c:987
   sctp_assoc_bh_rcv+0x34e/0xbc0 net/sctp/associola.c:987
   sctp_inq_push+0x2a3/0x350 net/sctp/inqueue.c:88
   sctp_backlog_rcv+0x3c7/0xda0 net/sctp/input.c:331
   sk_backlog_rcv+0x142/0x420 include/net/sock.h:1148
   __release_sock+0x1d3/0x330 net/core/sock.c:3213
   release_sock+0x6b/0x270 net/core/sock.c:3767
   sctp_wait_for_connect+0x458/0x820 net/sctp/socket.c:9367
   sctp_sendmsg_to_asoc+0x223a/0x2260 net/sctp/socket.c:1886
   sctp_sendmsg+0x3910/0x49f0 net/sctp/socket.c:2032
   inet_sendmsg+0x269/0x2a0 net/ipv4/af_inet.c:851
   sock_sendmsg_nosec net/socket.c:712 [inline]

This patch fixes it by linearizing cloned gso packets in sctp_rcv().

Fixes: 90017accff61 ("sctp: Add GSO support")
Reported-by: syzbot+773e51afe420baaf0e2b@syzkaller.appspotmail.com
Reported-by: syzbot+70a42f45e76bede082be@syzkaller.appspotmail.com
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 net/sctp/input.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/sctp/input.c b/net/sctp/input.c
index 2dc2666988fb..7e99894778d4 100644
--- a/net/sctp/input.c
+++ b/net/sctp/input.c
@@ -117,7 +117,7 @@ int sctp_rcv(struct sk_buff *skb)
 	 * it's better to just linearize it otherwise crc computing
 	 * takes longer.
 	 */
-	if ((!is_gso && skb_linearize(skb)) ||
+	if (((!is_gso || skb_cloned(skb)) && skb_linearize(skb)) ||
 	    !pskb_may_pull(skb, sizeof(struct sctphdr)))
 		goto discard_it;
 
-- 
2.47.1


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

* Re: [PATCH net] sctp: linearize cloned gso packets in sctp_rcv
  2025-08-07 19:40 [PATCH net] sctp: linearize cloned gso packets in sctp_rcv Xin Long
@ 2025-08-07 21:47 ` Marcelo Ricardo Leitner
  2025-08-08 20:20 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Marcelo Ricardo Leitner @ 2025-08-07 21:47 UTC (permalink / raw)
  To: Xin Long
  Cc: network dev, linux-sctp, davem, kuba, Eric Dumazet, Paolo Abeni,
	Simon Horman, Nikita Zhandarovich

On Thu, Aug 07, 2025 at 03:40:11PM -0400, Xin Long wrote:
...
> This patch fixes it by linearizing cloned gso packets in sctp_rcv().
> 
> Fixes: 90017accff61 ("sctp: Add GSO support")
> Reported-by: syzbot+773e51afe420baaf0e2b@syzkaller.appspotmail.com
> Reported-by: syzbot+70a42f45e76bede082be@syzkaller.appspotmail.com
> Signed-off-by: Xin Long <lucien.xin@gmail.com>

Reviewed-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>

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

* Re: [PATCH net] sctp: linearize cloned gso packets in sctp_rcv
  2025-08-07 19:40 [PATCH net] sctp: linearize cloned gso packets in sctp_rcv Xin Long
  2025-08-07 21:47 ` Marcelo Ricardo Leitner
@ 2025-08-08 20:20 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-08-08 20:20 UTC (permalink / raw)
  To: Xin Long
  Cc: netdev, linux-sctp, davem, kuba, edumazet, pabeni, horms,
	marcelo.leitner, n.zhandarovich

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Thu,  7 Aug 2025 15:40:11 -0400 you wrote:
> A cloned head skb still shares these frag skbs in fraglist with the
> original head skb. It's not safe to access these frag skbs.
> 
> syzbot reported two use-of-uninitialized-memory bugs caused by this:
> 
>   BUG: KMSAN: uninit-value in sctp_inq_pop+0x15b7/0x1920 net/sctp/inqueue.c:211
>    sctp_inq_pop+0x15b7/0x1920 net/sctp/inqueue.c:211
>    sctp_assoc_bh_rcv+0x1a7/0xc50 net/sctp/associola.c:998
>    sctp_inq_push+0x2ef/0x380 net/sctp/inqueue.c:88
>    sctp_backlog_rcv+0x397/0xdb0 net/sctp/input.c:331
>    sk_backlog_rcv+0x13b/0x420 include/net/sock.h:1122
>    __release_sock+0x1da/0x330 net/core/sock.c:3106
>    release_sock+0x6b/0x250 net/core/sock.c:3660
>    sctp_wait_for_connect+0x487/0x820 net/sctp/socket.c:9360
>    sctp_sendmsg_to_asoc+0x1ec1/0x1f00 net/sctp/socket.c:1885
>    sctp_sendmsg+0x32b9/0x4a80 net/sctp/socket.c:2031
>    inet_sendmsg+0x25a/0x280 net/ipv4/af_inet.c:851
>    sock_sendmsg_nosec net/socket.c:718 [inline]
> 
> [...]

Here is the summary with links:
  - [net] sctp: linearize cloned gso packets in sctp_rcv
    https://git.kernel.org/netdev/net/c/fd60d8a08619

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2025-08-08 20:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-07 19:40 [PATCH net] sctp: linearize cloned gso packets in sctp_rcv Xin Long
2025-08-07 21:47 ` Marcelo Ricardo Leitner
2025-08-08 20:20 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.