Skip to contentSkip to conversation

net: core: add missing check for uid_range in rule_exists.

PATCH Applied Lorenzo Colitti 3 participants 3 messages Nov 6, 2016 – Nov 9, 2016

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

PATCH 1/1 net: core: add missing check for uid_range in rule_exists.

Without this check, it is not possible to create two rules that are identical except for their UID ranges. For example:

root@net-test:/# ip rule add prio 1000 lookup 300
root@net-test:/# ip rule add prio 1000 uidrange 100-200 lookup 300
RTNETLINK answers: File exists
root@net-test:/# ip rule add prio 1000 uidrange 100-199 lookup 100
root@net-test:/# ip rule add prio 1000 uidrange 200-299 lookup 200
root@net-test:/# ip rule add prio 1000 uidrange 300-399 lookup 100
RTNETLINK answers: File exists

Tested: https://android-review.googlesource.com/#/c/299980/

---
 net/core/fib_rules.c | 4 ++++
 1 file changed, 4 insertions(+)
net/core/fib_rules.c +4 -0
index 5de436a..b6791d9 100644
@@ -343,6 +343,10 @@ static int rule_exists(struct fib_rules_ops *ops, struct fib_rule_hdr *frh,
 		if (r->l3mdev != rule->l3mdev)
 			continue;
 
+		if (!uid_eq(r->uid_range.start, rule->uid_range.start) ||
+		    !uid_eq(r->uid_range.end, rule->uid_range.end))
+			continue;
+
 		if (!ops->compare(r, frh, tb))
 			continue;
 		return 1;
Signature · 1 line
2.8.0.rc3.226.g39d4020
maintainer Applied
#2 lore raw
In reply to Lorenzo Colitti

From: Lorenzo Colitti <[email protected]>
Date: Mon, 7 Nov 2016 00:16:25 +0900

Quoted 11 lines

Without this check, it is not possible to create two rules that are identical except for their UID ranges. For example:

root@net-test:/# ip rule add prio 1000 lookup 300
root@net-test:/# ip rule add prio 1000 uidrange 100-200 lookup 300
RTNETLINK answers: File exists
root@net-test:/# ip rule add prio 1000 uidrange 100-199 lookup 100
root@net-test:/# ip rule add prio 1000 uidrange 200-299 lookup 200
root@net-test:/# ip rule add prio 1000 uidrange 300-399 lookup 100
RTNETLINK answers: File exists
Quoted 2 lines

Tested: https://android-review.googlesource.com/#/c/299980/

Applied.