Blame SOURCES/0005-ioctl-prevent-argc-underflow-in-do_perqueue.patch

83ef35
From 04315b072d623ba9200612a4c5f5330f1eb28a27 Mon Sep 17 00:00:00 2001
83ef35
From: Michal Kubecek <mkubecek@suse.cz>
83ef35
Date: Sun, 23 Aug 2020 21:40:24 +0200
83ef35
Subject: [PATCH 05/17] ioctl: prevent argc underflow in do_perqueue()
83ef35
83ef35
When first command line argument after "-Q" is "queue_mask", we parse
83ef35
the queue mask and following subcommand without checking if these
83ef35
arguments do actually exist. Add check if we have at least two arguments
83ef35
left after "queue_mask" in the corresponding branch.
83ef35
83ef35
Fixes: 9ecd54248b1a ("ethtool: introduce new ioctl for per-queue settings")
83ef35
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
83ef35
(cherry picked from commit 39c354e591b66cc29edaab89f90ed03a513ad88f)
83ef35
---
83ef35
 ethtool.c | 2 ++
83ef35
 1 file changed, 2 insertions(+)
83ef35
83ef35
diff --git a/ethtool.c b/ethtool.c
83ef35
index 4fa7a2c1716f..6c12452be7b4 100644
83ef35
--- a/ethtool.c
83ef35
+++ b/ethtool.c
83ef35
@@ -5880,6 +5880,8 @@ static int do_perqueue(struct cmd_context *ctx)
83ef35
 			"The sub commands will be applied to all %d queues\n",
83ef35
 			n_queues);
83ef35
 	} else {
83ef35
+		if (ctx->argc <= 2)
83ef35
+			exit_bad_args();
83ef35
 		ctx->argc--;
83ef35
 		ctx->argp++;
83ef35
 		if (parse_hex_u32_bitmap(*ctx->argp, MAX_NUM_QUEUE,
83ef35
-- 
83ef35
2.26.2
83ef35