Netdev List
 help / color / mirror / Atom feed
From: Kuniyuki Iwashima <kuniyu@google.com>
To: Eric Dumazet <edumazet@kernel.org>,
	Neal Cardwell <ncardwell@google.com>,
	 Daniel Zahka <daniel.zahka@gmail.com>,
	Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
	 "David S . Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: David Ahern <dsahern@kernel.org>,
	Ido Schimmel <idosch@nvidia.com>,
	 Simon Horman <horms@kernel.org>,
	Thaison Phan <thaisonphan@google.com>,
	 Kuniyuki Iwashima <kuniyu@google.com>,
	Kuniyuki Iwashima <kuni1840@gmail.com>,
	netdev@vger.kernel.org
Subject: [PATCH v1 net-next 1/2] psp: Check pas->tx.spi in psp_sk_overhead().
Date: Tue,  3 Nov 2026 00:06:02 +0000	[thread overview]
Message-ID: <20261103000712.658501-2-kuniyu@google.com> (raw)
In-Reply-To: <20261103000712.658501-1-kuniyu@google.com>

The next patch moves psp_sk_overhead(sk) from icsk->icsk_ext_hdr_len
to __tcp_mtu_to_mss() and tcp_mss_to_mtu(), which can be called
between psp_sock_assoc_set_rx() and psp_sock_set_tx_key() while Tx
packets are still sent in cleartext.

Currently, psp_sk_overhead() only checks if sk->psp_assoc is set,
and even without the next patch, if ipv6_update_options() is called
between psp_sock_assoc_set_rx() and psp_sock_set_tx_key(),
psp_sk_overhead(sk) is added to icsk->icsk_ext_hdr_len twice.

Let's check pas->tx.spi in psp_sk_overhead().

Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
---
not worth backporting, no one does that, only theoretical issue.
---
 include/net/psp/functions.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/net/psp/functions.h b/include/net/psp/functions.h
index b23c30898389..410adb6718c1 100644
--- a/include/net/psp/functions.h
+++ b/include/net/psp/functions.h
@@ -145,9 +145,9 @@ static inline struct psp_assoc *psp_skb_get_assoc_rcu(struct sk_buff *skb)
 static inline unsigned int psp_sk_overhead(const struct sock *sk)
 {
 	int psp_encap = sizeof(struct udphdr) + PSP_HDR_SIZE + PSP_TRL_SIZE;
-	bool has_psp = rcu_access_pointer(sk->psp_assoc);
+	struct psp_assoc *pas = psp_sk_assoc(sk);
 
-	return has_psp ? psp_encap : 0;
+	return pas && pas->tx.spi ? psp_encap : 0;
 }
 #else
 static inline void psp_sk_assoc_free(struct sock *sk) { }
-- 
2.56.0.385.gac671c819a-goog


  reply	other threads:[~2026-11-03  0:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-03  0:06 [PATCH v1 net-next 0/2] tcp: Let non-PSP and PSP share mtu and advmss Kuniyuki Iwashima
2026-11-03  0:06 ` Kuniyuki Iwashima [this message]
2026-11-03  0:06 ` [PATCH v1 net-next 2/2] tcp: Subtract psp_sk_overhead() in __tcp_mtu_to_mss() and tcp_mss_to_mtu() Kuniyuki Iwashima

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=20261103000712.658501-2-kuniyu@google.com \
    --to=kuniyu@google.com \
    --cc=daniel.zahka@gmail.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=kuni1840@gmail.com \
    --cc=ncardwell@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=thaisonphan@google.com \
    --cc=willemdebruijn.kernel@gmail.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