Skip to contentSkip to conversation

tipc: fix infinite loop in __tipc_nl_compat_dumpit

PATCH Applied Helen Koike 3 participants 5 messages Jul 13 – Jul 21

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tipc: fix infinite loop in __tipc_nl_compat_dumpit

cmd->dumpit callback can return a negative errno, causing an infinite loop due to the while(len) condition. As the loop never terminates, genl_mutex is never released, and other tasks waiting on it starve in D state.

Check dumpit's return value, propagate it and jump to err_out on error.

Reported-by [email protected]
Fixes d0796d1ef63d ("tipc: convert legacy nl bearer dump to nl compat")

---

Tested locally using syzbot reproducer.

---
 net/tipc/netlink_compat.c | 4 ++++
 1 file changed, 4 insertions(+)
net/tipc/netlink_compat.c +4 -0
index 2a786c56c8c5..d9a4f94ea2d4 100644
@@ -221,6 +221,10 @@ static int __tipc_nl_compat_dumpit(struct tipc_nl_compat_cmd_dump *cmd,
 		int rem;
 
 		len = (*cmd->dumpit)(buf, &cb);
+		if (len < 0) {
+			err = len;
+			goto err_out;
+		}
 
 		nlmsg_for_each_msg(nlmsg, nlmsg_hdr(buf), len, rem) {
 			err = nlmsg_parse_deprecated(nlmsg, GENL_HDRLEN,
Signature · 1 line
2.54.0
#1 lore raw

(cc + Erik)

Quoted 33 lines · Helen Koike

cmd->dumpit callback can return a negative errno, causing an infinite loop due to the while(len) condition. As the loop never terminates, genl_mutex is never released, and other tasks waiting on it starve in D state.

Check dumpit's return value, propagate it and jump to err_out on error.

Reported-by [email protected]
Fixes d0796d1ef63d ("tipc: convert legacy nl bearer dump to nl compat")

---

Tested locally using syzbot reproducer.

---
  net/tipc/netlink_compat.c | 4 ++++
  1 file changed, 4 insertions(+)
net/tipc/netlink_compat.c +4 -0
index 2a786c56c8c5..d9a4f94ea2d4 100644
@@ -221,6 +221,10 @@ static int __tipc_nl_compat_dumpit(struct tipc_nl_compat_cmd_dump *cmd,
  		int rem;
 
  		len = (*cmd->dumpit)(buf, &cb);
+		if (len < 0) {
+			err = len;
+			goto err_out;
+		}
 
  		nlmsg_for_each_msg(nlmsg, nlmsg_hdr(buf), len, rem) {
  			err = nlmsg_parse_deprecated(nlmsg, GENL_HDRLEN,
maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Helen Koike
Quoted 34 lines

Subject: [PATCH net] tipc: fix infinite loop in __tipc_nl_compat_dumpit

cmd->dumpit callback can return a negative errno, causing an infinite loop due to the while(len) condition. As the loop never terminates, genl_mutex is never released, and other tasks waiting on it starve in D state.

Check dumpit's return value, propagate it and jump to err_out on error.

Reported-by [email protected]
Fixes d0796d1ef63d ("tipc: convert legacy nl bearer dump to nl compat")

---

Tested locally using syzbot reproducer.
---
net/tipc/netlink_compat.c | 4 ++++

1 file changed, 4 insertions(+)
net/tipc/netlink_compat.c index renamed from net/tipc/netlink_compat.c +0 -0

2a786c56c8c5..d9a4f94ea2d4 100644

net/tipc/netlink_compat.c +4 -0
@@ -221,6 +221,10 @@ static int __tipc_nl_compat_dumpit(struct
 tipc_nl_compat_cmd_dump *cmd,
 		int rem;
 
 		len = (*cmd->dumpit)(buf, &cb);
+		if (len < 0) {
+			err = len;
+			goto err_out;
+		}
 
 		nlmsg_for_each_msg(nlmsg, nlmsg_hdr(buf), len, rem) {
Quoted 4 lines

err = nlmsg_parse_deprecated(nlmsg, GENL_HDRLEN,
--
2.54.0

maintainer Reviewed-by on v1 1/1
#3 lore raw
In reply to Helen Koike
Quoted 34 lines

Subject: [PATCH net] tipc: fix infinite loop in __tipc_nl_compat_dumpit

cmd->dumpit callback can return a negative errno, causing an infinite loop due to the while(len) condition. As the loop never terminates, genl_mutex is never released, and other tasks waiting on it starve in D state.

Check dumpit's return value, propagate it and jump to err_out on error.

Reported-by [email protected]
Fixes d0796d1ef63d ("tipc: convert legacy nl bearer dump to nl compat")

---

Tested locally using syzbot reproducer.
---
net/tipc/netlink_compat.c | 4 ++++

1 file changed, 4 insertions(+)
net/tipc/netlink_compat.c index renamed from net/tipc/netlink_compat.c +0 -0

2a786c56c8c5..d9a4f94ea2d4 100644

net/tipc/netlink_compat.c +4 -0
@@ -221,6 +221,10 @@ static int __tipc_nl_compat_dumpit(struct
 tipc_nl_compat_cmd_dump *cmd,
 		int rem;
 
 		len = (*cmd->dumpit)(buf, &cb);
+		if (len < 0) {
+			err = len;
+			goto err_out;
+		}
 
 		nlmsg_for_each_msg(nlmsg, nlmsg_hdr(buf), len, rem) {
Quoted 4 lines

err = nlmsg_parse_deprecated(nlmsg, GENL_HDRLEN,
--
2.54.0

#4 lore raw
In reply to Helen Koike
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Mon, 13 Jul 2026 17:49:35 -0300 you wrote:

cmd->dumpit callback can return a negative errno, causing an infinite loop due to the while(len) condition. As the loop never terminates, genl_mutex is never released, and other tasks waiting on it starve in D state.

Check dumpit's return value, propagate it and jump to err_out on error.

[...]

Here is the summary with links:
- [net] tipc: fix infinite loop in __tipc_nl_compat_dumpit

    https://git.kernel.org/netdev/net/c/22f8aa35964e

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html