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

drivers: ipmi: fix off-by-one bounds check that leads to a out-of-bounds write

The end of buffer check is off-by-one since the check is against
an index that is pre-incremented before a store to buf[]. Fix this
adjusting the bounds check appropriately.

Addresses-Coverity: ("Out-of-bounds write")
Fixes: 51bd6f291583 ("Add support for IPMB driver")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Message-Id: <20200114144031.358003-1-colin.king@canonical.com>
Reviewed-by: Asmaa Mnebhi <asmaa@mellanox.com>
Signed-off-by: Corey Minyard <cminyard@mvista.com>

authored by

Colin Ian King and committed by
Corey Minyard
e0354d14 6b8526d3

+1 -1
+1 -1
drivers/char/ipmi/ipmb_dev_int.c
··· 279 279 break; 280 280 281 281 case I2C_SLAVE_WRITE_RECEIVED: 282 - if (ipmb_dev->msg_idx >= sizeof(struct ipmb_msg)) 282 + if (ipmb_dev->msg_idx >= sizeof(struct ipmb_msg) - 1) 283 283 break; 284 284 285 285 buf[++ipmb_dev->msg_idx] = *val;