Re: [PATCH net v2] tls: fix the open record check in the max payload size setsockopt

From: Paolo Abeni

Date: Thu Sep 03 2026 - 05:17:16 EST


On 9/1/26 9:29 AM, Jiayuan Chen wrote:
> @@ -862,6 +876,7 @@ static int do_tls_setsockopt_tx_payload_len(struct sock *sk, sockptr_t optval,
> static int do_tls_setsockopt(struct sock *sk, int optname, sockptr_t optval,
> unsigned int optlen)
> {
> + struct tls_context *ctx;
> int rc = 0;
>
> switch (optname) {
> @@ -881,9 +896,17 @@ static int do_tls_setsockopt(struct sock *sk, int optname, sockptr_t optval,
> rc = do_tls_setsockopt_no_pad(sk, optval, optlen);
> break;
> case TLS_TX_MAX_PAYLOAD_LEN:
> + /* Take tx_lock like the sendmsg paths do, the socket lock is
> + * dropped while a sender waits for memory, with no record open.
> + */
> + ctx = tls_get_ctx(sk);
> + rc = mutex_lock_interruptible(&ctx->tx_lock);
> + if (rc)

Why using the interruptible variant? the blocking lock just after will
still ignore signals, and this sockopt will now surprisingly fail if a
signal happens at the wrong time.

/P