4 missing check bugs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dear maintainers,

Hi, our tool finds several missing check bugs on
Linux kernel v4.18.5 using static analysis.
We are looking forward to having more experts' eyes on this. Thank you!

Before calling sk_alloc() with SOCK_RAW type,
there should be a permission check, ns_capable(ns,CAP_NET_RAW).
For example,

static int xsk_create(struct net *net, struct socket *sock, int protocol,
      int kern)
{
struct xdp_sock *xs;
struct sock *sk;

if (!ns_capable(net->user_ns, CAP_NET_RAW))
return -EPERM;
if (sock->type != SOCK_RAW)
return -ESOCKTNOSUPPORT;
...
sk = sk_alloc(net, PF_XDP, GFP_KERNEL, &xsk_proto, kern);
if (!sk)
return -ENOBUFS;
...
}



We find 4 missing check bugs.
The functions that miss permission checks in v4.18.5:

net/bluetooth/hidp/sock.c
static int hidp_sock_create(struct net *net, struct socket *sock, int protocol,
    int kern)
{
struct sock *sk;

BT_DBG("sock %p", sock);

if (sock->type != SOCK_RAW)
return -ESOCKTNOSUPPORT;

sk = sk_alloc(net, PF_BLUETOOTH, GFP_ATOMIC, &hidp_proto, kern);
if (!sk)
return -ENOMEM;
...
}


net/bluetooth/cmtp/sock.c
static int cmtp_sock_create(struct net *net, struct socket *sock, int protocol,
    int kern)
{
struct sock *sk;

BT_DBG("sock %p", sock);

if (sock->type != SOCK_RAW)
return -ESOCKTNOSUPPORT;

sk = sk_alloc(net, PF_BLUETOOTH, GFP_ATOMIC, &cmtp_proto, kern);
if (!sk)
return -ENOMEM;
...
}


net/bluetooth/hci_sock.c
static int hci_sock_create(struct net *net, struct socket *sock, int protocol,
   int kern)
{
struct sock *sk;

BT_DBG("sock %p", sock);

if (sock->type != SOCK_RAW)
return -ESOCKTNOSUPPORT;

sock->ops = &hci_sock_ops;

sk = sk_alloc(net, PF_BLUETOOTH, GFP_ATOMIC, &hci_sk_proto, kern);
if (!sk)
return -ENOMEM;
...
}


/net/bluetooth/bnep/sock.c
static int bnep_sock_create(struct net *net, struct socket *sock, int protocol,
    int kern)
{
struct sock *sk;

BT_DBG("sock %p", sock);

if (sock->type != SOCK_RAW)
return -ESOCKTNOSUPPORT;

sk = sk_alloc(net, PF_BLUETOOTH, GFP_ATOMIC, &bnep_proto, kern);
if (!sk)
return -ENOMEM;
...
}


Thanks again!


Best regards,
Jinmeng Zhou



[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux