Blob Blame History Raw
From d97d0e6a5201c5c7d5a2019bd3c3a29b3b78d7d4 Mon Sep 17 00:00:00 2001
From: Davide Caratti <dcaratti@redhat.com>
Date: Tue, 17 Jan 2017 14:40:44 +0100
Subject: [PATCH] tc: don't accept qdisc 'handle' greater than ffff

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1375393
Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=12376479
Tested: on local VM (verified error message in case 'handle' is greater than ffff)
Upstream Status: iproute2.git commit 087dec7fcfb1

commit 087dec7fcfb18fc4e8a0ec68c9c0a84cb9f03e69
Author: Davide Caratti <dcaratti@redhat.com>
Date:   Fri Sep 16 10:30:00 2016 +0200

    tc: don't accept qdisc 'handle' greater than ffff

    since get_qdisc_handle() truncates the input value to 16 bit, return an
    error and prompt "invalid qdisc ID" in case input 'handle' parameter needs
    more than 16 bit to be stored.

    Signed-off-by: Davide Caratti <dcaratti@redhat.com>
    Acked-by: Phil Sutter <phil@nwl.cc>

Signed-off-by: Davide Caratti <dcaratti@redhat.com>
---
 tc/tc_util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tc/tc_util.c b/tc/tc_util.c
index 8114c97..df81c46 100644
--- a/tc/tc_util.c
+++ b/tc/tc_util.c
@@ -48,7 +48,7 @@ int get_qdisc_handle(__u32 *h, const char *str)
 	if (strcmp(str, "none") == 0)
 		goto ok;
 	maj = strtoul(str, &p, 16);
-	if (p == str)
+	if (p == str || maj >= (1 << 16))
 		return -1;
 	maj <<= 16;
 	if (*p != ':' && *p!=0)
-- 
1.8.3.1