bpfilter: reject kernel addresses
authorChristoph Hellwig <hch@lst.de>
Thu, 23 Jul 2020 06:08:45 +0000 (08:08 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 24 Jul 2020 22:41:53 +0000 (15:41 -0700)
The bpfilter user mode helper processes the optval address using
process_vm_readv.  Don't send it kernel addresses fed under
set_fs(KERNEL_DS) as that won't work.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/bpfilter/bpfilter_kern.c

index 78d561f2c54da72eb434205879a071075f0fc718..00540457e5f4d3c7356556727a10fa3508c9e73f 100644 (file)
@@ -70,6 +70,10 @@ static int bpfilter_process_sockopt(struct sock *sk, int optname,
                .addr           = (uintptr_t)optval,
                .len            = optlen,
        };
+       if (uaccess_kernel()) {
+               pr_err("kernel access not supported\n");
+               return -EFAULT;
+       }
        return bpfilter_send_req(&req);
 }