Re: [PATCH] net: Adding parameter detection in __ethtool_get_link_ksettings.

From: Michal Kubecek
Date: Thu Aug 29 2019 - 02:01:49 EST


On Tue, Aug 27, 2019 at 07:01:41PM +0000, Saeed Mahameed wrote:
> On Mon, 2019-08-26 at 17:47 +0800, Dongxu Liu wrote:
>
> > Maybe "if (!dev->ethtool_ops)" is more accurate for this bug.
> >
>
> Also i am not sure about this, could be a bug in the device driver your
> enslaving.
>
> alloc_netdev_mqs will assign &default_ethtool_ops to dev->ethtool_ops ,
> if user provided setup callback didn't assign the driver specific
> ethtool_ops.

Dongxu said he encountered the null pointer dereference in a 3.10
kernel, not current mainline. But commit 2c60db037034 ("net: provide a
default dev->ethtool_ops") which introduced default_ethtool_ops came in
3.7-rc1 so 3.10 should have it already. There is indeed something wrong.

I don't think we should add either check unless we positively know that
dev->ethtool_ops can be null with current mainline kernel. And even
then, it would probably be more appropriate to fix the code which caused
it.

Michal