diff mbox series

[ethtool,v2,3/9] ioctl: prevent argc underflow in do_perqueue()

Message ID 48ef048e78abee08eb6403985786659840d419e4.1598210544.git.mkubecek@suse.cz
State Accepted
Delegated to: Michal Kubecek
Headers show
Series compiler warnings cleanup, part 2 | expand

Commit Message

Michal Kubecek Aug. 23, 2020, 7:40 p.m. UTC
When first command line argument after "-Q" is "queue_mask", we parse
the queue mask and following subcommand without checking if these
arguments do actually exist. Add check if we have at least two arguments
left after "queue_mask" in the corresponding branch.

Fixes: 9ecd54248b1a ("ethtool: introduce new ioctl for per-queue settings")
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
---
 ethtool.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/ethtool.c b/ethtool.c
index 4fa7a2c1716f..6c12452be7b4 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -5880,6 +5880,8 @@  static int do_perqueue(struct cmd_context *ctx)
 			"The sub commands will be applied to all %d queues\n",
 			n_queues);
 	} else {
+		if (ctx->argc <= 2)
+			exit_bad_args();
 		ctx->argc--;
 		ctx->argp++;
 		if (parse_hex_u32_bitmap(*ctx->argp, MAX_NUM_QUEUE,