proc connector: reject unprivileged listener bumps
authorKees Cook <[email protected]>
Mon, 25 Feb 2013 21:32:25 +0000 (21:32 +0000)
committerDavid S. Miller <[email protected]>
Wed, 27 Feb 2013 18:08:35 +0000 (13:08 -0500)
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 <[email protected]>
Cc: Evgeniy Polyakov <[email protected]>
Cc: Matt Helsley <[email protected]>
Cc: [email protected]
Acked-by: Evgeniy Polyakov <[email protected]>
Acked-by: Matt Helsley <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
drivers/connector/cn_proc.c

index fce2000eec31d658efb52251b7f6df60822d1798..1110478dd0fdb83b6bbdbae5fa1f40c0a2406655 100644 (file)
@@ -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);
 }