summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorWenwen Wang <wang6495@umn.edu>2018-05-05 07:57:10 -0500
committerWolfram Sang <wsa+renesas@sang-engineering.com>2026-05-19 12:43:08 +0200
commit023453cb7eb0f53c5dc36babed8e706c1b0b0187 (patch)
tree41392b4b880edfaf3b28f897e8badb3d4ea8434a /include
parent24214ad405d18efa14597d79ea737cc55c507517 (diff)
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>
Diffstat (limited to 'include')
0 files changed, 0 insertions, 0 deletions