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  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:	Fri, 9 Jan 2015 10:55:16 +0000
From:	Thomas Graf <tgraf@...g.ch>
To:	Ying Xue <ying.xue@...driver.com>
Cc:	davem@...emloft.net, netdev@...r.kernel.org
Subject: Re: [PATCH net-next 2/3] netlink: eliminate nl_sk_hash_lock

On 01/09/15 at 04:23pm, Ying Xue wrote:
>  static struct sock *netlink_lookup(struct net *net, int protocol, u32 portid)
>  {
>  	struct netlink_table *table = &nl_table[protocol];
> @@ -1041,41 +1050,33 @@ netlink_update_listeners(struct sock *sk)
>  static int netlink_insert(struct sock *sk, struct net *net, u32 portid)
>  {
>  	struct netlink_table *table = &nl_table[sk->sk_protocol];
> -	int err = -EADDRINUSE;
> -
> -	mutex_lock(&nl_sk_hash_lock);
> -	if (__netlink_lookup(table, portid, net))
> -		goto err;
>  
> -	err = -EBUSY;
>  	if (nlk_sk(sk)->portid)
> -		goto err;
> +		return -EBUSY;
>  
> -	err = -ENOMEM;
>  	if (BITS_PER_LONG > 32 &&
>  	    unlikely(atomic_read(&table->hash.nelems) >= UINT_MAX))
> -		goto err;
> +		return -ENOMEM;
>  
>  	nlk_sk(sk)->portid = portid;

Since this code can now run in parallel, there is a race between
checking portid and then setting it. CPU#1 could overwrite portid after
CPU#0 has already checked portid, this would then insert the socket on
CPU#0 with the portid created on CPU#1. So this would need some kind
of atomic operation.
--
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