Hello,

I am testing ethtool 5.8, and I noticed it segfaulted with the command
   ethtool -s eth0 autoneg on

Backtrace as follows:
(gdb) run -s eth0 autoneg on
Starting program: /tmp/ethtool-5.8 -s eth0 autoneg on

Program received signal SIGSEGV, Segmentation fault.
0x0040bef8 in do_sset ()
(gdb) bt
#0  0x0040bef8 in do_sset ()
#1  0x00407d9c in do_ioctl_glinksettings ()
#2  0x00000000 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

I then tested reverting 
https://git.kernel.org/pub/scm/network/ethtool/ethtool.git/commit/ethtool.c?id=bef780467fa7aa95dca3ed5cc3ebb8bec5882f08

And the command now passes.

I am running ethtool on top of Linux 4.4.232, hence there is no support 
for ETHTOOL_xLINKSETTINGS.

Is the bef780467fa7aa95dca3ed5cc3ebb8bec5882f08 patch not correct, one 
should check link_usettings pointer for non-NULL before memset'ing?

Since do_ioctl_glinksettings() will return NULL upon failure, which 
matches well with kernels not supporting ETHTOOL_GLINKSETTINGS ioctl.

-- 
Best regards, Hans-Christian Noren Egtvedt

Reply via email to