|
|
c73017e |
From: Stanislaw Gruszka <sgruszka@redhat.com>
|
|
|
c73017e |
Date: 2017-03-22 15:08:33
|
|
|
c73017e |
Subject: [PATCH 4.11] genetlink: fix counting regression on ctrl_dumpfamily()
|
|
|
c73017e |
|
|
|
c73017e |
Commit 2ae0f17df1cd ("genetlink: use idr to track families") replaced
|
|
|
c73017e |
|
|
|
c73017e |
if (++n < fams_to_skip)
|
|
|
c73017e |
continue;
|
|
|
c73017e |
into:
|
|
|
c73017e |
|
|
|
c73017e |
if (n++ < fams_to_skip)
|
|
|
c73017e |
continue;
|
|
|
c73017e |
|
|
|
c73017e |
This subtle change cause that on retry ctrl_dumpfamily() call we omit
|
|
|
c73017e |
one family that failed to do ctrl_fill_info() on previous call, because
|
|
|
c73017e |
cb->args[0] = n number counts also family that failed to do
|
|
|
c73017e |
ctrl_fill_info().
|
|
|
c73017e |
|
|
|
c73017e |
Patch fixes the problem and avoid confusion in the future just decrease
|
|
|
c73017e |
n counter when ctrl_fill_info() fail.
|
|
|
c73017e |
|
|
|
c73017e |
User visible problem caused by this bug is failure to get access to
|
|
|
c73017e |
some genetlink family i.e. nl80211. However problem is reproducible
|
|
|
c73017e |
only if number of registered genetlink families is big enough to
|
|
|
c73017e |
cause second call of ctrl_dumpfamily().
|
|
|
c73017e |
|
|
|
c73017e |
Cc: Xose Vazquez Perez <xose.vazquez@gmail.com>
|
|
|
c73017e |
Cc: Larry Finger <Larry.Finger@lwfinger.net>
|
|
|
c73017e |
Cc: Johannes Berg <johannes@sipsolutions.net>
|
|
|
c73017e |
Fixes: 2ae0f17df1cd ("genetlink: use idr to track families")
|
|
|
c73017e |
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
|
|
|
c73017e |
---
|
|
|
c73017e |
Dave, please also target this for 4.10+ -stable.
|
|
|
c73017e |
|
|
|
c73017e |
net/netlink/genetlink.c | 4 +++-
|
|
|
c73017e |
1 files changed, 3 insertions(+), 1 deletions(-)
|
|
|
c73017e |
|
|
|
c73017e |
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
|
|
|
c73017e |
index fb6e10f..92e0981 100644
|
|
|
c73017e |
--- a/net/netlink/genetlink.c
|
|
|
c73017e |
+++ b/net/netlink/genetlink.c
|
|
|
c73017e |
@@ -783,8 +783,10 @@ static int ctrl_dumpfamily(struct sk_buff *skb, struct netlink_callback *cb)
|
|
|
c73017e |
|
|
|
c73017e |
if (ctrl_fill_info(rt, NETLINK_CB(cb->skb).portid,
|
|
|
c73017e |
cb->nlh->nlmsg_seq, NLM_F_MULTI,
|
|
|
c73017e |
- skb, CTRL_CMD_NEWFAMILY) < 0)
|
|
|
c73017e |
+ skb, CTRL_CMD_NEWFAMILY) < 0) {
|
|
|
c73017e |
+ n--;
|
|
|
c73017e |
break;
|
|
|
c73017e |
+ }
|
|
|
c73017e |
}
|
|
|
c73017e |
|
|
|
c73017e |
cb->args[0] = n;
|
|
|
c73017e |
--
|
|
|
c73017e |
1.7.1
|