Patchwork proc connector: reject unprivileged listener bumps

login
register
mail settings
Submitter Kees Cook
Date Feb. 26, 2013, 7:32 a.m.
Message ID <20130226073225.GA15489@www.outflux.net>
Download mbox | patch
Permalink /patch/223119/
State Accepted
Delegated to: David Miller
Headers show

Comments

Kees Cook - Feb. 26, 2013, 7:32 a.m.
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.

Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: Evgeniy Polyakov <zbr@ioremap.net>
Cc: Matt Helsley <matthltc@us.ibm.com>
Cc: stable@vger.kernel.org
---
 drivers/connector/cn_proc.c |    8 ++++++++
 1 file changed, 8 insertions(+)
Evgeniy Polyakov - Feb. 26, 2013, 8:46 a.m.
Hi

On Mon, Feb 25, 2013 at 11:32:25PM -0800, Kees Cook (keescook@chromium.org) wrote:
> 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
Acked-by: Evgeniy Polyakov <zbr@ioremap.net>
Matt Helsley - Feb. 26, 2013, 5:24 p.m.
On Mon, Feb 25, 2013 at 11:32:25PM -0800, Kees Cook wrote:
> 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.
> 
> Signed-off-by: Kees Cook <keescook@chromium.org>
> Cc: Evgeniy Polyakov <zbr@ioremap.net>
> Cc: Matt Helsley <matthltc@us.ibm.com>
> Cc: stable@vger.kernel.org
> ---
>  drivers/connector/cn_proc.c |    8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/connector/cn_proc.c b/drivers/connector/cn_proc.c
> index fce2000..1110478 100644
> --- a/drivers/connector/cn_proc.c
> +++ b/drivers/connector/cn_proc.c
> @@ -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.

Acked-by: Matt Helsley <matthltc@us.ibm.com>

> +	if (!capable(CAP_NET_ADMIN)) {
> +		err = EPERM;
> +		goto out;
> +	}

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller - Feb. 27, 2013, 6:08 p.m.
From: Matt Helsley <matthltc@linux.vnet.ibm.com>
Date: Tue, 26 Feb 2013 09:24:41 -0800

> On Mon, Feb 25, 2013 at 11:32:25PM -0800, Kees Cook wrote:
>> 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.
>> 
>> Signed-off-by: Kees Cook <keescook@chromium.org>
>> Cc: Evgeniy Polyakov <zbr@ioremap.net>
>> Cc: Matt Helsley <matthltc@us.ibm.com>
>> Cc: stable@vger.kernel.org
>> ---
>>  drivers/connector/cn_proc.c |    8 ++++++++
>>  1 file changed, 8 insertions(+)
>> 
>> diff --git a/drivers/connector/cn_proc.c b/drivers/connector/cn_proc.c
>> index fce2000..1110478 100644
>> --- a/drivers/connector/cn_proc.c
>> +++ b/drivers/connector/cn_proc.c
>> @@ -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.
> 
> Acked-by: Matt Helsley <matthltc@us.ibm.com>

Applied.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/connector/cn_proc.c b/drivers/connector/cn_proc.c
index fce2000..1110478 100644
--- a/drivers/connector/cn_proc.c
+++ b/drivers/connector/cn_proc.c
@@ -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);
 }