diff options
author | Jakub Kicinski <kuba@kernel.org> | 2022-12-15 20:41:22 -0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2022-12-31 13:32:55 +0100 |
commit | ce321a1cd66beba6bdfda4136b34ff19e8716a53 (patch) | |
tree | b42672a93b1986e3eddf801ab968781fade8213b /net/core | |
parent | 2838f0736cf0df0890726de19527b872377bf2d4 (diff) | |
download | linux-stable-ce321a1cd66beba6bdfda4136b34ff19e8716a53.tar.gz linux-stable-ce321a1cd66beba6bdfda4136b34ff19e8716a53.tar.bz2 linux-stable-ce321a1cd66beba6bdfda4136b34ff19e8716a53.zip |
devlink: protect devlink dump by the instance lock
[ Upstream commit 214964a13ab56a9757d146b79b468a7ca190fbfb ]
Take the instance lock around devlink_nl_fill() when dumping,
doit takes it already.
We are only dumping basic info so in the worst case we were risking
data races around the reload statistics. Until the big devlink mutex
was removed all relevant code was protected by it, so the missing
instance lock was not exposed.
Fixes: d3efc2a6a6d8 ("net: devlink: remove devlink_mutex")
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Link: https://lore.kernel.org/r/20221216044122.1863550-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/devlink.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/net/core/devlink.c b/net/core/devlink.c index e8f1af4231db..2aa77d4b80d0 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -1505,10 +1505,13 @@ static int devlink_nl_cmd_get_dumpit(struct sk_buff *msg, continue; } + devl_lock(devlink); err = devlink_nl_fill(msg, devlink, DEVLINK_CMD_NEW, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq, NLM_F_MULTI); + devl_unlock(devlink); devlink_put(devlink); + if (err) goto out; idx++; |