netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	"David S . Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Jens Axboe <axboe@kernel.dk>,
	kernel@pengutronix.de
Subject: Re: [PATCH] net: Do not break out of sk_stream_wait_memory() with TIF_NOTIFY_SIGNAL
Date: Thu, 26 Oct 2023 09:03:10 +0200	[thread overview]
Message-ID: <20231026070310.GY3359458@pengutronix.de> (raw)
In-Reply-To: <addf492843338e853f7fda683ce35050f26c9da0.camel@redhat.com>

On Tue, Oct 24, 2023 at 03:56:17PM +0200, Paolo Abeni wrote:
> On Mon, 2023-10-23 at 14:13 +0200, Sascha Hauer wrote:
> > It can happen that a socket sends the remaining data at close() time.
> > With io_uring and KTLS it can happen that sk_stream_wait_memory() bails
> > out with -512 (-ERESTARTSYS) because TIF_NOTIFY_SIGNAL is set for the
> > current task. This flag has been set in io_req_normal_work_add() by
> > calling task_work_add().
> > 
> > It seems signal_pending() is too broad, so this patch replaces it with
> > task_sigpending(), thus ignoring the TIF_NOTIFY_SIGNAL flag.
> 
> This looks dangerous, at best. Other possible legit users setting
> TIF_NOTIFY_SIGNAL will be broken.
> 
> Can't you instead clear TIF_NOTIFY_SIGNAL in io_run_task_work() ?

I don't have an idea how io_run_task_work() comes into play here, but it
seems it already clears TIF_NOTIFY_SIGNAL:

static inline int io_run_task_work(void)
{
        /*
         * Always check-and-clear the task_work notification signal. With how
         * signaling works for task_work, we can find it set with nothing to
         * run. We need to clear it for that case, like get_signal() does.
         */
        if (test_thread_flag(TIF_NOTIFY_SIGNAL))
                clear_notify_signal();
	...
}

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

  reply	other threads:[~2023-10-26  7:03 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-23 12:13 [PATCH] net: Do not break out of sk_stream_wait_memory() with TIF_NOTIFY_SIGNAL Sascha Hauer
2023-10-24 13:56 ` Paolo Abeni
2023-10-26  7:03   ` Sascha Hauer [this message]
2023-10-26  8:49     ` Paolo Abeni
2023-10-27 12:04       ` Sascha Hauer
2023-11-17 10:43         ` Marc Kleine-Budde
2023-12-19 11:00           ` Steffen Trumtrar
2023-12-19 13:13             ` Paolo Abeni
2024-03-15 10:01 Sascha Hauer
2024-03-15 16:43 ` Jens Axboe
2024-03-15 17:02 ` Pavel Begunkov
2024-03-18 12:10   ` Sascha Hauer
2024-03-18 13:19     ` Pavel Begunkov
2024-03-19 10:50       ` Sascha Hauer
2024-03-19 13:55         ` Pavel Begunkov
2024-03-19 15:08           ` Sascha Hauer
2024-03-18 12:03 ` Sascha Hauer
2024-03-19 12:30   ` Paolo Abeni

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=20231026070310.GY3359458@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=axboe@kernel.dk \
    --cc=davem@davemloft.net \
    --cc=kernel@pengutronix.de \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).