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, 02 Dec 2013 10:51:00 +0100
From:	Philippe Rétornaz <philippe.retornaz@...il.com>
To:	Alexander Shiyan <shc_work@...l.ru>
CC:	linux-kernel@...r.kernel.org, Samuel Ortiz <sameo@...ux.intel.com>,
	Sascha Hauer <kernel@...gutronix.de>,
	Shawn Guo <shawn.guo@...aro.org>,
	Lee Jones <lee.jones@...aro.org>,
	linux-arm-kernel@...ts.infradead.org
Subject: Re: [PATCH RESEND] mfd: mc13xxx: Remove unneeded mc13xxx_lock/unlock

Le 30/11/2013 06:01, Alexander Shiyan a écrit :
> Locking is performed by regmap API so no additional locking is
> needed. Nevertheless, keep locking in the ADC conversion routine.
> This need for keep proper read ADC sequence when calling from adc &
> touchscreen drivers.

You can't do that so easily !
Regmap only protect against concurrent access to the SPI/I2C bus, but do
not protect the driver's internal data.
And it does not protect against a race between concurrent access at a
higher level :

reg = regmap_read();
(modify reg)
regmap_write(reg);

And we do have such behavior:
* The mc13xxx->irqhandler/irqdata array is
   protected by this mutex.

* And we also have non-atomic RMW in mc13xxx_irq_unmask():

ret = mc13xxx_reg_read(mc13xxx, offmask, &mask);
if (ret)
	return ret;
if (!(mask & irqbit))
	return 0;
return mc13xxx_reg_write(mc13xxx, offmask, mask & ~irqbit);

It's OK to do this if you are protected by a mutex, but as soon as you
remove it you will have concurrency between two irq_unmask/irq_mask.

So you can remove the lock from trivial function like:
	mc13xxx_lock(led->master);
  	mc13xxx_reg_rmw(led->master, reg, mask << shift, value << shift);
	mc13xxx_unlock(led->master);

Which protect only a single access to regmap.

But we need to keep it for more complex behavior.

Regards,

Philippe
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ