From: Jakub Kicinski <kuba@kernel.org>
To: Maximilian Immanuel Brandtner <maxbr@linux.ibm.com>
Cc: john.fastabend@gmail.com, sd@queasysnail.net,
davem@davemloft.net, edumazet@google.com, pabeni@redhat.com,
horms@kernel.org, bcodding@redhat.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, svens@linux.ibm.com,
brueckner@linux.ibm.com
Subject: Re: [PATCH] tls: don't abort the connection on signal-interrupted sends
Date: Thu, 23 Jul 2026 09:26:30 -0700 [thread overview]
Message-ID: <20260723092630.1a1c9b4e@kernel.org> (raw)
In-Reply-To: <20260720090940.1334523-1-maxbr@linux.ibm.com>
On Mon, 20 Jul 2026 11:08:47 +0200 Maximilian Immanuel Brandtner wrote:
> When a signal interrupts a blocking send, tls_tx_records() treats the
> resulting -ERESTARTSYS as a transmission failure and marks the socket
> errored via tls_err_abort() with the raw error code. Later syscalls
> return the kernel-internal errno 512 (ERESTARTSYS) to userspace, as the
> signal it stems from is no longer pending during syscall exit and thus
> never translated.
Can we just add ERESTARTSYS handling? I never heard of the other codes
you're checking TBH, can they actually surface?
> An interrupted send is not a connection error: the partially sent record
> stays queued and is resent later. Interrupt error codes are therefore
> excluded from the abort in the same way as -EAGAIN.
>
> Fixes: b341ca51d267 ("tls: Fix tls_sw_sendmsg error handling")
> Signed-off-by: Maximilian Immanuel Brandtner <maxbr@linux.ibm.com>
> ---
> Tested on top of net commit 3f1f75536668 ("net: openvswitch: reject
> oversized nested action attrs").
>
> Several subsystems contain static helper functions to classify these
> interrupt errnos. It might be worthwhile to refactor these static
> functions into a generic helper function.
Yes, please.
> diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
> index d4afc90fd796..3c9e94069e82 100644
> --- a/net/tls/tls_sw.c
> +++ b/net/tls/tls_sw.c
> @@ -405,6 +405,24 @@ static void tls_free_open_rec(struct sock *sk)
> }
> }
>
> +static bool tls_is_non_restartable_err(int err)
> +{
> + if (err >= 0)
> + return false;
This doesn't belong in a helper for classifying errors.
> + switch (err) {
> + case -EAGAIN:
> + case -EINTR:
> + case -ERESTARTSYS:
> + case -ERESTARTNOINTR:
> + case -ERESTARTNOHAND:
> + case -ERESTART_RESTARTBLOCK:
> + return false;
> + default:
> + return true;
> + }
> +}
> +
> int tls_tx_records(struct sock *sk, int flags)
> {
> struct tls_context *tls_ctx = tls_get_ctx(sk);
> @@ -458,7 +476,7 @@ int tls_tx_records(struct sock *sk, int flags)
> }
>
> tx_err:
> - if (rc < 0 && rc != -EAGAIN)
> + if (tls_is_non_restartable_err(rc))
> tls_err_abort(sk, rc);
>
> return rc;
--
pw-bot: cr
next prev parent reply other threads:[~2026-07-23 16:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-20 9:08 [PATCH] tls: don't abort the connection on signal-interrupted sends Maximilian Immanuel Brandtner
2026-07-23 16:26 ` Jakub Kicinski [this message]
2026-07-23 18:38 ` Maximilian Immanuel Brandtner
2026-07-23 18:44 ` Jakub Kicinski
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=20260723092630.1a1c9b4e@kernel.org \
--to=kuba@kernel.org \
--cc=bcodding@redhat.com \
--cc=brueckner@linux.ibm.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=john.fastabend@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maxbr@linux.ibm.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sd@queasysnail.net \
--cc=svens@linux.ibm.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