Hi Dave,
I stumbled across a reproducible kernel panic while playing around with
busy_poll on a Linux 4.9.86 kernel. There's an unfortunate interaction
between init_dummy_netdev, which doesn't bother to fill in netdev_ops, and
sk_busy_loop, which assumes netdev_ops is a valid pointer.
To reproduce on the device under test (DUT), I did:
$ ip addr show dev wlan0
8: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq [...]
inet 172.16.122.6/23 brd 172.16.123.255 scope global wlan0
$ sysctl -w net.core.busy_read=50
$ nc -l 172.16.122.6 5001
Then transmitted some data to this socket from a second host:
$ echo "foo" | nc 172.16.122.6 5001
The DUT immediately hits a kernel panic.
I've attached a patch that applies cleanly to the 4.9.87 stable release.
This fix isn't necessary for net/net-next (ndo_busy_poll was removed in
linux-4.11), but a further backport of this commit is likely required for
any stable releases older than linux-4.5.
I hope this is the right way to raise something like this. I couldn't find
a clear answer from the -stable and netdev howtos for bugs against features
that no longer exist in mainline.
Thanks,
Josh
From: Cong Wang <hidden> Date: 2018-03-12 23:17:23
On Sun, Mar 11, 2018 at 12:22 PM, Josh Elsasser [off-list ref] 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 that napi->dev is not a dummy device before
dereferencing napi dev's netdev_ops, preventing the following panic:
Hmm, how about just checking ->netdev_ops? Checking reg_state looks
odd, although works.
On Mon, Mar 12, 2018 at 4:17 PM, Cong Wang [off-list ref] wrote:
On Sun, Mar 11, 2018 at 12:22 PM, Josh Elsasser [off-list ref] wrote:
quoted
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 that napi->dev is not a dummy device before
dereferencing napi dev's netdev_ops, preventing the following panic:
Hmm, how about just checking ->netdev_ops? Checking reg_state looks
odd, although works.
Fair point. I was trying to differentiate between an unexpected
NULL pointer and a dummy netdev, but I guess it was clever
at the expense of readability.
I'll push up a v2 that just does the obvious.