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: <20100629153326.GA4752@sortiz-mobl>
Date:	Tue, 29 Jun 2010 17:33:27 +0200
From:	Samuel Ortiz <sameo@...ux.intel.com>
To:	Rabin VINCENT <rabin.vincent@...ricsson.com>
Cc:	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	STEricsson_nomadik_linux <STEricsson_nomadik_linux@...t.st.com>,
	Linus WALLEIJ <linus.walleij@...ricsson.com>,
	"l.fu@...gutronix.de" <l.fu@...gutronix.de>
Subject: Re: [PATCHv2 1/3] mfd: add STMPE I/O Expander support

Hi Rabin,

On Tue, Jun 29, 2010 at 08:43:26AM +0530, Rabin VINCENT wrote:
> Hi Samuel,
> 
> On Mon, Jun 28, 2010 at 01:55:16 +0200, Samuel Ortiz wrote:
> > On Tue, Jun 22, 2010 at 07:25:27PM +0530, Rabin Vincent wrote:
> > > +int stmpe_reg_read(struct stmpe *stmpe, u8 reg)
> > > +{
> > > +	int ret;
> > > +
> > > +	ret = i2c_smbus_read_byte_data(stmpe->i2c, reg);
> > > +	if (ret < 0)
> > > +		dev_err(stmpe->dev, "failed to read reg %#x: %d\n",
> > > +			reg, ret);
> > > +
> > > +	dev_vdbg(stmpe->dev, "rd: reg %#x => data %#x\n", reg, ret);
> > > +
> > > +	return ret;
> > > +}
> > > +EXPORT_SYMBOL(stmpe_reg_read);
> > I think your locking is broken here.
> > If your exporting this routine (and the next ones below), you'd better make
> > sure you're under stmpe->lock for the stmpe register concurrent access.
> 
> stmpe_reg_read() and stmpe_reg_write() are just a call to one
> i2c_smbus_* function, and the I2C core takes a bus_lock internally
> preventing concurrent accesses.
> 
> The only place where the I2C core locking is not sufficient is the
> read/modify/write sequence, and we provide stmpe_set_bits() for that,
> which takes a lock.  If someone uses reg_read()/reg_write() sequences on
> registers where they should be using set_bits(), adding extra locking in
> reg_read()/reg_write() will not provide any additional safeguard.
> 
> The same scheme is used by adp5520.
> 
> Could you please explain why more locking is needed?
Without the extra locking, there's nothing preventing me from writing to a
register while you're in the middle of a stmpe_set_bits() call.

> > > +/**
> > > + * stmpe_block_write() - write multiple stmpe registers
> > > + * @stmpe:	device to write to
> > > + * @reg:	first register
> > > + * @length:	number of registers
> > > + * @values:	values to write
> > > + */
> > > +int stmpe_block_write(struct stmpe *stmpe, u8 reg, u8 length,
> > > +			const u8 *values)
> > > +{
> > > +	int ret;
> > > +
> > > +	dev_vdbg(stmpe->dev, "wr: regs %#x (%d)\n", reg, length);
> > > +#ifdef VERBOSE_DEBUG
> > > +	print_hex_dump_bytes("stmpe wr: ", dump_prefix_offset, values, length);
> > > +#endif
> > I don't really enjoy this part for 2 reasons:
> > - You should use a less generic ifdef switch, prefixed with STMPE_ for
> > example.
> 
> The dev_vdbg() in the previous line is activated via VERBOSE_DEBUG, so
> the idea was to have this dump use the same config.  
Ah, I didnt realize VERBOSE_DEBUG was defined from device.h. Should have
grepped for it in your patch, sorry.
I would still like it to be part of your header file though.

> I'll fix it as your recommended, though.  Will fix your other comments too.
Thanks in advance.

Cheers,
Samuel.


> Rabin

-- 
Intel Open Source Technology Centre
http://oss.intel.com/
--
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