Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

i2c: core-smbus: don't trace smbus_reply data on errors

If an smbus transfer fails, there's no guarantee that the output
buffer was written. So, avoid trying to show the output buffer when
tracing after an error. This was 'mostly harmless', but would trip
up kasan checking if left-over cruft in byte 0 is a large length,
causing us to read from unwritten memory.

Signed-off-by: John Sperbeck <jsperbeck@google.com>
Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>

authored by

John Sperbeck and committed by
Wolfram Sang
d8434c31 237b5f66

+4 -4
+1 -1
drivers/i2c/i2c-core-smbus.c
··· 585 585 trace: 586 586 /* If enabled, the reply tracepoint is conditional on read_write. */ 587 587 trace_smbus_reply(adapter, addr, flags, read_write, 588 - command, protocol, data); 588 + command, protocol, data, res); 589 589 trace_smbus_result(adapter, addr, flags, read_write, 590 590 command, protocol, res); 591 591
+3 -3
include/trace/events/smbus.h
··· 138 138 TP_PROTO(const struct i2c_adapter *adap, 139 139 u16 addr, unsigned short flags, 140 140 char read_write, u8 command, int protocol, 141 - const union i2c_smbus_data *data), 142 - TP_ARGS(adap, addr, flags, read_write, command, protocol, data), 143 - TP_CONDITION(read_write == I2C_SMBUS_READ), 141 + const union i2c_smbus_data *data, int res), 142 + TP_ARGS(adap, addr, flags, read_write, command, protocol, data, res), 143 + TP_CONDITION(res >= 0 && read_write == I2C_SMBUS_READ), 144 144 TP_STRUCT__entry( 145 145 __field(int, adapter_nr ) 146 146 __field(__u16, addr )