Skip to content

Commit 53c5bbc

Browse files
author
CKI Backport Bot
committed
rtc: pcf85063: fix potential OOB write in PCF85063 NVMEM read
JIRA: https://issues.redhat.com/browse/RHEL-82456 CVE: CVE-2024-58069 commit 3ab8c5e Author: Oleksij Rempel <[email protected]> Date: Wed Dec 18 20:34:58 2024 +0100 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: fadfd09 ("rtc: pcf85063: add nvram support") Signed-off-by: Oleksij Rempel <[email protected]> Signed-off-by: Ahmad Fatoum <[email protected]> Link: https://lore.kernel.org/r/20241218-rtc-pcf85063-stack-corruption-v1-1-12fd0ee0f046@pengutronix.de Signed-off-by: Alexandre Belloni <[email protected]> Signed-off-by: CKI Backport Bot <[email protected]>
1 parent 5150d3a commit 53c5bbc

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

drivers/rtc/rtc-pcf85063.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,16 @@ static const struct rtc_class_ops pcf85063_rtc_ops = {
322322
static int pcf85063_nvmem_read(void *priv, unsigned int offset,
323323
void *val, size_t bytes)
324324
{
325-
return regmap_read(priv, PCF85063_REG_RAM, val);
325+
unsigned int tmp;
326+
int ret;
327+
328+
ret = regmap_read(priv, PCF85063_REG_RAM, &tmp);
329+
if (ret < 0)
330+
return ret;
331+
332+
*(u8 *)val = tmp;
333+
334+
return 0;
326335
}
327336

328337
static int pcf85063_nvmem_write(void *priv, unsigned int offset,

0 commit comments

Comments
 (0)