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]
Date:	Mon, 14 Sep 2015 09:43:47 -0700
From:	Eric Dumazet <eric.dumazet@...il.com>
To:	Sasha Levin <sasha.levin@...cle.com>
Cc:	xeb@...l.ru, ebiederm@...ssion.com, davem@...emloft.net,
	simon@...nz.org.uk, netdev@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] pptp: avoid releasing the sock too early

On Mon, 2015-09-14 at 11:40 -0400, Sasha Levin wrote:
> Since we're using RCU we can't free the sock structure before RCU lets us,
> otherwise we're risking getting use-after-frees accessing it:

> 
> Signed-off-by: Sasha Levin <sasha.levin@...cle.com>
> ---
>  drivers/net/ppp/pptp.c   |    9 ++++++++-
>  include/linux/if_pppox.h |    1 +
>  2 files changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ppp/pptp.c b/drivers/net/ppp/pptp.c
> index 686f37d..cb7a029 100644
> --- a/drivers/net/ppp/pptp.c
> +++ b/drivers/net/ppp/pptp.c
> @@ -517,6 +517,13 @@ static int pptp_getname(struct socket *sock, struct sockaddr *uaddr,
>  	return 0;
>  }
>  
> +static void pptp_release_cb(struct rcu_head *rcu)
> +{
> +	struct pppox_sock *p = container_of(rcu, struct pppox_sock, rcu);
> +
> +	sock_put(sk_pppox(p));
> +}
> +
>  static int pptp_release(struct socket *sock)
>  {
>  	struct sock *sk = sock->sk;
> @@ -545,7 +552,7 @@ static int pptp_release(struct socket *sock)
>  	sock->sk = NULL;
>  
>  	release_sock(sk);
> -	sock_put(sk);
> +	call_rcu(&po->rcu, pptp_release_cb);
>  
>  	return error;
>  }
> diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
> index b49cf92..ba9c378 100644
> --- a/include/linux/if_pppox.h
> +++ b/include/linux/if_pppox.h
> @@ -55,6 +55,7 @@ struct pppox_sock {
>  		struct pptp_opt  pptp;
>  	} proto;
>  	__be16			num;
> +	struct rcu_head rcu;
>  };
>  #define pppoe_dev	proto.pppoe.dev
>  #define pppoe_ifindex	proto.pppoe.ifindex

Hmm, is the synchronize_rcu() in del_chan() still needed, and why it was
not enough ?

I believe your patch might reduce the race window, but it is not clear
it is the right fix.



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ