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: <20210618115104.GB4920@sirena.org.uk>
Date:   Fri, 18 Jun 2021 12:51:04 +0100
From:   Mark Brown <broonie@...nel.org>
To:     Srinivas Kandagatla <srinivas.kandagatla@...aro.org>
Cc:     srivasam@...eaurora.org, rafael@...nel.org,
        dp@...nsource.wolfsonmicro.com, linux-kernel@...r.kernel.org,
        stable@...r.kernel.org, Marek Szyprowski <m.szyprowski@...sung.com>
Subject: Re: [PATCH] regmap: move readable check before accessing regcache.

On Fri, Jun 18, 2021 at 12:35:58PM +0100, Srinivas Kandagatla wrote:

> The issue that I encountered is when doing regmap_update_bits on
> a write only register. In regcache path this will not do the right
> thing as the register is not readable and driver which is using
> regmap_update_bits will never notice that it can not do a update
> bits on write only register leading to inconsistent writes and
> random hardware behavior.

Why will use of regmap_update_bits() mean that a driver will never
notice a write failure?  Shouldn't remgap_update_bits() be fixed to
report any errors it isn't reporting, or the driver fixed to check 
error codes?  I really don't understand the issue you're trying to
report - what is "the right thing" and what makes you believe that a
driver can't do an _update_bits() on a write only but cached register?
Can you specify in concrete terms what the problem is.

> There seems to be missing checks in regcache_read() which is
> now added by moving the orignal check in _regmap_read() before
> accessing regcache.

> Cc: stable@...r.kernel.org
> Fixes: 5d1729e7f02f ("regmap: Incorporate the regcache core into regmap")

Are you *sure* you've identified the actual issue here - nobody has seen
any problems with this in the past decade?  Please don't just pick a
random commit for the sake of adding a Fixes tag.

> @@ -2677,6 +2677,9 @@ static int _regmap_read(struct regmap *map, unsigned int reg,
>  	int ret;
>  	void *context = _regmap_map_get_context(map);
>  
> +	if (!regmap_readable(map, reg))
> +		return -EIO;
> +
>  	if (!map->cache_bypass) {
>  		ret = regcache_read(map, reg, val);
>  		if (ret == 0)
> @@ -2686,9 +2689,6 @@ static int _regmap_read(struct regmap *map, unsigned int reg,
>  	if (map->cache_only)
>  		return -EBUSY;
>  
> -	if (!regmap_readable(map, reg))
> -		return -EIO;
> -

This puts the readability check before the cache check which will break
all drivers using the cache on write only registers.

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ