Netdev List
 help / color / mirror / Atom feed
From: luoqing <l1138897701@163.com>
To: marcelo.leitner@gmail.com, lucien.xin@gmail.com,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com
Cc: horms@kernel.org, linux-sctp@vger.kernel.org,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH net v3 1/2] sctp: auth: do not set auth flag when skb_clone fails
Date: Mon, 20 Jul 2026 17:31:15 +0800	[thread overview]
Message-ID: <20260720093116.1266202-1-l1138897701@163.com> (raw)

From: Qing Luo <luoqing@kylinos.cn>

When processing AUTH + COOKIE-ECHO packets in sctp_assoc_bh_rcv()
and sctp_endpoint_bh_rcv(), the AUTH chunk skb is cloned and
saved as chunk->auth_chunk for deferred verification. However,
when skb_clone() fails under memory pressure, chunk->auth_chunk
is set to NULL but chunk->auth is still unconditionally set to 1.

This creates an inconsistent state where the chunk appears to be
authenticated (auth == 1) but has no auth_chunk data to actually
verify against. Later, sctp_auth_chunk_verify() sees a NULL
auth_chunk and returns true, skipping authentication entirely
and allowing unauthenticated COOKIE-ECHO packets to be accepted.

Fix this by only setting chunk->auth = 1 when skb_clone()
succeeds, ensuring the auth flag accurately reflects whether
a valid auth_chunk is available for verification.

Fixes: bbd0d59809f9 ("[SCTP]: Implement the receive and verification of AUTH chunk")
Signed-off-by: Qing Luo <luoqing@kylinos.cn>
---
 net/sctp/associola.c   | 3 ++-
 net/sctp/endpointola.c | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/sctp/associola.c b/net/sctp/associola.c
index 62d3cc155809..e54068305396 100644
--- a/net/sctp/associola.c
+++ b/net/sctp/associola.c
@@ -999,7 +999,8 @@ static void sctp_assoc_bh_rcv(struct work_struct *work)
 			if (next_hdr->type == SCTP_CID_COOKIE_ECHO) {
 				chunk->auth_chunk = skb_clone(chunk->skb,
 							      GFP_ATOMIC);
-				chunk->auth = 1;
+				if (chunk->auth_chunk)
+					chunk->auth = 1;
 				continue;
 			}
 		}
diff --git a/net/sctp/endpointola.c b/net/sctp/endpointola.c
index dfb1719275db..3419748c66bc 100644
--- a/net/sctp/endpointola.c
+++ b/net/sctp/endpointola.c
@@ -368,7 +368,8 @@ static void sctp_endpoint_bh_rcv(struct work_struct *work)
 			if (next_hdr->type == SCTP_CID_COOKIE_ECHO) {
 				chunk->auth_chunk = skb_clone(chunk->skb,
 								GFP_ATOMIC);
-				chunk->auth = 1;
+				if (chunk->auth_chunk)
+					chunk->auth = 1;
 				continue;
 			}
 		}
-- 
2.25.1


             reply	other threads:[~2026-07-20  9:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-20  9:31 luoqing [this message]
2026-07-20  9:31 ` [PATCH net v3 2/2] sctp: auth: verify auth requirement when auth_chunk is NULL luoqing
2026-07-20 15:01   ` Xin Long

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260720093116.1266202-1-l1138897701@163.com \
    --to=l1138897701@163.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sctp@vger.kernel.org \
    --cc=lucien.xin@gmail.com \
    --cc=marcelo.leitner@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox