From: Andy Gospodarek <andy@greyhouse.net>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
Linux Netdev List <netdev@vger.kernel.org>,
Andy Gospodarek <andy@greyhouse.net>
Subject: Re: [PATCH net-next-2.6] net: sysfs: ethtool_ops can be NULL
Date: Mon, 26 Oct 2009 09:40:33 -0400 [thread overview]
Message-ID: <20091026134033.GD1639@gospo.rdu.redhat.com> (raw)
In-Reply-To: <4AE586B5.4030308@gmail.com>
On Mon, Oct 26, 2009 at 12:23:33PM +0100, Eric Dumazet wrote:
> commit d519e17e2d01a0ee9abe083019532061b4438065
> (net: export device speed and duplex via sysfs)
> made the wrong assumption that netdev->ethtool_ops was always set.
>
> This makes possible to crash kernel and let rtnl in locked state.
>
> modprobe dummy
> ip link set dummy0 up
> (udev runs and crash)
>
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
> ---
> net/core/net-sysfs.c | 8 ++++++--
> 1 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
> index 753c420..89de182 100644
> --- a/net/core/net-sysfs.c
> +++ b/net/core/net-sysfs.c
> @@ -139,7 +139,9 @@ static ssize_t show_speed(struct device *dev,
> if (!rtnl_trylock())
> return restart_syscall();
>
> - if (netif_running(netdev) && netdev->ethtool_ops->get_settings) {
> + if (netif_running(netdev) &&
> + netdev->ethtool_ops &&
> + netdev->ethtool_ops->get_settings) {
> struct ethtool_cmd cmd = { ETHTOOL_GSET };
>
> if (!netdev->ethtool_ops->get_settings(netdev, &cmd))
> @@ -158,7 +160,9 @@ static ssize_t show_duplex(struct device *dev,
> if (!rtnl_trylock())
> return restart_syscall();
>
> - if (netif_running(netdev) && netdev->ethtool_ops->get_settings) {
> + if (netif_running(netdev) &&
> + netdev->ethtool_ops &&
> + netdev->ethtool_ops->get_settings) {
> struct ethtool_cmd cmd = { ETHTOOL_GSET };
>
> if (!netdev->ethtool_ops->get_settings(netdev, &cmd))
Nice catch, Eric.
Acked-by: Andy Gospodarek <andy@greyhouse.net>
next prev parent reply other threads:[~2009-10-26 13:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-26 11:23 [PATCH net-next-2.6] net: sysfs: ethtool_ops can be NULL Eric Dumazet
2009-10-26 13:40 ` Andy Gospodarek [this message]
2009-10-28 11:02 ` David Miller
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=20091026134033.GD1639@gospo.rdu.redhat.com \
--to=andy@greyhouse.net \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=netdev@vger.kernel.org \
/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).