]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commit - net/netlink/genetlink.c
genetlink: fix counting regression on ctrl_dumpfamily()
authorStanislaw Gruszka <sgruszka@redhat.com>
Wed, 22 Mar 2017 15:08:33 +0000 (16:08 +0100)
committerTim Gardner <tim.gardner@canonical.com>
Thu, 30 Mar 2017 12:35:45 +0000 (06:35 -0600)
commit9b5a220a7aa18c48b711789ad15ffdef2ea0004c
treeac6ec9722e38859c6a001393271ae359442c7797
parentc9e96ed4a460196862c5eb532bbbfd2291357f22
genetlink: fix counting regression on ctrl_dumpfamily()

BugLink: http://bugs.launchpad.net/bugs/1677589
[ Upstream commit 1d2a6a5e4bf2921531071fcff8538623dce74efa ]

Commit 2ae0f17df1cd ("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: 2ae0f17df1cd ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
net/netlink/genetlink.c