Skip to contentSkip to conversation

proc connector: reject unprivileged listener bumps

PATCH Applied Kees Cook 4 participants 4 messages Feb 26, 2013 – Feb 27, 2013

Subsystems (2)
lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH 1/1 proc connector: reject unprivileged listener bumps

While PROC_CN_MCAST_LISTEN/IGNORE is entirely advisory, it was possible for an unprivileged user to turn off notifications for all listeners by sending PROC_CN_MCAST_IGNORE. Instead, require the same privileges as required for a multicast bind.

Cc Evgeniy Polyakov <[email protected]>
Cc Matt Helsley <[email protected]>
---
 drivers/connector/cn_proc.c |    8 ++++++++
 1 file changed, 8 insertions(+)
drivers/connector/cn_proc.c +8 -0
index fce2000..1110478 100644
@@ -313,6 +313,12 @@ static void cn_proc_mcast_ctl(struct cn_msg *msg,
 	    (task_active_pid_ns(current) != &init_pid_ns))
 		return;
 
+	/* Can only change if privileged. */
+	if (!capable(CAP_NET_ADMIN)) {
+		err = EPERM;
+		goto out;
+	}
+
 	mc_op = (enum proc_cn_mcast_op *)msg->data;
 	switch (*mc_op) {
 	case PROC_CN_MCAST_LISTEN:
@@ -325,6 +331,8 @@ static void cn_proc_mcast_ctl(struct cn_msg *msg,
 		err = EINVAL;
 		break;
 	}
+
+out:
 	cn_proc_ack(err, msg->seq, msg->ack);
 }
 
Signature · 6 lines
1.7.9.5


-- 
Kees Cook
Chrome OS Security
Acked-by on v1 1/1
#1 lore raw

Hi

Quoted 4 lines · Kees Cook

While PROC_CN_MCAST_LISTEN/IGNORE is entirely advisory, it was possible for an unprivileged user to turn off notifications for all listeners by sending PROC_CN_MCAST_IGNORE. Instead, require the same privileges as required for a multicast bind.

Sounds resonable.
Not sure whether this is a candidate for stable release, but otherwise

Signature · 1 line
	Evgeniy Polyakov
Acked-by on v1 1/1
#2 lore raw
In reply to Kees Cook
Quoted 18 lines · Kees Cook

While PROC_CN_MCAST_LISTEN/IGNORE is entirely advisory, it was possible for an unprivileged user to turn off notifications for all listeners by sending PROC_CN_MCAST_IGNORE. Instead, require the same privileges as required for a multicast bind.

Cc Evgeniy Polyakov <[email protected]>
Cc Matt Helsley <[email protected]>
---
 drivers/connector/cn_proc.c |    8 ++++++++
 1 file changed, 8 insertions(+)
drivers/connector/cn_proc.c +0 -0
index fce2000..1110478 100644

drivers/connector/cn_proc.c static void cn_proc_mcast_ctl(struct cn_msg *msg, · line 316

Quoted 4 lines
drivers/connector/cn_proc.c +1 -0
@@ -313,6 +313,12 @@ static void cn_proc_mcast_ctl(struct cn_msg *msg,
 	    (task_active_pid_ns(current) != &init_pid_ns))
 		return;
 
+	/* Can only change if privileged. */

I think this comment doesn't tell us anything above and beyond the what capability check already tells us. I think you could improve it by noting that since the connector is multicast and not namespace-safe it's not yet appropriate to use ns_capable() here.

Quoted 4 lines
drivers/connector/cn_proc.c +4 -0
+	if (!capable(CAP_NET_ADMIN)) {
+		err = EPERM;
+		goto out;
+	}
maintainer Applied
#3 lore raw

From: Matt Helsley <[email protected]>
Date: Tue, 26 Feb 2013 09:24:41 -0800

Quoted 22 lines · Kees Cook
Quoted 21 lines

While PROC_CN_MCAST_LISTEN/IGNORE is entirely advisory, it was possible for an unprivileged user to turn off notifications for all listeners by sending PROC_CN_MCAST_IGNORE. Instead, require the same privileges as required for a multicast bind.

Cc Evgeniy Polyakov <[email protected]>
Cc Matt Helsley <[email protected]>
---
 drivers/connector/cn_proc.c |    8 ++++++++
 1 file changed, 8 insertions(+)
drivers/connector/cn_proc.c +0 -0
index fce2000..1110478 100644
@@ -313,6 +313,12 @@ static void cn_proc_mcast_ctl(struct cn_msg *msg,
 	    (task_active_pid_ns(current) != &init_pid_ns))
 		return;
 
Quoted 8 lines

drivers/connector/cn_proc.c static void cn_proc_mcast_ctl(struct cn_msg *msg, · line 316

Quoted 1 line
drivers/connector/cn_proc.c +1 -0
+	/* Can only change if privileged. */

I think this comment doesn't tell us anything above and beyond the what capability check already tells us. I think you could improve it by noting that since the connector is multicast and not namespace-safe it's not yet appropriate to use ns_capable() here.

Applied.