genetlink: fix potencial use-after-free and null-ptr-deref in genl_dumpit()
Subsystems (2)
PATCH 1/1 genetlink: fix potencial use-after-free and null-ptr-deref in genl_dumpit()
From: Vasiliy Kovalev <[email protected]>
The pernet operations structure for the subsystem must be registered before registering the generic netlink family.
--- net/netlink/genetlink.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
net/netlink/genetlink.c +6 -4
@@ -1879,14 +1879,16 @@ static int __init genl_init(void) {int err; - err =genl_register_family (&genl_ctrl); -if (err <0 ) - goto problem; - err =register_pernet_subsys (&genl_pernet_ops);if (err) goto problem; + err =genl_register_family (&genl_ctrl); +if (err <0 ) { +unregister_pernet_subsys (&genl_pernet_ops); + goto problem; + } +return 0 ; problem:
Signature · 1 line
2.33.8
Simon Horman
reviewer+ Jiri Pirko <[email protected]>
David Lebrun <[email protected]>
Quoted 6 lines · On Thu, Feb 15, 2024 at 11:23:09PM +0300, [email protected] wrote:
From: Vasiliy Kovalev <[email protected]>
The pernet operations structure for the subsystem must be registered before registering the generic netlink family.
Fixes 134e63756d5f ("genetlink: make netns aware")
Hi Vasiliy,
A Fixes tag implies that this is a bug fix.
So I think some explanation is warranted of what, user-visible, problem this resolves.
In that case the patch should be targeted at net.
Which means it should be based on that tree and have a net annotation in the subject
Subject: [PATCH net] ...
Alternatively, the Fixes tag should be dropped and some explanation should be provided of why the structure needs to be registered before the family.
In this case, if you wish to refer to the patch where the problem (but not bug) was introduced you can use something like the following. It is just the Fixes tag that has a special meaning.
Introduced in 134e63756d5f ("genetlink: make netns aware")
I think the above comments also apply to:
- [PATCH] ipv6: sr: fix possible use-after-free and null-ptr-deref
https://lore.kernel.org/all/[email protected]/
- [PATCH] devlink: fix possible use-after-free and memory leaks in devlink_init()
https://lore.kernel.org/all/[email protected]/
And as these patches seem to try to fix the same problem in different places, all under Networking, I would suggest that if you do repost, they are combined into a patch series (3 patches in the same series).
But I do wonder, how such an apparently fundamental problem has been present for so long in what I assume to be well exercised code.
Also, potential is misspelt in the subject of this patch.
Quoted 15 lines
Signed-off-by Vasiliy Kovalev <[email protected]>--- net/netlink/genetlink.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)net/netlink/genetlink.c +0
-2@@ -1879,14 +1879,16 @@ static int __init genl_init(void) {int err; - err =genl_register_family (&genl_ctrl); -if (err <0 )
net/netlink/genetlink.c static int __init genl_init(void) · line 1889
Quoted 10 lines
net/netlink/genetlink.c +4
-2- goto problem; - err =register_pernet_subsys (&genl_pernet_ops);if (err) goto problem; + err =genl_register_family (&genl_ctrl); +if (err <0 ) { +unregister_pernet_subsys (&genl_pernet_ops); + goto problem;
The problem label calls panic().
As noted elsewhere [1] there is no expectation of recovering from panic(), so there is no need to clean up here.
[1] https://lore.kernel.org/all/CANn89i+TNVtk8UT1+2QeeKHR-b6AQoopdxpcqcbNVOp9+JYSYw@mail.gmail.com/
Quoted 9 lines
net/netlink/genetlink.c +2
-0+ } +return 0 ; problem:Signature · 1 line
2.33.8
Signature · 1 line
pw-bot: changes-requested
+ Pablo Neira Ayuso <[email protected]>
Quoted 40 lines · Simon Horman
+ Jiri Pirko <[email protected]>
David Lebrun <[email protected]>Quoted 6 lines · On Thu, Feb 15, 2024 at 11:23:09PM +0300, [email protected] wrote:
From: Vasiliy Kovalev <[email protected]>
The pernet operations structure for the subsystem must be registered before registering the generic netlink family.
Fixes 134e63756d5f ("genetlink: make netns aware")Hi Vasiliy,
A Fixes tag implies that this is a bug fix.
So I think some explanation is warranted of what, user-visible, problem this resolves.In that case the patch should be targeted at net.
Which means it should be based on that tree and have a net annotation in the subjectSubject: [PATCH net] ...
Alternatively, the Fixes tag should be dropped and some explanation should be provided of why the structure needs to be registered before the family.
In this case, if you wish to refer to the patch where the problem (but not bug) was introduced you can use something like the following. It is just the Fixes tag that has a special meaning.
Introduced in
134e63756d5f("genetlink: make netns aware")I think the above comments also apply to:
- [PATCH] ipv6: sr: fix possible use-after-free and null-ptr-deref
https://lore.kernel.org/all/[email protected]/- [PATCH] devlink: fix possible use-after-free and memory leaks in
devlink_init()
https://lore.kernel.org/all/[email protected]/
Quoted 6 lines
And as these patches seem to try to fix the same problem in different places, all under Networking, I would suggest that if you do repost, they are combined into a patch series (3 patches in the same series).
But I do wonder, how such an apparently fundamental problem has been present for so long in what I assume to be well exercised code.
Hi Simon,
The history of these changes began with the crash fix in the gtp module [1]
A solution to the problem was found [2] and Pablo Neruda Ayuso suggested fixing similar
sections of code if they might have the same problem.
I have sent patches, but do not have reproducers, relying on drawing attention to the problem.
[1] https://lore.kernel.org/lkml/[email protected]/T/
[2] https://lore.kernel.org/netdev/[email protected]/T/#u
Signature · 2 lines
Thanks, Vasiliy Kovalev
Simon Horman
reviewerQuoted 54 lines · On Mon, Feb 19, 2024 at 03:15:52PM +0300, [email protected] wrote:
+ Pablo Neira Ayuso <[email protected]>
Quoted 40 lines · Simon Horman
+ Jiri Pirko <[email protected]>
David Lebrun <[email protected]>Quoted 6 lines · On Thu, Feb 15, 2024 at 11:23:09PM +0300, [email protected] wrote:
From: Vasiliy Kovalev <[email protected]>
The pernet operations structure for the subsystem must be registered before registering the generic netlink family.
Fixes 134e63756d5f ("genetlink: make netns aware")Hi Vasiliy,
A Fixes tag implies that this is a bug fix.
So I think some explanation is warranted of what, user-visible, problem this resolves.In that case the patch should be targeted at net.
Which means it should be based on that tree and have a net annotation in the subjectSubject: [PATCH net] ...
Alternatively, the Fixes tag should be dropped and some explanation should be provided of why the structure needs to be registered before the family.
In this case, if you wish to refer to the patch where the problem (but not bug) was introduced you can use something like the following. It is just the Fixes tag that has a special meaning.
Introduced in
134e63756d5f("genetlink: make netns aware")I think the above comments also apply to:
- [PATCH] ipv6: sr: fix possible use-after-free and null-ptr-deref
https://lore.kernel.org/all/[email protected]/- [PATCH] devlink: fix possible use-after-free and memory leaks in
devlink_init()
https://lore.kernel.org/all/[email protected]/Quoted 6 lines
And as these patches seem to try to fix the same problem in different places, all under Networking, I would suggest that if you do repost, they are combined into a patch series (3 patches in the same series).
But I do wonder, how such an apparently fundamental problem has been present for so long in what I assume to be well exercised code.
Hi Simon,
The history of these changes began with the crash fix in the gtp module [1]
Quoted 7 lines
A solution to the problem was found [2] and Pablo Neruda Ayuso suggested fixing similar
sections of code if they might have the same problem.
I have sent patches, but do not have reproducers, relying on drawing attention to the problem.
Thanks Vasiliy,
I think it would be worth adding some text along those lines to the commit messages for the patches you have posted.
Quoted 11 lines
[1]
https://lore.kernel.org/lkml/[email protected]/T/[2] https://lore.kernel.org/netdev/[email protected]/T/#u
Signature · 2 lines
Thanks, Vasiliy Kovalev