Bluetooth: hci_ldisc: require CAP_NET_ADMIN to attach N_HCI ldisc
authorThadeu Lima de Souza Cascardo <cascardo@canonical.com>
Wed, 22 Sep 2021 11:56:56 +0000 (08:56 -0300)
committerMarcel Holtmann <marcel@holtmann.org>
Wed, 22 Sep 2021 14:14:21 +0000 (16:14 +0200)
Any unprivileged user can attach N_HCI ldisc and send packets coming from a
virtual controller by using PTYs.

Require initial namespace CAP_NET_ADMIN to do that.

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
drivers/bluetooth/hci_ldisc.c

index 5ed2cfa7da1d9e116198f3742ef29d53cb4128cb..5e32e4d5367af5a4ad581b8cd04ed327973da3c2 100644 (file)
@@ -479,6 +479,9 @@ static int hci_uart_tty_open(struct tty_struct *tty)
 
        BT_DBG("tty %p", tty);
 
+       if (!capable(CAP_NET_ADMIN))
+               return -EPERM;
+
        /* Error if the tty has no write op instead of leaving an exploitable
         * hole
         */