From: Jakub Kicinski <kuba@kernel.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com,
jacob.e.keller@intel.com, Jakub Kicinski <kuba@kernel.org>,
jiri@nvidia.com, moshe@mellanox.com
Subject: [PATCH net] devlink: protect devlink dump by the instance lock
Date: Thu, 15 Dec 2022 20:41:22 -0800 [thread overview]
Message-ID: <20221216044122.1863550-1-kuba@kernel.org> (raw)
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. Also note that the reloads
themselves had not been under the instance lock until recently, so
the selection of the Fixes tag is inherently questionable.
Fixes: a254c264267e ("devlink: Add reload stats")
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: jiri@nvidia.com
CC: moshe@mellanox.com
---
net/core/devlink.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/net/core/devlink.c b/net/core/devlink.c
index d2df30829083..032d6d0a5ce6 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -1648,10 +1648,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++;
--
2.38.1
next reply other threads:[~2022-12-16 4:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-16 4:41 Jakub Kicinski [this message]
2022-12-16 4:44 ` [PATCH net] devlink: protect devlink dump by the instance lock Jakub Kicinski
2022-12-16 9:18 ` Jiri Pirko
2022-12-16 22:32 ` Jacob Keller
2022-12-17 5:20 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221216044122.1863550-1-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jacob.e.keller@intel.com \
--cc=jiri@nvidia.com \
--cc=moshe@mellanox.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).