[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAM_iQpUxNYpkRetxX88z=iFZiZ1beQqBt+9qFsDTnAYwWCoHfA@mail.gmail.com>
Date: Wed, 16 Nov 2016 11:08:23 -0800
From: Cong Wang <xiyou.wangcong@...il.com>
To: Guillaume Nault <g.nault@...halink.fr>
Cc: Baozeng Ding <sploving1@...il.com>,
Linux Kernel Network Developers <netdev@...r.kernel.org>
Subject: Re: net/l2tp:BUG: KASAN: use-after-free in l2tp_ip6_close
On Wed, Nov 16, 2016 at 8:30 AM, Guillaume Nault <g.nault@...halink.fr> wrote:
> diff --git a/net/l2tp/l2tp_ip.c b/net/l2tp/l2tp_ip.c
> index fce25af..982f6c4 100644
> --- a/net/l2tp/l2tp_ip.c
> +++ b/net/l2tp/l2tp_ip.c
> @@ -251,8 +251,6 @@ static int l2tp_ip_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
> int ret;
> int chk_addr_ret;
>
> - if (!sock_flag(sk, SOCK_ZAPPED))
> - return -EINVAL;
> if (addr_len < sizeof(struct sockaddr_l2tpip))
> return -EINVAL;
> if (addr->l2tp_family != AF_INET)
> @@ -267,6 +265,9 @@ static int l2tp_ip_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
> read_unlock_bh(&l2tp_ip_lock);
>
> lock_sock(sk);
> + if (!sock_flag(sk, SOCK_ZAPPED))
> + goto out;
> +
> if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_l2tpip))
> goto out;
>
> diff --git a/net/l2tp/l2tp_ip6.c b/net/l2tp/l2tp_ip6.c
> index ad3468c..9978d01 100644
> --- a/net/l2tp/l2tp_ip6.c
> +++ b/net/l2tp/l2tp_ip6.c
> @@ -269,8 +269,6 @@ static int l2tp_ip6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
> int addr_type;
> int err;
>
> - if (!sock_flag(sk, SOCK_ZAPPED))
> - return -EINVAL;
> if (addr->l2tp_family != AF_INET6)
> return -EINVAL;
> if (addr_len < sizeof(*addr))
> @@ -296,6 +294,9 @@ static int l2tp_ip6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
> lock_sock(sk);
>
> err = -EINVAL;
> + if (!sock_flag(sk, SOCK_ZAPPED))
> + goto out_unlock;
> +
> if (sk->sk_state != TCP_CLOSE)
> goto out_unlock;
Makes sense, it should prevent a concurrent caller adding the socket
into bind table
twice after passing __l2tp_ip_bind_lookup() check.
Powered by blists - more mailing lists