* [PATCH] netlink: Fix off-by-one error in netlink_proto_init()
@ 2024-11-03 13:15 Markus Elfring
2024-11-03 17:31 ` Kuniyuki Iwashima
0 siblings, 1 reply; 3+ messages in thread
From: Markus Elfring @ 2024-11-03 13:15 UTC (permalink / raw)
To: netdev, David S. Miller, Eric Dumazet, Jakub Kicinski,
Jiri Pirko, Juntong Deng, Kuniyuki Iwashima, Nikolay Aleksandrov,
Paolo Abeni, Simon Horman, Thomas Graf, Zhengchao Shao
Cc: LKML, kernel-janitors, Jinjie Ruan, Nikolay Aleksandrov
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 3 Nov 2024 14:01:26 +0100
Hash tables should be properly destroyed after a rhashtable_init() call
failed in this function implementation.
The corresponding exception handling was incomplete because of
a questionable condition check.
Thus use the comparison operator “>=” instead for the affected while loop.
This issue was transformed by using the Coccinelle software.
Fixes: e341694e3eb5 ("netlink: Convert netlink_lookup() to use RCU protected hash table")
Cc: stable@vger.kernel.org
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
net/netlink/af_netlink.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 0a9287fadb47..9601b85dda95 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -2936,7 +2936,7 @@ static int __init netlink_proto_init(void)
for (i = 0; i < MAX_LINKS; i++) {
if (rhashtable_init(&nl_table[i].hash,
&netlink_rhashtable_params) < 0) {
- while (--i > 0)
+ while (--i >= 0)
rhashtable_destroy(&nl_table[i].hash);
kfree(nl_table);
goto panic;
--
2.47.0
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] netlink: Fix off-by-one error in netlink_proto_init()
2024-11-03 13:15 [PATCH] netlink: Fix off-by-one error in netlink_proto_init() Markus Elfring
@ 2024-11-03 17:31 ` Kuniyuki Iwashima
2024-11-04 7:38 ` Markus Elfring
0 siblings, 1 reply; 3+ messages in thread
From: Kuniyuki Iwashima @ 2024-11-03 17:31 UTC (permalink / raw)
To: markus.elfring
Cc: davem, edumazet, horms, jiri, juntong.deng, kernel-janitors,
kuba, kuniyu, linux-kernel, netdev, nikolay, pabeni, razor,
ruanjinjie, shaozhengchao, tgraf
From: Markus Elfring <Markus.Elfring@web.de>
Date: Sun, 3 Nov 2024 14:15:18 +0100
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 3 Nov 2024 14:01:26 +0100
>
> Hash tables should be properly destroyed after a rhashtable_init() call
> failed in this function implementation.
> The corresponding exception handling was incomplete because of
> a questionable condition check.
> Thus use the comparison operator “>=” instead for the affected while loop.
This patch is already applied to net-next.
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/commit/?id=bc74d329ceba
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: netlink: Fix off-by-one error in netlink_proto_init()
2024-11-03 17:31 ` Kuniyuki Iwashima
@ 2024-11-04 7:38 ` Markus Elfring
0 siblings, 0 replies; 3+ messages in thread
From: Markus Elfring @ 2024-11-04 7:38 UTC (permalink / raw)
To: Kuniyuki Iwashima, netdev
Cc: kernel-janitors, LKML, David S. Miller, Eric Dumazet,
Jakub Kicinski, Jinjie Ruan, Jiri Pirko, Juntong Deng,
Nikolay Aleksandrov, Paolo Abeni, Simon Horman, Thomas Graf
…
>> Thus use the comparison operator “>=” instead for the affected while loop.
>
> This patch is already applied to net-next.
> https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/commit/?id=bc74d329ceba
Thanks for your reminder on the commit bc74d329ceba23f998ead4f716266da5afe319f7
("netlink: Remove the dead code in netlink_proto_init()") from 2024-10-31
for another contribution by Jinjie Ruan (also according to your suggestion).
See also:
https://lore.kernel.org/linux-kernel/20241028182421.6692-1-kuniyu@amazon.com/
https://lore.kernel.org/linux-kernel/20241030012147.357400-1-ruanjinjie@huawei.com/
Regards,
Markus
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-11-04 7:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-03 13:15 [PATCH] netlink: Fix off-by-one error in netlink_proto_init() Markus Elfring
2024-11-03 17:31 ` Kuniyuki Iwashima
2024-11-04 7:38 ` Markus Elfring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®