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: <1506956029.8061.8.camel@edumazet-glaptop3.roam.corp.google.com>
Date:   Mon, 02 Oct 2017 07:53:49 -0700
From:   Eric Dumazet <eric.dumazet@...il.com>
To:     Florian Westphal <fw@...len.de>
Cc:     netdev@...r.kernel.org
Subject: Re: [PATCH net-next v2] net: core: decouple ifalias get/set from
 rtnl lock

On Mon, 2017-10-02 at 12:27 +0200, Florian Westphal wrote:
> Device alias can be set by either rtnetlink (rtnl is held) or sysfs.
> 
> rtnetlink hold the rtnl mutex, sysfs acquires it for this purpose.
> Add an extra mutex for it plus a seqcount to get a consistent snapshot
> of the alias buffer.


> +int dev_get_alias(const struct net_device *dev, char *alias, size_t len)
> +{
> +	unsigned int seq;
> +	int ret;
> +
> +	for (;;) {
> +		const char *name;
> +
> +		ret = 0;
> +		rcu_read_lock();
> +		name = rcu_dereference(dev->ifalias);
> +		seq = raw_seqcount_begin(&ifalias_rename_seq);
> +		if (name)
> +			ret = snprintf(alias, len, "%s", name);
> +		rcu_read_unlock();
> +
> +		if (!read_seqcount_retry(&ifalias_rename_seq, seq))
> +			break;
> +
> +		cond_resched();
> +	}
> +
> +	return ret;
> +}

I believe this too complex and not needed.

Just use RCU : A writer is supposed to work on a private copy, and
_then_ publish the new pointer, so that a reader can not see mangled
string.

We either copy the 'old' name or the 'new' one.

A seqcount is not needed, and wont prevent you from reading the value
right before a change anyway.



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ