All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Michal Kubecek <mkubecek@suse.cz>
Cc: netdev <netdev@vger.kernel.org>, Chris Healy <cphealy@gmail.com>,
	Andrew Lunn <andrew@lunn.ch>
Subject: [PATCH ethtool] Fix segfault with cable test and ./configure --disable-netlink
Date: Fri, 17 Jul 2020 00:05:09 +0200	[thread overview]
Message-ID: <20200716220509.1314265-1-andrew@lunn.ch> (raw)

When the netlink interface code is disabled, a stub version of
netlink_run_handler() is used. This stub version needs to handle the
case when there is no possibility for a command to fall back to the
IOCTL call. The two cable tests commands have no such fallback, and if
we don't handle this, ethtool tries to jump through a NULL pointer
resulting in a segfault.

Reported-by: Chris Healy <cphealy@gmail.com>
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 netlink/extapi.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/netlink/extapi.h b/netlink/extapi.h
index c5bfde9..a35d5f2 100644
--- a/netlink/extapi.h
+++ b/netlink/extapi.h
@@ -46,6 +46,12 @@ void nl_monitor_usage(void);
 static inline void netlink_run_handler(struct cmd_context *ctx,
 				       nl_func_t nlfunc, bool no_fallback)
 {
+	if (no_fallback) {
+		fprintf(stderr,
+			"Command requires kernel netlink support which is not "
+			"enabled in this ethtool binary\n");
+		exit(1);
+	}
 }
 
 static inline int nl_monitor(struct cmd_context *ctx)
-- 
2.27.0


             reply	other threads:[~2020-07-16 22:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-16 22:05 Andrew Lunn [this message]
2020-07-20  0:12 ` [PATCH ethtool] Fix segfault with cable test and ./configure --disable-netlink Michal Kubecek
2020-07-20  0:31   ` Andrew Lunn

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=20200716220509.1314265-1-andrew@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=cphealy@gmail.com \
    --cc=mkubecek@suse.cz \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.