From: Andrew Lunn <andrew@lunn.ch>
To: Jamie Bainbridge <jamie.bainbridge@gmail.com>
Cc: netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Florian Fainelli <f.fainelli@gmail.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net 3/4] net-sysfs: check device is present when showing testing
Date: Wed, 24 Jul 2024 12:35:36 +0200 [thread overview]
Message-ID: <30a2d52a-527b-4cc3-94b6-9ee092859ae0@lunn.ch> (raw)
In-Reply-To: <2a96f450e4150e9b8c39fb000d82c17987c5bbc5.1721784184.git.jamie.bainbridge@gmail.com>
On Wed, Jul 24, 2024 at 11:46:52AM +1000, Jamie Bainbridge wrote:
> A sysfs reader can race with a device reset or removal.
>
> This was fixed for speed_show with commit 4224cfd7fb65 ("net-sysfs: add
> check for netdevice being present to speed_show") so add the same check
> to testing_show.
>
> Fixes: db30a57779b1 ("net: Add testing sysfs attribute")
>
> Signed-off-by: Jamie Bainbridge <jamie.bainbridge@gmail.com>
> ---
> net/core/net-sysfs.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
> index 3a539a2bd4d11c5f5d7b6f15a23d61439f178c3b..17927832a4fbb56d3e1dfbed29c567d70ab944be 100644
> --- a/net/core/net-sysfs.c
> +++ b/net/core/net-sysfs.c
> @@ -291,7 +291,7 @@ static ssize_t testing_show(struct device *dev,
> {
> struct net_device *netdev = to_net_dev(dev);
>
> - if (netif_running(netdev))
> + if (netif_running(netdev) && netif_device_present(netdev))
Maybe a dumb observation, but how can it be running if it is not
present?
And if we are not holding any locks, it might be gone by the time you
call netif_testing()?
> return sysfs_emit(buf, fmt_dec, !!netif_testing(netdev));
Andrew
next prev parent reply other threads:[~2024-07-24 10:35 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1721784184.git.jamie.bainbridge@gmail.com>
2024-07-24 1:46 ` [PATCH net 1/4] net-sysfs: check device is present when showing carrier Jamie Bainbridge
2024-07-24 9:35 ` Johannes Berg
2024-07-24 9:41 ` Johannes Berg
2024-07-24 22:54 ` Jamie Bainbridge
2024-07-25 2:22 ` Shigeru Yoshida
2024-07-24 1:46 ` [PATCH net 2/4] net-sysfs: check device is present when showing duplex Jamie Bainbridge
2024-07-24 1:46 ` [PATCH net 3/4] net-sysfs: check device is present when showing testing Jamie Bainbridge
2024-07-24 10:35 ` Andrew Lunn [this message]
2024-07-24 1:46 ` [PATCH net 4/4] net-sysfs: check device is present when showing dormant Jamie Bainbridge
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=30a2d52a-527b-4cc3-94b6-9ee092859ae0@lunn.ch \
--to=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=jamie.bainbridge@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--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
all inboxes | Powered by JetHome®