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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1463576621.18194.96.camel@edumazet-glaptop3.roam.corp.google.com>
Date:	Wed, 18 May 2016 06:03:41 -0700
From:	Eric Dumazet <eric.dumazet@...il.com>
To:	Andrey Ryabinin <aryabinin@...tuozzo.com>
Cc:	"David S. Miller" <davem@...emloft.net>,
	Hannes Frederic Sowa <hannes@...essinduktion.org>,
	Rainer Weikusat <rweikusat@...ileactivedefense.com>,
	Eric Dumazet <edumazet@...gle.com>, netdev@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] net: sock: move ->sk_shutdown out of bitfields.

On Wed, 2016-05-18 at 15:03 +0300, Andrey Ryabinin wrote:
> ->sk_shutdown bits share one bitfield with some other bits in sock struct,
> such as ->sk_no_check_[r,t]x, ->sk_userlocks ...
> sock_setsockopt() may write to these bits, while holding the socket lock.
> 
> In case of AF_UNIX sockets, we change ->sk_shutdown bits while holding only
> unix_state_lock(). So concurrent setsockopt() and shutdown() may lead
> to corrupting these bits.
> 
> Fix this by moving ->sk_shutdown bits out of bitfield into a separate byte.
> This will not change the 'struct sock' size since ->sk_shutdown moved into
> previously unused 16-bit hole.
> 
> Signed-off-by: Andrey Ryabinin <aryabinin@...tuozzo.com>
> Suggested-by: Hannes Frederic Sowa <hannes@...essinduktion.org>
> ---
>  include/net/sock.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/net/sock.h b/include/net/sock.h
> index c9c8b19..04dc131 100644
> --- a/include/net/sock.h
> +++ b/include/net/sock.h
> @@ -383,8 +383,7 @@ struct sock {
>  	int			sk_sndbuf;
>  	struct sk_buff_head	sk_write_queue;
>  	kmemcheck_bitfield_begin(flags);
> -	unsigned int		sk_shutdown  : 2,


Please replace by a padding, so that sk_protocol is sill a byte,
not 8 bits spaning 2 bytes in memory.

> -				sk_no_check_tx : 1,
> +	unsigned int		sk_no_check_tx : 1,
>  				sk_no_check_rx : 1,
>  				sk_userlocks : 4,
>  				sk_protocol  : 8,
> @@ -418,6 +417,7 @@ struct sock {
>  	struct timer_list	sk_timer;
>  	ktime_t			sk_stamp;
>  	u16			sk_tsflags;
> +	u8			sk_shutdown;
>  	u32			sk_tskey;
>  	struct socket		*sk_socket;
>  	void			*sk_user_data;

Thanks.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ