]> www.infradead.org Git - users/jedix/linux-maple.git/commit
eth: fbnic: fix memory corruption in fbnic_tlv_attr_get_string()
authorDan Carpenter <dan.carpenter@linaro.org>
Fri, 7 Mar 2025 09:28:48 +0000 (12:28 +0300)
committerJakub Kicinski <kuba@kernel.org>
Mon, 10 Mar 2025 20:17:33 +0000 (13:17 -0700)
commit991a1b09920bc15c66f64c1e7d15cdabd3816c46
treeb579ada2a2800899fd02787d1082e60f63a67eb1
parent473367a5ffe1607a61be481e2feda684eb5faea9
eth: fbnic: fix memory corruption in fbnic_tlv_attr_get_string()

This code is trying to ensure that the last byte of the buffer is a NUL
terminator.  However, the problem is that attr->value[] is an array of
__le32, not char, so it zeroes out 4 bytes way beyond the end of the
buffer.  Cast the buffer to char to address this.

Fixes: e5cf5107c9e4 ("eth: fbnic: Update fbnic_tlv_attr_get_string() to work like nla_strscpy()")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Lee Trager <lee@trager.us>
Link: https://patch.msgid.link/2791d4be-ade4-4e50-9b12-33307d8410f6@stanley.mountain
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/meta/fbnic/fbnic_tlv.c