netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kuniyuki Iwashima <kuniyu@amazon.com>
To: <kuba@kernel.org>
Cc: <davem@davemloft.net>, <edumazet@google.com>,
	<johannes@sipsolutions.net>, <netdev@vger.kernel.org>,
	<pabeni@redhat.com>, <pablo@netfilter.org>,
	<syzkaller@googlegroups.com>, <kuniyu@amazon.com>
Subject: Re: [PATCH net 1/2] netlink: terminate outstanding dump on socket close
Date: Mon, 4 Nov 2024 21:31:15 -0800	[thread overview]
Message-ID: <20241105053115.59273-1-kuniyu@amazon.com> (raw)
In-Reply-To: <20241105010347.2079981-1-kuba@kernel.org>

From: Jakub Kicinski <kuba@kernel.org>
Date: Mon,  4 Nov 2024 17:03:46 -0800
> Netlink supports iterative dumping of data. It provides the families
> the following ops:
>  - start - (optional) kicks off the dumping process
>  - dump  - actual dump helper, keeps getting called until it returns 0
>  - done  - (optional) pairs with .start, can be used for cleanup
> The whole process is asynchronous and the repeated calls to .dump
> don't actually happen in a tight loop, but rather are triggered
> in response to recvmsg() on the socket.
> 
> This gives the user full control over the dump, but also means that
> the user can close the socket without getting to the end of the dump.
> To make sure .start is always paired with .done we check if there
> is an ongoing dump before freeing the socket, and if so call .done.
> 
> The complication is that sockets can get freed from BH and .done
> is allowed to sleep. So we use a workqueue to defer the call, when
> needed.
> 
> Unfortunately this does not work correctly. What we defer is not
> the cleanup but rather releasing a reference on the socket.
> We have no guarantee that we own the last reference, if someone
> else holds the socket they may release it in BH and we're back
> to square one.
> 
> The whole dance, however, appears to be unnecessary. Only the user
> can interact with dumps, so we can clean up when socket is closed.
> And close always happens in process context. Some async code may
> still access the socket after close, queue notification skbs to it etc.
> but no dumps can start, end or otherwise make progress.
> 
> Delete the workqueue and flush the dump state directly from the release
> handler. Note that further cleanup is possible in -next, for instance
> we now always call .done before releasing the main module reference,
> so dump doesn't have to take a reference of its own.

and we can remove netns & reftracker switching for kernel socket


> 
> Reported-by: syzbot <syzkaller@googlegroups.com>
> Fixes: ed5d7788a934 ("netlink: Do not schedule work from sk_destruct")

Do you have a link to a public report ?

Previously syzkaller's author asked me to use a different name for
Reported-by not to confuse their internal metrics if the report is
generated by local syzkaller.

  Reported-by: syzkaller <syzkaller@googlegroups.com>


> Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Change itself looks good to me

Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>

  parent reply	other threads:[~2024-11-05  5:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-05  1:03 [PATCH net 1/2] netlink: terminate outstanding dump on socket close Jakub Kicinski
2024-11-05  1:03 ` [PATCH net 2/2] selftests: net: add a test for closing a netlink socket ith dump in progress Jakub Kicinski
2024-11-05  6:21   ` Kuniyuki Iwashima
2024-11-05  5:31 ` Kuniyuki Iwashima [this message]
2024-11-05 10:03   ` [PATCH net 1/2] netlink: terminate outstanding dump on socket close Eric Dumazet
2024-11-05 19:42   ` 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=20241105053115.59273-1-kuniyu@amazon.com \
    --to=kuniyu@amazon.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=johannes@sipsolutions.net \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pablo@netfilter.org \
    --cc=syzkaller@googlegroups.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).