Skip to content

Commit 1d2a6a5

Browse files
Stanislaw Gruszkadavem330
authored andcommitted
genetlink: fix counting regression on ctrl_dumpfamily()
Commit 2ae0f17 ("genetlink: use idr to track families") replaced if (++n < fams_to_skip) continue; into: if (n++ < fams_to_skip) continue; This subtle change cause that on retry ctrl_dumpfamily() call we omit one family that failed to do ctrl_fill_info() on previous call, because cb->args[0] = n number counts also family that failed to do ctrl_fill_info(). Patch fixes the problem and avoid confusion in the future just decrease n counter when ctrl_fill_info() fail. User visible problem caused by this bug is failure to get access to some genetlink family i.e. nl80211. However problem is reproducible only if number of registered genetlink families is big enough to cause second call of ctrl_dumpfamily(). Cc: Xose Vazquez Perez <[email protected]> Cc: Larry Finger <[email protected]> Cc: Johannes Berg <[email protected]> Fixes: 2ae0f17 ("genetlink: use idr to track families") Signed-off-by: Stanislaw Gruszka <[email protected]> Acked-by: Johannes Berg <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a97e50c commit 1d2a6a5

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

net/netlink/genetlink.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,8 +783,10 @@ static int ctrl_dumpfamily(struct sk_buff *skb, struct netlink_callback *cb)
783783

784784
if (ctrl_fill_info(rt, NETLINK_CB(cb->skb).portid,
785785
cb->nlh->nlmsg_seq, NLM_F_MULTI,
786-
skb, CTRL_CMD_NEWFAMILY) < 0)
786+
skb, CTRL_CMD_NEWFAMILY) < 0) {
787+
n--;
787788
break;
789+
}
788790
}
789791

790792
cb->args[0] = n;

0 commit comments

Comments
 (0)