Skip to contentSkip to conversation

m68k: q40: Fix info-leak in rtc_ioctl

PATCH In review Fuqian Huang 2 participants 2 messages Sep 27, 2019 m68k architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 m68k: q40: Fix info-leak in rtc_ioctl

When the option is RTC_PLL_GET, pll will be copied to userland via copy_to_user. pll is initialized using mach_get_rtc_pll indirect call and mach_get_rtc_pll is only assigned with function q40_get_rtc_pll in arch/m68k/q40/config.c.
In function q40_get_rtc_pll, the field pll_ctrl is not initialized. This will leak uninitialized stack content to userland. Fix this by zeroing the uninitialized field.

---
 arch/m68k/q40/config.c | 1 +
 1 file changed, 1 insertion(+)
arch/m68k/q40/config.c +1 -0
index e63eb5f06999..f31890078197 100644
@@ -264,6 +264,7 @@ static int q40_get_rtc_pll(struct rtc_pll_info *pll)
 {
 	int tmp = Q40_RTC_CTRL;
 
+	pll->pll_ctrl = 0;
 	pll->pll_value = tmp & Q40_RTC_PLL_MASK;
 	if (tmp & Q40_RTC_PLL_SIGN)
 		pll->pll_value = -pll->pll_value;
Signature · 1 line
2.11.0
maintainer Reviewed-by on v1 1/1
#1 lore raw

Hi Fuqian,

Quoted 9 lines · Fuqian Huang

When the option is RTC_PLL_GET, pll will be copied to userland via copy_to_user. pll is initialized using mach_get_rtc_pll indirect call and mach_get_rtc_pll is only assigned with function q40_get_rtc_pll in arch/m68k/q40/config.c.
In function q40_get_rtc_pll, the field pll_ctrl is not initialized. This will leak uninitialized stack content to userland. Fix this by zeroing the uninitialized field.

Thanks for your patch!

arch/m68k/q40/config.c static int q40_get_rtc_pll(struct rtc_pll_info *pll) · line 270

Quoted 10 lines
arch/m68k/q40/config.c +1 -0
@@ -264,6 +264,7 @@ static int q40_get_rtc_pll(struct rtc_pll_info *pll)
 {
        int tmp = Q40_RTC_CTRL;
 
+       pll->pll_ctrl = 0;
        pll->pll_value = tmp & Q40_RTC_PLL_MASK;
        if (tmp & Q40_RTC_PLL_SIGN)
                pll->pll_value = -pll->pll_value;

Nice catch!

i.e. will queue for v5.5.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds