Skip to contentSkip to conversation

tipc: call start and done ops directly in __tipc_nl_compat_dumpit()

PATCH In review Cong Wang 1 participant 2 messages Sep 4, 2018

Subsystems (3)
lore
Share & tools
lore

Cong Wang

author
#0 lore raw

PATCH 1/1 tipc: call start and done ops directly in __tipc_nl_compat_dumpit()

__tipc_nl_compat_dumpit() uses a netlink_callback on stack, so the only way to align it with other ->dumpit() call path is calling tipc_dump_start() and tipc_dump_done() directly inside it. Otherwise ->dumpit() would always get NULL from cb->args[0].

Fixes 9a07efa9aea2 ("tipc: switch to rhashtable iterator")
Reported-by [email protected]
Cc Jon Maloy <[email protected]>
Cc Ying Xue <[email protected]>
---
 net/tipc/netlink_compat.c | 2 ++
 1 file changed, 2 insertions(+)
net/tipc/netlink_compat.c +2 -0
index a2f76743c73a..aa05934613f2 100644
@@ -185,6 +185,7 @@ static int __tipc_nl_compat_dumpit(struct tipc_nl_compat_cmd_dump *cmd,
 		return -ENOMEM;
 
 	buf->sk = msg->dst_sk;
+	tipc_dump_start(&cb);
 
 	do {
 		int rem;
@@ -216,6 +217,7 @@ static int __tipc_nl_compat_dumpit(struct tipc_nl_compat_cmd_dump *cmd,
 	err = 0;
 
 err_out:
+	tipc_dump_done(&cb);
 	kfree_skb(buf);
 
 	if (err == -EMSGSIZE) {
Signature · 1 line
2.14.4
author
#1 lore raw
Quoted 21 lines · Cong Wang

__tipc_nl_compat_dumpit() uses a netlink_callback on stack, so the only way to align it with other ->dumpit() call path is calling tipc_dump_start() and tipc_dump_done() directly inside it. Otherwise ->dumpit() would always get NULL from cb->args[0].

Fixes 9a07efa9aea2 ("tipc: switch to rhashtable iterator")
Reported-by [email protected]
Cc Jon Maloy <[email protected]>
Cc Ying Xue <[email protected]>
---
 net/tipc/netlink_compat.c | 2 ++
 1 file changed, 2 insertions(+)
net/tipc/netlink_compat.c +0 -0
index a2f76743c73a..aa05934613f2 100644

net/tipc/netlink_compat.c static int __tipc_nl_compat_dumpit(struct tipc_nl_compat_cmd_dump *cmd, · line 188

Quoted 4 lines
net/tipc/netlink_compat.c +1 -0
@@ -185,6 +185,7 @@ static int __tipc_nl_compat_dumpit(struct tipc_nl_compat_cmd_dump *cmd,
                return -ENOMEM;
 
        buf->sk = msg->dst_sk;
+       tipc_dump_start(&cb);

Well, tipc_dump_start() uses sock_net(cb->skb->sk) which seems not set here... I need to pass msg->dst_sk in.

I will send v2.