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

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