Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

devlink: protect devlink dump by the instance lock

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>

+3
+3
net/core/devlink.c
··· 1648 1648 continue; 1649 1649 } 1650 1650 1651 + devl_lock(devlink); 1651 1652 err = devlink_nl_fill(msg, devlink, DEVLINK_CMD_NEW, 1652 1653 NETLINK_CB(cb->skb).portid, 1653 1654 cb->nlh->nlmsg_seq, NLM_F_MULTI); 1655 + devl_unlock(devlink); 1654 1656 devlink_put(devlink); 1657 + 1655 1658 if (err) 1656 1659 goto out; 1657 1660 idx++;