From: Lorenzo Colitti Date: Sun, 6 Nov 2016 15:16:25 +0000 (+0900) Subject: net: core: add missing check for uid_range in rule_exists. X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=35b80733b3d3ab620edc30f286606be775930843;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git 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/ Signed-off-by: Lorenzo Colitti Acked-by: Maciej Żenczykowski Signed-off-by: David S. Miller --- diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c index 5de436a73be2..b6791d94841d 100644 --- a/net/core/fib_rules.c +++ b/net/core/fib_rules.c @@ -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;