ethtool/SOURCES/0005-ioctl-prevent-argc-und...

34 lines
1.1 KiB
Diff

From 04315b072d623ba9200612a4c5f5330f1eb28a27 Mon Sep 17 00:00:00 2001
From: Michal Kubecek <mkubecek@suse.cz>
Date: Sun, 23 Aug 2020 21:40:24 +0200
Subject: [PATCH 05/17] ioctl: prevent argc underflow in do_perqueue()
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>
(cherry picked from commit 39c354e591b66cc29edaab89f90ed03a513ad88f)
---
ethtool.c | 2 ++
1 file changed, 2 insertions(+)
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,
--
2.26.2