From: Eric Dumazet <eric.dumazet@gmail.com>
To: Josh Elsasser <jelsasser@appneta.com>, davem@davemloft.net
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Eric Dumazet" <edumazet@google.com>,
"Willem de Bruijn" <willemb@google.com>,
"Alexander Potapenko" <glider@google.com>,
"Cong Wang" <xiyou.wangcong@gmail.com>,
"Vlad Yasevich" <vyasevich@gmail.com>,
"Michal Kubeček" <mkubecek@suse.cz>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/1] net: check before dereferencing netdev_ops during busy poll
Date: Mon, 12 Mar 2018 22:50:54 -0700 [thread overview]
Message-ID: <1e992840-bf36-aa86-791e-8910a2aab7a5@gmail.com> (raw)
In-Reply-To: <20180313053248.13654-2-jelsasser@appneta.com>
On 03/12/2018 10:32 PM, Josh Elsasser wrote:
> init_dummy_netdev() leaves its netdev_ops pointer zeroed. This leads
> to a NULL pointer dereference when sk_busy_loop fires against an iwlwifi
> wireless adapter and checks napi->dev->netdev_ops->ndo_busy_poll.
>
> Avoid this by ensuring napi->dev->netdev_ops is valid before following
> the pointer, avoiding the following panic when busy polling on a dummy
> netdev:
>
>
> Fixes: 060212928670 ("net: add low latency socket poll")
> Fixes: ce6aea93f751 ("net: network drivers no longer need to implement ndo_busy_poll()") - 4.9.y
> Signed-off-by: Josh Elsasser <jelsasser@appneta.com>
> ---
> net/core/dev.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/net/core/dev.c b/net/core/dev.c
> index 8898618bf341..1f50c131ed15 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -5042,7 +5042,10 @@ bool sk_busy_loop(struct sock *sk, int nonblock)
> goto out;
>
> /* Note: ndo_busy_poll method is optional in linux-4.5 */
> - busy_poll = napi->dev->netdev_ops->ndo_busy_poll;
> + if (napi->dev->netdev_ops)
> + busy_poll = napi->dev->netdev_ops->ndo_busy_poll;
> + else
> + busy_poll = NULL;
>
> do {
> rc = 0;
>
We could instead setup a non NULL netdev_ops pointer on these 'dummy'
devices to not add a check in fast path, but I presume we do
not really care since this fix is for old kernels, and considering how
long it took to discover this bug.
Reviewed-by: Eric Dumazet <edumazet@google.com>
next prev parent reply other threads:[~2018-03-13 5:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-13 5:31 [PATCH 0/1] net: avoid a kernel panic during sk_busy_loop Josh Elsasser
2018-03-13 5:32 ` [PATCH v2 1/1] net: check before dereferencing netdev_ops during busy poll Josh Elsasser
2018-03-13 5:50 ` Eric Dumazet [this message]
2018-03-13 14:51 ` 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=1e992840-bf36-aa86-791e-8910a2aab7a5@gmail.com \
--to=eric.dumazet@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=glider@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=jelsasser@appneta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mkubecek@suse.cz \
--cc=netdev@vger.kernel.org \
--cc=vyasevich@gmail.com \
--cc=willemb@google.com \
--cc=xiyou.wangcong@gmail.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®