]> git.baikalelectronics.ru Git - kernel.git/commit
genetlink: fix counting regression on ctrl_dumpfamily()
authorStanislaw Gruszka <sgruszka@redhat.com>
Wed, 22 Mar 2017 15:08:33 +0000 (16:08 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 22 Mar 2017 22:38:43 +0000 (15:38 -0700)
commit9c52f9d003e31390bcfbe48770614bc37a0a19b9
tree45076a17d569a552c96db9f823c2824d7ea4b656
parentfae74218da22487c9d5aa84a4e158895c52a95a4
genetlink: fix counting regression on ctrl_dumpfamily()

Commit 4182c6da5057 ("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 <xose.vazquez@gmail.com>
Cc: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Johannes Berg <johannes@sipsolutions.net>
Fixes: 4182c6da5057 ("genetlink: use idr to track families")
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Acked-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/netlink/genetlink.c