Skip to contentSkip to conversation

rttable: Fix invalid range checking when table id is converted to u32

PATCH In review David Ahern 2 participants 2 messages Jan 10, 2017 – Jan 13, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rttable: Fix invalid range checking when table id is converted to u32

Frank reported that table ids for very large numbers are not properly detected:

$ ip li add foobar type vrf table 98765432100123456789

command succeeds and resulting table id is actually:

21: foobar: <NOARP,MASTER> mtu 65536 qdisc noop state DOWN mode DEFAULT group default qlen 1000

    link/ether da:ea:d4:77:38:2a brd ff:ff:ff:ff:ff:ff promiscuity 0
    vrf table 4294967295 addrgenmode eui64 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535

Make the temp variable 'i' unsigned long and let the typecast to u32 happen on assignment to id.

---
 lib/rt_names.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/rt_names.c +1 -1
index c66cb1e439e3..63687586508b 100644
@@ -404,7 +404,7 @@ int rtnl_rttable_a2n(__u32 *id, const char *arg)
 	static unsigned long res;
 	struct rtnl_hash_entry *entry;
 	char *end;
-	__u32 i;
+	unsigned long i;
 
 	if (cache && strcmp(cache, arg) == 0) {
 		*id = res;
Signature · 1 line
2.1.4
#1 lore raw
Quoted 7 lines · On Tue, 10 Jan 2017 15:33:55 -0800 David Ahern <[email protected]> wrote:

Frank reported that table ids for very large numbers are not properly detected:

$ ip li add foobar type vrf table 98765432100123456789

command succeeds and resulting table id is actually:

21: foobar: <NOARP,MASTER> mtu 65536 qdisc noop state DOWN mode DEFAULT group default qlen 1000

Quoted 8 lines
    link/ether da:ea:d4:77:38:2a brd ff:ff:ff:ff:ff:ff promiscuity 0
    vrf table 4294967295 addrgenmode eui64 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535

Make the temp variable 'i' unsigned long and let the typecast to u32 happen on assignment to id.

Applied thanks.