Fix rcu_read_lock issues in netdev-genl
Subsystems (3)
v2 cover Fix rcu_read_lock issues in netdev-genl
Greetings:
Paolo reported a splat [1] when running the new selftest for busy poll. I confirmed and reproduced this splat locally.
This series proposes 2 patches:
- Patch 1:
- Fixes a similar issue in an older commit and CCs stable as this fix could be backported.
- Patch 2:
- Fixes the issue Paolo hit while running the selftest
I retested locally after applying this series and confirmed that the splat is fixed.
Thanks,
Joe
[1]: https://lore.kernel.org/netdev/[email protected]/
v2:
- Removed the helper and simplified to just add a rcu_read_lock / unlock in both patches instead.
rfc: https://lore.kernel.org/lkml/[email protected]/
Joe Damato (2):
netdev-genl: Hold rcu_read_lock in napi_get
netdev-genl: Hold rcu_read_lock in napi_set
net/core/netdev-genl.c | 4 ++++ 1 file changed, 4 insertions(+)
base-commit: a58f00ed24b849d449f7134fd5d86f07090fe2f5
Signature · 1 line
2.25.1
PATCH v2 1/2 netdev-genl: Hold rcu_read_lock in napi_get
Hold rcu_read_lock in netdev_nl_napi_get_doit, which calls napi_by_id and is required to be called under rcu_read_lock.
---
v2:
- Simplified by removing the helper and calling rcu_read_lock / unlock directly instead.
net/core/netdev-genl.c | 2 ++ 1 file changed, 2 insertions(+)
net/core/netdev-genl.c +2 -0
@@ -233,6 +233,7 @@ int netdev_nl_napi_get_doit(struct sk_buff *skb, struct genl_info *info)return -ENOMEM ;rtnl_lock (); +rcu_read_lock (); napi =napi_by_id (napi_id);if (napi) {
@@ -242,6 +243,7 @@ int netdev_nl_napi_get_doit(struct sk_buff *skb, struct genl_info *info) err = -ENOENT ; } +rcu_read_unlock ();rtnl_unlock ();if (err)
Signature · 1 line
2.25.1
PATCH v2 2/2 netdev-genl: Hold rcu_read_lock in napi_set
In reply to Joe DamatoHold rcu_read_lock during netdev_nl_napi_set_doit, which calls napi_by_id and requires rcu_read_lock to be held.
---
v2:
- Simplified by adding rcu_read_lock/unlock instead of using the helper proposed in the RFC.
net/core/netdev-genl.c | 2 ++ 1 file changed, 2 insertions(+)
net/core/netdev-genl.c +2 -0
@@ -348,6 +348,7 @@ int netdev_nl_napi_set_doit(struct sk_buff *skb, struct genl_info *info) napi_id =nla_get_u32 (info->attrs[NETDEV_A_NAPI_ID ]);rtnl_lock (); +rcu_read_lock (); napi =napi_by_id (napi_id);if (napi) {
@@ -357,6 +358,7 @@ int netdev_nl_napi_set_doit(struct sk_buff *skb, struct genl_info *info) err = -ENOENT ; } +rcu_read_unlock ();rtnl_unlock ();return err;
Signature · 1 line
2.25.1
Jakub Kicinski
maintainerQuoted 1 line · On Wed, 13 Nov 2024 02:17:50 +0000 Joe Damato wrote:
base-commit:
a58f00ed24b849d449f7134fd5d86f07090fe2f5
which is a net-next commit.. please rebase on net
Quoted 4 lines · Jakub Kicinski
Quoted 1 line · On Wed, 13 Nov 2024 02:17:50 +0000 Joe Damato wrote:
base-commit:
a58f00ed24b849d449f7134fd5d86f07090fe2f5which is a net-next commit.. please rebase on net
I thought I asked about this in the previous thread, but I probably wasn't clear with my question.
Let me try again:
Patch 1 will apply to net and is a fixes and CC's stable, and fixes a similar issue to the one Paolo reported, not the exact same path, though.
Patch 2 will not apply to net, because the code it fixes is not in net yet. This fixes the splat Paolo reported.
So... back to the question in the cover letter from the RFC :) I suppose the right thing to do is split the series:
- Rebase patch 1 on net (it applies as is) and send it on its own
- Send patch 2 on its own against net-next
Or... something else ?
Paolo Abeni
maintainerQuoted 18 lines · Joe Damato
Quoted 4 lines · Jakub Kicinski
Quoted 1 line · On Wed, 13 Nov 2024 02:17:50 +0000 Joe Damato wrote:
base-commit:
a58f00ed24b849d449f7134fd5d86f07090fe2f5which is a net-next commit.. please rebase on net
I thought I asked about this in the previous thread, but I probably wasn't clear with my question.
Let me try again:
Patch 1 will apply to net and is a fixes and CC's stable, and fixes a similar issue to the one Paolo reported, not the exact same path, though.
Patch 2 will not apply to net, because the code it fixes is not in net yet. This fixes the splat Paolo reported.
Quoted 7 lines
So... back to the question in the cover letter from the RFC :) I suppose the right thing to do is split the series:
- Rebase patch 1 on net (it applies as is) and send it on its own
- Send patch 2 on its own against net-nextOr... something else ?
I'm sorry for the late reply.
Please send the two patch separately, patch 1 targeting (and rebased on) net and patch 2 targeting (and based on) net-next.
Thanks!
Paolo
Quoted 27 lines · Paolo Abeni
Quoted 24 lines · Joe Damato
Quoted 4 lines · Jakub Kicinski
Quoted 1 line · On Wed, 13 Nov 2024 02:17:50 +0000 Joe Damato wrote:
base-commit:
a58f00ed24b849d449f7134fd5d86f07090fe2f5which is a net-next commit.. please rebase on net
I thought I asked about this in the previous thread, but I probably wasn't clear with my question.
Let me try again:
Patch 1 will apply to net and is a fixes and CC's stable, and fixes a similar issue to the one Paolo reported, not the exact same path, though.
Patch 2 will not apply to net, because the code it fixes is not in net yet. This fixes the splat Paolo reported.
So... back to the question in the cover letter from the RFC :) I suppose the right thing to do is split the series:
- Rebase patch 1 on net (it applies as is) and send it on its own
- Send patch 2 on its own against net-next
Quoted 7 lines
Quoted 1 line
Or... something else ?
I'm sorry for the late reply.
Please send the two patch separately, patch 1 targeting (and rebased on) net and patch 2 targeting (and based on) net-next.
OK, I've done that. I left the fixes tag on patch 2 despite it targeting net-next, but didn't CC stable since the code doesn't need to be backported.
Paolo Abeni
maintainerQuoted 7 lines · Joe Damato
Quoted 2 lines · Paolo Abeni
Please send the two patch separately, patch 1 targeting (and rebased on) net and patch 2 targeting (and based on) net-next.
OK, I've done that. I left the fixes tag on patch 2 despite it targeting net-next, but didn't CC stable since the code doesn't need to be backported.
Thanks! FTR the above was the right thing to do.
/P
Jakub Kicinski
maintainerQuoted 2 lines · On Wed, 13 Nov 2024 22:29:50 -0800 Joe Damato wrote:
- Rebase patch 1 on net (it applies as is) and send it on its own
- Send patch 2 on its own against net-next
My bad, I thought patch 2 is also needed in net, but not in stable.
Quoted 5 lines · Jakub Kicinski
Quoted 2 lines · On Wed, 13 Nov 2024 22:29:50 -0800 Joe Damato wrote:
- Rebase patch 1 on net (it applies as is) and send it on its own
- Send patch 2 on its own against net-nextMy bad, I thought patch 2 is also needed in net, but not in stable.
No problem; sorry for the noob confusing on my side. Hopefully, I got it right for the v3.