Skip to contentSkip to conversation

ARM: bcm2835: Fix integer overflow in rpi_firmware_print_firmware_revision()

PATCH Applied Andy Shevchenko 4 participants 5 messages Jun 16, 2020 – Jun 17, 2020 Broadcom BCM2711/BCM2835 Arm architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: bcm2835: Fix integer overflow in rpi_firmware_print_firmware_revision()

time64_t is 64-bit width type, we are not supposed to supply lesser ones as in the case of rpi_firmware_print_firmware_revision() after the commit 4a60f58ee002 ("ARM: bcm2835: Switch to use %ptT"). Use temporary variable of time64_t type to correctly handle lesser types.

Fixes 4a60f58ee002 ("ARM: bcm2835: Switch to use %ptT")
Cc Petr Mladek <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Sergey Senozhatsky <[email protected]>
---
 drivers/firmware/raspberrypi.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/firmware/raspberrypi.c +4 -1
index ef8098856a47..625c8fdceabf 100644
@@ -181,6 +181,7 @@ EXPORT_SYMBOL_GPL(rpi_firmware_property);
 static void
 rpi_firmware_print_firmware_revision(struct rpi_firmware *fw)
 {
+	time64_t date_and_time;
 	u32 packet;
 	int ret = rpi_firmware_property(fw,
 					RPI_FIRMWARE_GET_FIRMWARE_REVISION,
@@ -189,7 +190,9 @@ rpi_firmware_print_firmware_revision(struct rpi_firmware *fw)
 	if (ret)
 		return;
 
-	dev_info(fw->cl.dev, "Attached to firmware from %ptT\n", &packet);
+	/* This is not compatible with y2038 */
+	date_and_time = packet;
+	dev_info(fw->cl.dev, "Attached to firmware from %ptT\n", &date_and_time);
 }
 
 static void
Signature · 1 line
2.27.0.rc2
Reviewed-by Tested-by on v1 1/1
#1 lore raw
Quoted 5 lines · Andy Shevchenko

time64_t is 64-bit width type, we are not supposed to supply lesser ones as in the case of rpi_firmware_print_firmware_revision() after the commit 4a60f58ee002 ("ARM: bcm2835: Switch to use %ptT"). Use temporary variable of time64_t type to correctly handle lesser types.

Quoted 8 lines
Fixes 4a60f58ee002 ("ARM: bcm2835: Switch to use %ptT")
Cc Petr Mladek <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Sergey Senozhatsky <[email protected]>

---

If this doesn't fit the printk tree I don't mind taking it trough the rpi soc tree.

I'll also update the MAINTAINERS file so the firmware driver isn't orphaned.

Thanks!
Nicolas

#2 lore raw
Quoted 7 lines · Nicolas Saenz Julienne
Quoted 6 lines · Andy Shevchenko

time64_t is 64-bit width type, we are not supposed to supply lesser ones as in the case of rpi_firmware_print_firmware_revision() after the commit 4a60f58ee002 ("ARM: bcm2835: Switch to use %ptT"). Use temporary variable of time64_t type to correctly handle lesser types.

Fixes 4a60f58ee002 ("ARM: bcm2835: Switch to use %ptT")

[..]

Quoted 3 lines

If this doesn't fit the printk tree I don't mind taking it trough the rpi soc tree.

I think, for this patch, SoC tree might be a better fit than printk tree, thanks.

	-ss
#3 lore raw
In reply to Nicolas Saenz Julienne
Quoted 15 lines · Nicolas Saenz Julienne
Quoted 5 lines · Andy Shevchenko

time64_t is 64-bit width type, we are not supposed to supply lesser ones as in the case of rpi_firmware_print_firmware_revision() after the commit 4a60f58ee002 ("ARM: bcm2835: Switch to use %ptT"). Use temporary variable of time64_t type to correctly handle lesser types.

Quoted 8 lines
Fixes 4a60f58ee002 ("ARM: bcm2835: Switch to use %ptT")
Cc Petr Mladek <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Sergey Senozhatsky <[email protected]>

---

Quoted 2 lines
Quoted 4 lines

If this doesn't fit the printk tree I don't mind taking it trough the rpi soc tree.

I'll also update the MAINTAINERS file so the firmware driver isn't orphaned.

I agree with Sergey that this should better go via SOC tree.

That said, feel free to ask to take it via printk tree. It has caused the regression after all ;-)

Best Regards,
Petr

#4 lore raw
In reply to Andy Shevchenko
Quoted 5 lines · Andy Shevchenko

time64_t is 64-bit width type, we are not supposed to supply lesser ones as in the case of rpi_firmware_print_firmware_revision() after the commit 4a60f58ee002 ("ARM: bcm2835: Switch to use %ptT"). Use temporary variable of time64_t type to correctly handle lesser types.

Quoted 8 lines
Fixes 4a60f58ee002 ("ARM: bcm2835: Switch to use %ptT")
Cc Petr Mladek <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Sergey Senozhatsky <[email protected]>

---

Applied to fixes branch,

Thanks,
Nicolas