netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] netlink: Unset cb_running when terminating dump on release.
@ 2025-02-14  6:58 Siddh Raman Pant
  2025-02-15  1:06 ` Jakub Kicinski
  0 siblings, 1 reply; 4+ messages in thread
From: Siddh Raman Pant @ 2025-02-14  6:58 UTC (permalink / raw)
  To: Jakub Kicinski, Eric Dumazet, David S. Miller, Paolo Abeni
  Cc: netdev, linux-kernel

When we terminated the dump, the callback isn't running, so cb_running
should be set to false to be logically consistent.

Fixes: 1904fb9ebf91 ("netlink: terminate outstanding dump on socket close")
Fixes: 16b304f3404f ("netlink: Eliminate kmalloc in netlink dump operation.")
Signed-off-by: Siddh Raman Pant <siddh.raman.pant@oracle.com>
---
I found this by inspection and was thinking why it isn't being done. So
I thought I should ask by sending a patch.

 net/netlink/af_netlink.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 85311226183a..f8f13058a46e 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -771,6 +771,7 @@ static int netlink_release(struct socket *sock)
 			nlk->cb.done(&nlk->cb);
 		module_put(nlk->cb.module);
 		kfree_skb(nlk->cb.skb);
+		WRITE_ONCE(nlk->cb_running, false);
 	}
 
 	module_put(nlk->module);
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [RFC PATCH] netlink: Unset cb_running when terminating dump on release.
  2025-02-14  6:58 [RFC PATCH] netlink: Unset cb_running when terminating dump on release Siddh Raman Pant
@ 2025-02-15  1:06 ` Jakub Kicinski
  2025-02-15  9:40   ` [PATCH] " Siddh Raman Pant
  0 siblings, 1 reply; 4+ messages in thread
From: Jakub Kicinski @ 2025-02-15  1:06 UTC (permalink / raw)
  To: Siddh Raman Pant
  Cc: Eric Dumazet, David S. Miller, Paolo Abeni, netdev, linux-kernel

On Fri, 14 Feb 2025 12:28:49 +0530 Siddh Raman Pant wrote:
> When we terminated the dump, the callback isn't running, so cb_running
> should be set to false to be logically consistent.
> 
> Fixes: 1904fb9ebf91 ("netlink: terminate outstanding dump on socket close")
> Fixes: 16b304f3404f ("netlink: Eliminate kmalloc in netlink dump operation.")
> Signed-off-by: Siddh Raman Pant <siddh.raman.pant@oracle.com>
> ---
> I found this by inspection and was thinking why it isn't being done. So
> I thought I should ask by sending a patch.

I only see uses in places called by user space. So code which can't 
be run once we're in release.

You can send as a cleanup, if you want, but with more analysis in
the commit msg, and no fixes tags.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] netlink: Unset cb_running when terminating dump on release
  2025-02-15  1:06 ` Jakub Kicinski
@ 2025-02-15  9:40   ` Siddh Raman Pant
  2025-02-19  2:10     ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 4+ messages in thread
From: Siddh Raman Pant @ 2025-02-15  9:40 UTC (permalink / raw)
  To: kuba@kernel.org
  Cc: edumazet@google.com, davem@davemloft.net, netdev@vger.kernel.org,
	pabeni@redhat.com, linux-kernel@vger.kernel.org

[-- Attachment #1: Type: text/plain, Size: 1172 bytes --]

When we terminated the dump, the callback isn't running, so cb_running
should be set to false to be logically consistent.

cb_running signifies whether a dump is ongoing. It is set to true in
cb->start(), and is checked in netlink_dump() to be true initially.
After the dump, it is set to false in the same function.

When we terminate a dump before it ends (see 1904fb9ebf91 ("netlink:
terminate outstanding dump on socket close")), we do not unset the
boolean flag cb_running. This is wrong - since the dump is no longer
running (we terminated it), it must be set to false to convey the
correct state.

Signed-off-by: Siddh Raman Pant <siddh.raman.pant@oracle.com>
---
 net/netlink/af_netlink.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 85311226183a..f8f13058a46e 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -771,6 +771,7 @@ static int netlink_release(struct socket *sock)
 			nlk->cb.done(&nlk->cb);
 		module_put(nlk->cb.module);
 		kfree_skb(nlk->cb.skb);
+		WRITE_ONCE(nlk->cb_running, false);
 	}
 
 	module_put(nlk->module);
-- 
2.45.2

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] netlink: Unset cb_running when terminating dump on release
  2025-02-15  9:40   ` [PATCH] " Siddh Raman Pant
@ 2025-02-19  2:10     ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-02-19  2:10 UTC (permalink / raw)
  To: Siddh Raman Pant; +Cc: kuba, edumazet, davem, netdev, pabeni, linux-kernel

Hello:

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

On Sat, 15 Feb 2025 09:40:51 +0000 you wrote:
> When we terminated the dump, the callback isn't running, so cb_running
> should be set to false to be logically consistent.
> 
> cb_running signifies whether a dump is ongoing. It is set to true in
> cb->start(), and is checked in netlink_dump() to be true initially.
> After the dump, it is set to false in the same function.
> 
> [...]

Here is the summary with links:
  - netlink: Unset cb_running when terminating dump on release
    https://git.kernel.org/netdev/net-next/c/438989137acd

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



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-02-19  2:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-14  6:58 [RFC PATCH] netlink: Unset cb_running when terminating dump on release Siddh Raman Pant
2025-02-15  1:06 ` Jakub Kicinski
2025-02-15  9:40   ` [PATCH] " Siddh Raman Pant
2025-02-19  2:10     ` patchwork-bot+netdevbpf

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).