lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAM_iQpWwApLVg39rUkyXxnhsiP0SZf=0ft6vsq=VxFtJ2SumAQ@mail.gmail.com>
Date:   Sat, 29 May 2021 12:14:57 -0700
From:   Cong Wang <xiyou.wangcong@...il.com>
To:     Changbin Du <changbin.du@...il.com>
Cc:     "David S. Miller" <davem@...emloft.net>,
        Jakub Kici nski <kuba@...nel.org>,
        Linux Kernel Network Developers <netdev@...r.kernel.org>,
        LKML <linux-kernel@...r.kernel.org>,
        stable <stable@...r.kernel.org>
Subject: Re: [PATCH] net: fix oops in socket ioctl cmd SIOCGSKNS when NET_NS
 is disabled

On Fri, May 28, 2021 at 11:08 PM Changbin Du <changbin.du@...il.com> wrote:
> diff --git a/net/socket.c b/net/socket.c
> index 27e3e7d53f8e..644b46112d35 100644
> --- a/net/socket.c
> +++ b/net/socket.c
> @@ -1149,11 +1149,15 @@ static long sock_ioctl(struct file *file, unsigned cmd, unsigned long arg)
>                         mutex_unlock(&vlan_ioctl_mutex);
>                         break;
>                 case SIOCGSKNS:
> +#ifdef CONFIG_NET_NS
>                         err = -EPERM;
>                         if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
>                                 break;
>
>                         err = open_related_ns(&net->ns, get_net_ns);
> +#else
> +                       err = -ENOTSUPP;
> +#endif

I wonder if it is easier if we just reject ns->ops==NULL case
in open_related_ns(). For 1) we can save an ugly #ifdef here;
2) drivers/net/tun.c has the same bugs.

Something like this:

diff --git a/fs/nsfs.c b/fs/nsfs.c
index 800c1d0eb0d0..d63414604e99 100644
--- a/fs/nsfs.c
+++ b/fs/nsfs.c
@@ -152,6 +152,9 @@ int open_related_ns(struct ns_common *ns,
        int err;
        int fd;

+       if (!ns->ops)
+               return -EOPNOTSUPP;
+
        fd = get_unused_fd_flags(O_CLOEXEC);
        if (fd < 0)
                return fd;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ