rtc: pcf85063: fix potential OOB write in PCF85063 NVMEM read
authorOleksij Rempel <o.rempel@pengutronix.de>
Wed, 18 Dec 2024 19:34:58 +0000 (20:34 +0100)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Sun, 12 Jan 2025 23:26:54 +0000 (00:26 +0100)
commit3ab8c5ed4f84fa20cd16794fe8dc31f633fbc70c
tree7701af234464ecb8d5ae0165525b5a1723e0eb25
parent09c4a610153286cef54d4f0c85398f4e32fc227e
rtc: pcf85063: fix potential OOB write in PCF85063 NVMEM read

The nvmem interface supports variable buffer sizes, while the regmap
interface operates with fixed-size storage. If an nvmem client uses a
buffer size less than 4 bytes, regmap_read will write out of bounds
as it expects the buffer to point at an unsigned int.

Fix this by using an intermediary unsigned int to hold the value.

Fixes: fadfd092ee91 ("rtc: pcf85063: add nvram support")
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.kernel.org/r/20241218-rtc-pcf85063-stack-corruption-v1-1-12fd0ee0f046@pengutronix.de
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
drivers/rtc/rtc-pcf85063.c