From 39ce73504695500e043d2851e3d4938fcae89399 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Tue, 5 Oct 2021 16:16:11 +0100 Subject: ipmi: ipmb: Fix off-by-one size check on rcvlen There is an off-by-one bounds check on the rcvlen causing a potential out of bounds write on iidev->rcvmsg. Fix this by using the >= operator on the bounds check rather than the > operator. Addresses-Coverity: ("Out-of-bounds write") Fixes: 0ba0c3c5d1c1 ("ipmi:ipmb: Add initial support for IPMI over IPMB") Signed-off-by: Colin Ian King Message-Id: <20211005151611.305383-1-colin.king@canonical.com> Signed-off-by: Corey Minyard --- drivers/char/ipmi/ipmi_ipmb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/char/ipmi') diff --git a/drivers/char/ipmi/ipmi_ipmb.c b/drivers/char/ipmi/ipmi_ipmb.c index 742ae10166af..856e432fa04c 100644 --- a/drivers/char/ipmi/ipmi_ipmb.c +++ b/drivers/char/ipmi/ipmi_ipmb.c @@ -192,7 +192,7 @@ static int ipmi_ipmb_slave_cb(struct i2c_client *client, break; case I2C_SLAVE_WRITE_RECEIVED: - if (iidev->rcvlen > sizeof(iidev->rcvmsg)) + if (iidev->rcvlen >= sizeof(iidev->rcvmsg)) iidev->overrun = true; else iidev->rcvmsg[iidev->rcvlen++] = *val; -- cgit v1.2.3