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_iQpWyVswsMn7nHAF3F_EtRnG1Gs5AiYD24ZQn6693pMdyZQ@mail.gmail.com>
Date:	Wed, 24 Feb 2016 10:54:37 -0800
From:	Cong Wang <xiyou.wangcong@...il.com>
To:	Linux Kernel Network Developers <netdev@...r.kernel.org>
Cc:	Dmitry Vyukov <dvyukov@...gle.com>,
	linux-wireless <linux-wireless@...r.kernel.org>,
	Cong Wang <xiyou.wangcong@...il.com>,
	Lauro Ramos Venancio <lauro.venancio@...nbossa.org>,
	Aloisio Almeida Jr <aloisio.almeida@...nbossa.org>,
	Samuel Ortiz <sameo@...ux.intel.com>
Subject: Re: [PATCH v2 net] nfc: close a race condition in llcp_sock_getname()

On Fri, Jan 29, 2016 at 11:37 AM, Cong Wang <xiyou.wangcong@...il.com> wrote:
> llcp_sock_getname() checks llcp_sock->dev to make sure
> llcp_sock is already connected or bound, however, we could
> be in the middle of llcp_sock_bind() where llcp_sock->dev
> is bound and llcp_sock->service_name_len is set,
> but llcp_sock->service_name is not, in this case we would
> lead to copy some bytes from a NULL pointer.
>
> Just lock the sock since this is not a hot path anyway.
>
> Reported-by: Dmitry Vyukov <dvyukov@...gle.com>
> Cc: Lauro Ramos Venancio <lauro.venancio@...nbossa.org>
> Cc: Aloisio Almeida Jr <aloisio.almeida@...nbossa.org>
> Cc: Samuel Ortiz <sameo@...ux.intel.com>
> Signed-off-by: Cong Wang <xiyou.wangcong@...il.com>


Samuel, please take a look at this one too.


> ---
>  net/nfc/llcp_sock.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/net/nfc/llcp_sock.c b/net/nfc/llcp_sock.c
> index ecf0a01..b9edf5f 100644
> --- a/net/nfc/llcp_sock.c
> +++ b/net/nfc/llcp_sock.c
> @@ -509,6 +509,11 @@ static int llcp_sock_getname(struct socket *sock, struct sockaddr *uaddr,
>         memset(llcp_addr, 0, sizeof(*llcp_addr));
>         *len = sizeof(struct sockaddr_nfc_llcp);
>
> +       lock_sock(sk);
> +       if (!llcp_sock->dev) {
> +               release_sock(sk);
> +               return -EBADFD;
> +       }
>         llcp_addr->sa_family = AF_NFC;
>         llcp_addr->dev_idx = llcp_sock->dev->idx;
>         llcp_addr->target_idx = llcp_sock->target_idx;
> @@ -518,6 +523,7 @@ static int llcp_sock_getname(struct socket *sock, struct sockaddr *uaddr,
>         llcp_addr->service_name_len = llcp_sock->service_name_len;
>         memcpy(llcp_addr->service_name, llcp_sock->service_name,
>                llcp_addr->service_name_len);
> +       release_sock(sk);
>
>         return 0;
>  }
> --
> 1.8.3.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ