Skip to contentSkip to conversation

ipv6: invert flowlabel sharing check in process and user mode

PATCH In review Willem de Bruijn 2 participants 2 messages Apr 25, 2019 – Apr 29, 2019

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

PATCH 1/1 ipv6: invert flowlabel sharing check in process and user mode

From: Willem de Bruijn <[email protected]>

A request for a flowlabel fails in process or user exclusive mode must fail if the caller pid or uid does not match. Invert the test.

Previously, the test was unsafe wrt PID recycling, but indeed tested for inequality: fl1->owner != fl->owner

Fixes 4f82f45730c68 ("net ip6 flowlabel: Make owner a union of struct pid* and kuid_t")
---
 net/ipv6/ip6_flowlabel.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/ipv6/ip6_flowlabel.c +2 -2
index cb54a8a3c2735..a05036bc808d5 100644
@@ -633,9 +633,9 @@ int ipv6_flowlabel_opt(struct sock *sk, char __user *optval, int optlen)
 				if (fl1->share == IPV6_FL_S_EXCL ||
 				    fl1->share != fl->share ||
 				    ((fl1->share == IPV6_FL_S_PROCESS) &&
-				     (fl1->owner.pid == fl->owner.pid)) ||
+				     (fl1->owner.pid != fl->owner.pid)) ||
 				    ((fl1->share == IPV6_FL_S_USER) &&
-				     uid_eq(fl1->owner.uid, fl->owner.uid)))
+				     !uid_eq(fl1->owner.uid, fl->owner.uid)))
 					goto release;
 
 				err = -ENOMEM;
Signature · 1 line
2.21.0.593.g511ec345e18-goog
maintainer
#1 lore raw

From: Willem de Bruijn <[email protected]>
Date: Thu, 25 Apr 2019 12:06:54 -0400

Quoted 10 lines

From: Willem de Bruijn <[email protected]>

A request for a flowlabel fails in process or user exclusive mode must fail if the caller pid or uid does not match. Invert the test.

Previously, the test was unsafe wrt PID recycling, but indeed tested for inequality: fl1->owner != fl->owner

Fixes 4f82f45730c68 ("net ip6 flowlabel: Make owner a union of struct pid* and kuid_t")

Applied and queued up for -stable, thanks Willem.