<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/drivers/i2c/i2c-core.c, branch linux-3.2.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-3.2.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-3.2.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2018-03-03T15:51:01Z</updated>
<entry>
<title>i2c: core-smbus: prevent stack corruption on read I2C_BLOCK_DATA</title>
<updated>2018-03-03T15:51:01Z</updated>
<author>
<name>Jeremy Compostella</name>
</author>
<published>2017-11-15T19:31:44Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=fa05746dcb3132105d634eb72ec0d455af3be3cf'/>
<id>urn:sha1:fa05746dcb3132105d634eb72ec0d455af3be3cf</id>
<content type='text'>
commit 89c6efa61f5709327ecfa24bff18e57a4e80c7fa upstream.

On a I2C_SMBUS_I2C_BLOCK_DATA read request, if data-&gt;block[0] is
greater than I2C_SMBUS_BLOCK_MAX + 1, the underlying I2C driver writes
data out of the msgbuf1 array boundary.

It is possible from a user application to run into that issue by
calling the I2C_SMBUS ioctl with data.block[0] greater than
I2C_SMBUS_BLOCK_MAX + 1.

This patch makes the code compliant with
Documentation/i2c/dev-interface by raising an error when the requested
size is larger than 32 bytes.

Call Trace:
 [&lt;ffffffff8139f695&gt;] dump_stack+0x67/0x92
 [&lt;ffffffff811802a4&gt;] panic+0xc5/0x1eb
 [&lt;ffffffff810ecb5f&gt;] ? vprintk_default+0x1f/0x30
 [&lt;ffffffff817456d3&gt;] ? i2cdev_ioctl_smbus+0x303/0x320
 [&lt;ffffffff8109a68b&gt;] __stack_chk_fail+0x1b/0x20
 [&lt;ffffffff817456d3&gt;] i2cdev_ioctl_smbus+0x303/0x320
 [&lt;ffffffff81745aed&gt;] i2cdev_ioctl+0x4d/0x1e0
 [&lt;ffffffff811f761a&gt;] do_vfs_ioctl+0x2ba/0x490
 [&lt;ffffffff81336e43&gt;] ? security_file_ioctl+0x43/0x60
 [&lt;ffffffff811f7869&gt;] SyS_ioctl+0x79/0x90
 [&lt;ffffffff81a22e97&gt;] entry_SYSCALL_64_fastpath+0x12/0x6a

Signed-off-by: Jeremy Compostella &lt;jeremy.compostella@intel.com&gt;
Signed-off-by: Wolfram Sang &lt;wsa@the-dreams.de&gt;
[bwh: Backported to 3.2: adjust filename]
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</content>
</entry>
<entry>
<title>i2c: core: fix NULL pointer dereference under race condition</title>
<updated>2017-02-23T03:50:59Z</updated>
<author>
<name>Vladimir Zapolskiy</name>
</author>
<published>2016-10-31T19:46:24Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=06de3b4d33e4387e7803ddbf0978a8d7dc7541f9'/>
<id>urn:sha1:06de3b4d33e4387e7803ddbf0978a8d7dc7541f9</id>
<content type='text'>
commit 147b36d5b70c083cc76770c47d60b347e8eaf231 upstream.

Race condition between registering an I2C device driver and
deregistering an I2C adapter device which is assumed to manage that
I2C device may lead to a NULL pointer dereference due to the
uninitialized list head of driver clients.

The root cause of the issue is that the I2C bus may know about the
registered device driver and thus it is matched by bus_for_each_drv(),
but the list of clients is not initialized and commonly it is NULL,
because I2C device drivers define struct i2c_driver as static and
clients field is expected to be initialized by I2C core:

  i2c_register_driver()             i2c_del_adapter()
    driver_register()                 ...
      bus_add_driver()                ...
        ...                           bus_for_each_drv(..., __process_removed_adapter)
      ...                               i2c_do_del_adapter()
    ...                                   list_for_each_entry_safe(..., &amp;driver-&gt;clients, ...)
    INIT_LIST_HEAD(&amp;driver-&gt;clients);

To solve the problem it is sufficient to do clients list head
initialization before calling driver_register().

The problem was found while using an I2C device driver with a sluggish
registration routine on a bus provided by a physically detachable I2C
master controller, but practically the oops may be reproduced under
the race between arbitraty I2C device driver registration and managing
I2C bus device removal e.g. by unbinding the latter over sysfs:

% echo 21a4000.i2c &gt; /sys/bus/platform/drivers/imx-i2c/unbind
  Unable to handle kernel NULL pointer dereference at virtual address 00000000
  Internal error: Oops: 17 [#1] SMP ARM
  CPU: 2 PID: 533 Comm: sh Not tainted 4.9.0-rc3+ #61
  Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
  task: e5ada400 task.stack: e4936000
  PC is at i2c_do_del_adapter+0x20/0xcc
  LR is at __process_removed_adapter+0x14/0x1c
  Flags: NzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
  Control: 10c5387d  Table: 35bd004a  DAC: 00000051
  Process sh (pid: 533, stack limit = 0xe4936210)
  Stack: (0xe4937d28 to 0xe4938000)
  Backtrace:
  [&lt;c0667be0&gt;] (i2c_do_del_adapter) from [&lt;c0667cc0&gt;] (__process_removed_adapter+0x14/0x1c)
  [&lt;c0667cac&gt;] (__process_removed_adapter) from [&lt;c0516998&gt;] (bus_for_each_drv+0x6c/0xa0)
  [&lt;c051692c&gt;] (bus_for_each_drv) from [&lt;c06685ec&gt;] (i2c_del_adapter+0xbc/0x284)
  [&lt;c0668530&gt;] (i2c_del_adapter) from [&lt;bf0110ec&gt;] (i2c_imx_remove+0x44/0x164 [i2c_imx])
  [&lt;bf0110a8&gt;] (i2c_imx_remove [i2c_imx]) from [&lt;c051a838&gt;] (platform_drv_remove+0x2c/0x44)
  [&lt;c051a80c&gt;] (platform_drv_remove) from [&lt;c05183d8&gt;] (__device_release_driver+0x90/0x12c)
  [&lt;c0518348&gt;] (__device_release_driver) from [&lt;c051849c&gt;] (device_release_driver+0x28/0x34)
  [&lt;c0518474&gt;] (device_release_driver) from [&lt;c0517150&gt;] (unbind_store+0x80/0x104)
  [&lt;c05170d0&gt;] (unbind_store) from [&lt;c0516520&gt;] (drv_attr_store+0x28/0x34)
  [&lt;c05164f8&gt;] (drv_attr_store) from [&lt;c0298acc&gt;] (sysfs_kf_write+0x50/0x54)
  [&lt;c0298a7c&gt;] (sysfs_kf_write) from [&lt;c029801c&gt;] (kernfs_fop_write+0x100/0x214)
  [&lt;c0297f1c&gt;] (kernfs_fop_write) from [&lt;c0220130&gt;] (__vfs_write+0x34/0x120)
  [&lt;c02200fc&gt;] (__vfs_write) from [&lt;c0221088&gt;] (vfs_write+0xa8/0x170)
  [&lt;c0220fe0&gt;] (vfs_write) from [&lt;c0221e74&gt;] (SyS_write+0x4c/0xa8)
  [&lt;c0221e28&gt;] (SyS_write) from [&lt;c0108a20&gt;] (ret_fast_syscall+0x0/0x1c)

Signed-off-by: Vladimir Zapolskiy &lt;vladimir_zapolskiy@mentor.com&gt;
Signed-off-by: Wolfram Sang &lt;wsa@the-dreams.de&gt;
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</content>
</entry>
<entry>
<title>i2c: Fix device name for 10-bit slave address</title>
<updated>2011-11-23T10:33:07Z</updated>
<author>
<name>Jean Delvare</name>
</author>
<published>2011-11-23T10:33:07Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=cbb44514048a250647c6c6b3df27ff62cb71f7d5'/>
<id>urn:sha1:cbb44514048a250647c6c6b3df27ff62cb71f7d5</id>
<content type='text'>
10-bit addresses overlap with traditional 7-bit addresses, leading in
device name collisions. Add an arbitrary offset to 10-bit addresses to
prevent this collision. The offset was chosen so that the address is
still easily recognizable.

Signed-off-by: Jean Delvare &lt;khali@linux-fr.org&gt;
Acked-by: Wolfram Sang &lt;w.sang@pengutronix.de&gt;
</content>
</entry>
<entry>
<title>i2c: Allow i2c_add_numbered_adapter() to assign a bus id</title>
<updated>2011-07-25T15:49:43Z</updated>
<author>
<name>Grant Likely</name>
</author>
<published>2011-07-25T15:49:43Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=488bf314bf219c66922305a1a320950efa86662f'/>
<id>urn:sha1:488bf314bf219c66922305a1a320950efa86662f</id>
<content type='text'>
Currently, if an i2c bus driver supports both static and dynamic bus
ids, it needs to choose between calling i2c_add_numbered_adapter() and
i2c_add_adapter().  This patch makes i2c_add_numbered_adapter()
redirect to i2c_add_adapter() if the requested bus id is -1.

Signed-off-by: Grant Likely &lt;grant.likely@secretlab.ca&gt;
Signed-off-by: Jean Delvare &lt;khali@linux-fr.org&gt;
</content>
</entry>
<entry>
<title>i2c: Improve deprecation warnings</title>
<updated>2011-04-17T08:20:19Z</updated>
<author>
<name>Jean Delvare</name>
</author>
<published>2011-04-17T08:20:19Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=a920ff41cb3d2b03da095c4fa1a11b71417ae2a4'/>
<id>urn:sha1:a920ff41cb3d2b03da095c4fa1a11b71417ae2a4</id>
<content type='text'>
When warning on the use of deprecated i2c_driver methods
attach_adapter and detach_adapter, mention the name of the driver
which needs to be updated.

Signed-off-by: Jean Delvare &lt;khali@linux-fr.org&gt;
Cc: Benjamin Herrenschmidt &lt;benh@kernel.crashing.org&gt;
</content>
</entry>
<entry>
<title>Fix common misspellings</title>
<updated>2011-03-31T14:26:23Z</updated>
<author>
<name>Lucas De Marchi</name>
</author>
<published>2011-03-31T01:57:33Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=25985edcedea6396277003854657b5f3cb31a628'/>
<id>urn:sha1:25985edcedea6396277003854657b5f3cb31a628</id>
<content type='text'>
Fixes generated by 'codespell' and manually reviewed.

Signed-off-by: Lucas De Marchi &lt;lucas.demarchi@profusion.mobi&gt;
</content>
</entry>
<entry>
<title>i2c: Deprecate i2c_driver.attach_adapter and .detach_adapter</title>
<updated>2011-03-20T13:50:53Z</updated>
<author>
<name>Jean Delvare</name>
</author>
<published>2011-03-20T13:50:53Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=fe6fc25857d293546bd400432cdb77866c797c9b'/>
<id>urn:sha1:fe6fc25857d293546bd400432cdb77866c797c9b</id>
<content type='text'>
The last legitimate user of i2c_driver.attach_adapter and
.detach_adapter is gone, so we can finally deprecate these callbacks.
The last few drivers which still use these will have to be updated to
make use of standard I2C device instantiation ways instead.

Signed-off-by: Jean Delvare &lt;khali@linux-fr.org&gt;
</content>
</entry>
<entry>
<title>i2c: Export i2c_for_each_dev</title>
<updated>2011-03-20T13:50:52Z</updated>
<author>
<name>Jean Delvare</name>
</author>
<published>2011-03-20T13:50:52Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=7ae31482a8376fb0df3a0c5ff0677a92820c06b7'/>
<id>urn:sha1:7ae31482a8376fb0df3a0c5ff0677a92820c06b7</id>
<content type='text'>
Introduce i2c_for_each_dev(), an i2c device iterator with proper
locking for use by i2c-dev. This is needed so that we can get rid of
the attach_adapter and detach_adapter legacy callback functions.

Signed-off-by: Jean Delvare &lt;khali@linux-fr.org&gt;
</content>
</entry>
<entry>
<title>i2c: make i2c_get_adapter prototype clearer</title>
<updated>2011-03-20T13:50:52Z</updated>
<author>
<name>Jean Delvare</name>
</author>
<published>2011-03-20T13:50:52Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=d735b34db30b7891ff76b552d18ecb0ce04a2bc2'/>
<id>urn:sha1:d735b34db30b7891ff76b552d18ecb0ce04a2bc2</id>
<content type='text'>
Rename the parameter of i2c_get_adapter() to "nr", to make it clear we
are passing an adapter number and not an adapter ID (which have gone
away by now.)

Signed-off-by: Jean Delvare &lt;khali@linux-fr.org&gt;
</content>
</entry>
<entry>
<title>driver-core: remove conditionals around devicetree pointers</title>
<updated>2011-01-21T16:24:48Z</updated>
<author>
<name>Grant Likely</name>
</author>
<published>2011-01-21T16:24:48Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=c9e358dfc4a8cb2227172ef77908c2e0ee17bcb9'/>
<id>urn:sha1:c9e358dfc4a8cb2227172ef77908c2e0ee17bcb9</id>
<content type='text'>
Having conditional around the of_match_table and the of_node pointers
turns out to make driver code use ugly #ifdef blocks.  Drop the
conditionals and remove the #ifdef blocks from the affected drivers.

Also tidy up minor whitespace issues within the same hunks.

Signed-off-by: Grant Likely &lt;grant.likely@secretlab.ca&gt;
Acked-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;
</content>
</entry>
</feed>
