mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net] sctp: pick the AUTH key by the data chunk type that is sent
@ 2026-11-23  8:26 Kyuwon Cho
  2026-11-24 14:16 ` Xin Long
  2026-11-29 18:00 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Kyuwon Cho @ 2026-11-23  8:26 UTC (permalink / raw)
  To: Xin Long, Marcelo Ricardo Leitner
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Willem de Bruijn, Simon Horman, Neil Horman, linux-sctp, netdev,
	linux-kernel

sctp_datamsg_from_user() takes the chunk key only when the peer asked
to authenticate DATA, but with stream interleaving the message is sent
as I-DATA chunks, and _sctp_make_chunk() marks those for AUTH when the
peer asked for I-DATA. If the peer lists I-DATA but not DATA, the chunk
has auth set and no key, and bundling the AUTH chunk dereferences it:

  KASAN: null-ptr-deref in range [0x0000000000000018-0x000000000000001f]
  RIP: 0010:sctp_packet_append_chunk (net/sctp/output.c:264)
  Call Trace:
   <TASK>
   sctp_packet_transmit_chunk (net/sctp/output.c:189)
   sctp_outq_flush (net/sctp/outqueue.c:1112 net/sctp/outqueue.c:1218)
   sctp_do_sm (net/sctp/sm_sideeffect.c:1826)
   sctp_primitive_SEND (net/sctp/primitive.c:163)
   sctp_sendmsg_to_asoc (net/sctp/socket.c:1919)
   sctp_sendmsg (net/sctp/socket.c:2086)
   __sys_sendto (net/socket.c:2283)

In the opposite case, DATA listed and I-DATA not, the chunks carry a
key but no AUTH, and room for an AUTH chunk is reserved for nothing.

Ask about the chunk type that will actually be built.

Fixes: 0c3f6f655487 ("sctp: implement make_datafrag for sctp_stream_interleave")
Reported-by: Sashiko AI review <netdev-bot+sashiko@kernel.org>
Closes: https://lore.kernel.org/netdev/179540440300.3135.8565987128928534228@kernel.org/
Signed-off-by: Kyuwon Cho <kyuwoncho18@gmail.com>
---
The Sashiko review of our earlier SCTP report pointed this out. We
reproduced it with a test that enables AUTH and interleaving on both
ends of a loopback association and has the listener ask for AUTH on
I-DATA only: the first send() oopses. The test also works as an
unprivileged user in its own user and network namespace, where
net.sctp.auth_enable and net.sctp.intl_enable can be set.

The patch was written with LLM assistance; we reviewed and tested it.
With it, the test runs clean.

 net/sctp/chunk.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/sctp/chunk.c b/net/sctp/chunk.c
index 5b889e89e9f2..0ed251421cda 100644
--- a/net/sctp/chunk.c
+++ b/net/sctp/chunk.c
@@ -183,7 +183,8 @@ struct sctp_datamsg *sctp_datamsg_from_user(struct sctp_association *asoc,
 	 * we need to account for bundling of the AUTH chunks along with
 	 * DATA.
 	 */
-	if (sctp_auth_send_cid(SCTP_CID_DATA, asoc)) {
+	if (sctp_auth_send_cid(asoc->peer.intl_capable ? SCTP_CID_I_DATA :
+							 SCTP_CID_DATA, asoc)) {
 		const struct sctp_hmac *hmac_desc =
 			sctp_auth_asoc_get_hmac(asoc);
 
-- 
2.43.0


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

* Re: [PATCH net] sctp: pick the AUTH key by the data chunk type that is sent
  2026-11-23  8:26 [PATCH net] sctp: pick the AUTH key by the data chunk type that is sent Kyuwon Cho
@ 2026-11-24 14:16 ` Xin Long
  2026-11-29 18:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Xin Long @ 2026-11-24 14:16 UTC (permalink / raw)
  To: Kyuwon Cho
  Cc: Marcelo Ricardo Leitner, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Willem de Bruijn, Simon Horman,
	Neil Horman, linux-sctp, netdev, linux-kernel

On Mon, Nov 23, 2026 at 3:26 AM Kyuwon Cho <kyuwoncho18@gmail.com> wrote:
>
> sctp_datamsg_from_user() takes the chunk key only when the peer asked
> to authenticate DATA, but with stream interleaving the message is sent
> as I-DATA chunks, and _sctp_make_chunk() marks those for AUTH when the
> peer asked for I-DATA. If the peer lists I-DATA but not DATA, the chunk
> has auth set and no key, and bundling the AUTH chunk dereferences it:
>
>   KASAN: null-ptr-deref in range [0x0000000000000018-0x000000000000001f]
>   RIP: 0010:sctp_packet_append_chunk (net/sctp/output.c:264)
>   Call Trace:
>    <TASK>
>    sctp_packet_transmit_chunk (net/sctp/output.c:189)
>    sctp_outq_flush (net/sctp/outqueue.c:1112 net/sctp/outqueue.c:1218)
>    sctp_do_sm (net/sctp/sm_sideeffect.c:1826)
>    sctp_primitive_SEND (net/sctp/primitive.c:163)
>    sctp_sendmsg_to_asoc (net/sctp/socket.c:1919)
>    sctp_sendmsg (net/sctp/socket.c:2086)
>    __sys_sendto (net/socket.c:2283)
>
> In the opposite case, DATA listed and I-DATA not, the chunks carry a
> key but no AUTH, and room for an AUTH chunk is reserved for nothing.
>
> Ask about the chunk type that will actually be built.
>
> Fixes: 0c3f6f655487 ("sctp: implement make_datafrag for sctp_stream_interleave")
> Reported-by: Sashiko AI review <netdev-bot+sashiko@kernel.org>
> Closes: https://lore.kernel.org/netdev/179540440300.3135.8565987128928534228@kernel.org/
> Signed-off-by: Kyuwon Cho <kyuwoncho18@gmail.com>
> ---
> The Sashiko review of our earlier SCTP report pointed this out. We
> reproduced it with a test that enables AUTH and interleaving on both
> ends of a loopback association and has the listener ask for AUTH on
> I-DATA only: the first send() oopses. The test also works as an
> unprivileged user in its own user and network namespace, where
> net.sctp.auth_enable and net.sctp.intl_enable can be set.
>
> The patch was written with LLM assistance; we reviewed and tested it.
> With it, the test runs clean.
>
>  net/sctp/chunk.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/net/sctp/chunk.c b/net/sctp/chunk.c
> index 5b889e89e9f2..0ed251421cda 100644
> --- a/net/sctp/chunk.c
> +++ b/net/sctp/chunk.c
> @@ -183,7 +183,8 @@ struct sctp_datamsg *sctp_datamsg_from_user(struct sctp_association *asoc,
>          * we need to account for bundling of the AUTH chunks along with
>          * DATA.
>          */
> -       if (sctp_auth_send_cid(SCTP_CID_DATA, asoc)) {
> +       if (sctp_auth_send_cid(asoc->peer.intl_capable ? SCTP_CID_I_DATA :
> +                                                        SCTP_CID_DATA, asoc)) {
>                 const struct sctp_hmac *hmac_desc =
>                         sctp_auth_asoc_get_hmac(asoc);
>
> --
> 2.43.0
>

Acked-by: Xin Long <lucien.xin@gmail.com>

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

* Re: [PATCH net] sctp: pick the AUTH key by the data chunk type that is sent
  2026-11-23  8:26 [PATCH net] sctp: pick the AUTH key by the data chunk type that is sent Kyuwon Cho
  2026-11-24 14:16 ` Xin Long
@ 2026-11-29 18:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-11-29 18:00 UTC (permalink / raw)
  To: Kyuwon Cho
  Cc: lucien.xin, marcelo.leitner, davem, edumazet, kuba, pabeni,
	willemb, horms, nhorman, linux-sctp, netdev, linux-kernel

Hello:

This patch was applied to netdev/net.git (main)
by Willem de Bruijn <willemb@google.com>:

On Mon, 23 Nov 2026 17:26:25 +0900 you wrote:
> sctp_datamsg_from_user() takes the chunk key only when the peer asked
> to authenticate DATA, but with stream interleaving the message is sent
> as I-DATA chunks, and _sctp_make_chunk() marks those for AUTH when the
> peer asked for I-DATA. If the peer lists I-DATA but not DATA, the chunk
> has auth set and no key, and bundling the AUTH chunk dereferences it:
> 
>   KASAN: null-ptr-deref in range [0x0000000000000018-0x000000000000001f]
>   RIP: 0010:sctp_packet_append_chunk (net/sctp/output.c:264)
>   Call Trace:
>    <TASK>
>    sctp_packet_transmit_chunk (net/sctp/output.c:189)
>    sctp_outq_flush (net/sctp/outqueue.c:1112 net/sctp/outqueue.c:1218)
>    sctp_do_sm (net/sctp/sm_sideeffect.c:1826)
>    sctp_primitive_SEND (net/sctp/primitive.c:163)
>    sctp_sendmsg_to_asoc (net/sctp/socket.c:1919)
>    sctp_sendmsg (net/sctp/socket.c:2086)
>    __sys_sendto (net/socket.c:2283)
> 
> [...]

Here is the summary with links:
  - [net] sctp: pick the AUTH key by the data chunk type that is sent
    https://git.kernel.org/netdev/net/c/1ca5a3b4c235

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:[~2026-11-29 18:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-23  8:26 [PATCH net] sctp: pick the AUTH key by the data chunk type that is sent Kyuwon Cho
2026-11-24 14:16 ` Xin Long
2026-11-29 18:00 ` patchwork-bot+netdevbpf

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

all inboxes | Powered by JetHome®