mirror-linux/drivers/i2c
Wenwen Wang 023453cb7e i2c: smbus: fix a potential uninitialization bug
In i2c_smbus_xfer_emulated(), there are two buffers: msgbuf0 and
msgbuf1, which are used to save a series of messages, as mentioned in
the comment. According to the value of the variable 'size', msgbuf0 is
initialized to various values. In contrast, msgbuf1 is left
uninitialized until the function i2c_transfer() is invoked. However,
msgbuf1 is not always initialized on all possible execution paths
(implementation) of i2c_transfer(). Thus, it is possible that msgbuf1
may still be uninitialized even after the invocation of the function
i2c_transfer(), especially when the return value of i2c_transfer() is
not checked properly. In the following execution, the uninitialized
msgbuf1 will be used, such as for security checks. Since uninitialized
values can be random and arbitrary, this will cause undefined behaviors
or even check bypass. For example, it is expected that if the value of
'size' is I2C_SMBUS_BLOCK_PROC_CALL, the value of data->block[0] should
not be larger than I2C_SMBUS_BLOCK_MAX. This patch initializes the first
byte of msgbuf1 with 0 to avoid such undefined behaviors or security
issues.

Signed-off-by: Wenwen Wang <wang6495@umn.edu>
[wsa: reworded commit message a little]
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
2026-05-19 12:43:08 +02:00
..
algos i2c: pcf8584: Change pcf_doAdress() to pcf_send_address() 2025-10-28 17:05:39 +01:00
busses i2c: tegra: make tegra_i2c_mutex_unlock() return void 2026-05-14 00:14:20 +02:00
muxes i2c: muxes: pca954x: Fix broken reset-gpio usage 2025-11-03 18:04:15 +01:00
Kconfig i2c: Remove I2C_COMPAT config symbol and related code 2024-09-07 18:31:28 +02:00
Makefile i2c: Introduce OF component probe function 2024-11-27 12:04:10 +01:00
i2c-atr.c i2c: atr: use kzalloc_flex 2026-04-10 01:16:59 +02:00
i2c-boardinfo.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
i2c-core-acpi.c i2c: acpi: Add ELAN0678 to i2c_acpi_force_100khz_device_ids 2026-05-04 11:17:46 +02:00
i2c-core-base.c i2c: Compare the return value of gpiod_get_direction against GPIO_LINE_DIRECTION_OUT 2026-05-04 12:19:25 +02:00
i2c-core-of-prober.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
i2c-core-of.c device property: Make modifications of fwnode "flags" thread safe 2026-03-26 22:00:59 +01:00
i2c-core-slave.c i2c: Use trace_call__##name() at guarded tracepoint call sites 2026-03-26 10:24:39 -04:00
i2c-core-smbus.c i2c: smbus: fix a potential uninitialization bug 2026-05-19 12:43:08 +02:00
i2c-core.h i2c: Unexport i2c_of_match_device() 2025-02-13 16:47:52 +01:00
i2c-dev.c i2c: dev: prevent integer overflow in I2C_TIMEOUT ioctl 2026-05-04 11:31:35 +02:00
i2c-mux.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
i2c-slave-eeprom.c sysfs: treewide: switch back to bin_attribute::read()/write() 2025-06-17 10:44:13 +02:00
i2c-slave-testunit.c i2c: testunit: Replace system_long_wq with system_dfl_long_wq 2026-05-04 10:07:46 +02:00
i2c-smbus.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
i2c-stub.c i2c: stub: Reject I2C block transfers with invalid length 2026-05-04 13:23:53 +02:00