🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
6 messages
6 total messages Started by Anil Kaushik Mon, 02 Nov 2026 12:09
[PATCH net] netlink: Do not call the unbind callback with the table locked
#9625
Author: Anil Kaushik
Date: Mon, 02 Nov 2026 12:09
44 lines
12440 bytes
When netlink_bind() fails to insert the socket, it calls
netlink_undo_bind() with the table locked. genl_unbind() then takes
cb_lock, while genl_unregister_family() and genl_register_family() take
cb_lock for writing and then wait in netlink_table_grab() for the table
users to go away:

  netlink_bind()                 genl_unregister_family()
    netlink_lock_table()           down_write(&cb_lock)
    netlink_insert() fails
    netlink_undo_bind()            netlink_table_grab()
      genl_unbind()                  waits for nl_table_users == 0
        down_read(&cb_lock)

An unprivileged user can get here by binding to a port ID that is in
use, with nl_groups set. Lockdep does not see it, as nl_table_users is a
plain counter.

Unlock the table first, as the comment in netlink_release() asks for.

Link: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261101101347.3910654-1-anilkaushikwireless@gmail.com
Fixes: 3de21a8990d3 ("genetlink: Add per family bind/unbind callbacks")
Signed-off-by: Anil Kaushik <anilkaushikwireless@gmail.com>
---
 net/netlink/af_netlink.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index fec2879c497d..666a0ba03ca1 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -1047,8 +1047,9 @@ static int netlink_bind(struct socket *sock, struct sockaddr_unsized *addr,
 			netlink_insert(sk, nladdr->nl_pid) :
 			netlink_autobind(sock);
 		if (err) {
+			netlink_unlock_table();
 			netlink_undo_bind(BITS_PER_TYPE(u32), groups, sk);
-			goto unlock;
+			return err;
 		}
 	}
 
-- 
2.25.1
Re: [PATCH net] netlink: Do not call the unbind callback with the table locked
#9616
Author: netdev-bot+sinfo
Date: Mon, 02 Nov 2026 12:13
18 lines
8541 bytes
Hi!

This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:

 - Whether the issue was actually triggered, or is only theoretical
   (e.g. found by code inspection). If it was triggered please include
   the symptoms, like the stack trace or error messages.

Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account. If the series needs another revision for
other reasons, please include the information in the commit messages
then.

The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
Re: [PATCH net] netlink: Do not call the unbind callback with the table locked
#9620
Author: Anil Kaushik
Date: Mon, 02 Nov 2026 12:53
27 lines
12917 bytes
On Mon, Nov 2, 2026 at 5:43 PM <netdev-bot+sinfo@kernel.org> wrote:
>
> Hi!
>
> This is an automated message. This series looks like a fix, but its
> commit messages seem to be missing some information:
>
>  - Whether the issue was actually triggered, or is only theoretical
>    (e.g. found by code inspection). If it was triggered please include
>    the symptoms, like the stack trace or error messages.
>
> Please do not repost the series just to address the above. Instead,
> reply to this email with the missing information, so that reviewers
> can take it into account. If the series needs another revision for
> other reasons, please include the information in the commit messages
> then.
>
> The evaluation is done by an LLM so it may be wrong, if you think
> that is the case please reply and explain.

Found by Sashiko, not seen in production. I triggered the hang in a
VM, with a test-only msleep() to widen the window. It does not hang
with this patch.

Regards
Anil
Re: [PATCH net] netlink: Do not call the unbind callback with the table locked
#9686
Author: Anil Kaushik
Date: Mon, 02 Nov 2026 14:35
35 lines
13264 bytes
Sorry , missed adding Stanislaw and Jiri

Anil

On Mon, Nov 2, 2026 at 6:23 PM Anil Kaushik
<anilkaushikwireless@gmail.com> wrote:
>
> On Mon, Nov 2, 2026 at 5:43 PM <netdev-bot+sinfo@kernel.org> wrote:
> >
> > Hi!
> >
> > This is an automated message. This series looks like a fix, but its
> > commit messages seem to be missing some information:
> >
> >  - Whether the issue was actually triggered, or is only theoretical
> >    (e.g. found by code inspection). If it was triggered please include
> >    the symptoms, like the stack trace or error messages.
> >
> > Please do not repost the series just to address the above. Instead,
> > reply to this email with the missing information, so that reviewers
> > can take it into account. If the series needs another revision for
> > other reasons, please include the information in the commit messages
> > then.
> >
> > The evaluation is done by an LLM so it may be wrong, if you think
> > that is the case please reply and explain.
>
> Found by Sashiko, not seen in production. I triggered the hang in a
> VM, with a test-only msleep() to widen the window. It does not hang
> with this patch.
>
> Regards
> Anil
Re: [PATCH net] netlink: Do not call the unbind callback with the table locked
#12078
Author: Simon Horman
Date: Fri, 06 Nov 2026 08:30
26 lines
8910 bytes
On Mon, Nov 02, 2026 at 12:09:29PM +0000, Anil Kaushik wrote:
> When netlink_bind() fails to insert the socket, it calls
> netlink_undo_bind() with the table locked. genl_unbind() then takes
> cb_lock, while genl_unregister_family() and genl_register_family() take
> cb_lock for writing and then wait in netlink_table_grab() for the table
> users to go away:
> 
>   netlink_bind()                 genl_unregister_family()
>     netlink_lock_table()           down_write(&cb_lock)
>     netlink_insert() fails
>     netlink_undo_bind()            netlink_table_grab()
>       genl_unbind()                  waits for nl_table_users == 0
>         down_read(&cb_lock)
> 
> An unprivileged user can get here by binding to a port ID that is in
> use, with nl_groups set. Lockdep does not see it, as nl_table_users is a
> plain counter.
> 
> Unlock the table first, as the comment in netlink_release() asks for.
> 
> Link: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261101101347.3910654-1-anilkaushikwireless@gmail.com
> Fixes: 3de21a8990d3 ("genetlink: Add per family bind/unbind callbacks")
> Signed-off-by: Anil Kaushik <anilkaushikwireless@gmail.com>

Reviewed-by: Simon Horman <horms@kernel.org>
Re: [PATCH net] netlink: Do not call the unbind callback with the table locked
#12312
Author: patchwork-bot+netdevbpf
Date: Fri, 06 Nov 2026 21:00
30 lines
8905 bytes
Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Mon,  2 Nov 2026 12:09:29 +0000 you wrote:
> When netlink_bind() fails to insert the socket, it calls
> netlink_undo_bind() with the table locked. genl_unbind() then takes
> cb_lock, while genl_unregister_family() and genl_register_family() take
> cb_lock for writing and then wait in netlink_table_grab() for the table
> users to go away:
> 
>   netlink_bind()                 genl_unregister_family()
>     netlink_lock_table()           down_write(&cb_lock)
>     netlink_insert() fails
>     netlink_undo_bind()            netlink_table_grab()
>       genl_unbind()                  waits for nl_table_users == 0
>         down_read(&cb_lock)
> 
> [...]

Here is the summary with links:
  - [net] netlink: Do not call the unbind callback with the table locked
    https://git.kernel.org/netdev/net/c/a36b9e205cb3

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads