netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: core: add missing check for uid_range in rule_exists.
@ 2016-11-06 15:16 Lorenzo Colitti
  2016-11-07  2:21 ` Maciej Żenczykowski
  2016-11-09 18:28 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Lorenzo Colitti @ 2016-11-06 15:16 UTC (permalink / raw)
  To: netdev; +Cc: davem, ek, eric.dumazet, zenczykowski, Lorenzo Colitti

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 <lorenzo@google.com>
---
 net/core/fib_rules.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c
index 5de436a..b6791d9 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;
-- 
2.8.0.rc3.226.g39d4020

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] net: core: add missing check for uid_range in rule_exists.
  2016-11-06 15:16 [PATCH net-next] net: core: add missing check for uid_range in rule_exists Lorenzo Colitti
@ 2016-11-07  2:21 ` Maciej Żenczykowski
  2016-11-09 18:28 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Maciej Żenczykowski @ 2016-11-07  2:21 UTC (permalink / raw)
  To: Lorenzo Colitti; +Cc: Linux NetDev, David Miller, Erik Kline, Eric Dumazet

Acked-by: Maciej Żenczykowski <maze@google.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] net: core: add missing check for uid_range in rule_exists.
  2016-11-06 15:16 [PATCH net-next] net: core: add missing check for uid_range in rule_exists Lorenzo Colitti
  2016-11-07  2:21 ` Maciej Żenczykowski
@ 2016-11-09 18:28 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2016-11-09 18:28 UTC (permalink / raw)
  To: lorenzo; +Cc: netdev, ek, eric.dumazet, zenczykowski

From: Lorenzo Colitti <lorenzo@google.com>
Date: Mon,  7 Nov 2016 00:16:25 +0900

> 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 <lorenzo@google.com>

Applied.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-11-09 18:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-06 15:16 [PATCH net-next] net: core: add missing check for uid_range in rule_exists Lorenzo Colitti
2016-11-07  2:21 ` Maciej Żenczykowski
2016-11-09 18:28 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).