Skip to contentSkip to conversation

media: rcar_drif: fix a memory disclosure

PATCH In review Kangjie Lu 2 participants 2 messages Oct 18, 2019 – Oct 21, 2019

Subsystems (2)
lore
Share & tools
lore

Kangjie Lu

author
#0 lore raw

PATCH 1/1 media: rcar_drif: fix a memory disclosure

"f->fmt.sdr.reserved" is uninitialized. As other peer drivers like msi2500 and airspy do, the fix initializes it to avoid memory disclosures.

---
 drivers/media/platform/rcar_drif.c | 1 +
 1 file changed, 1 insertion(+)
drivers/media/platform/rcar_drif.c +1 -0
index 608e5217ccd5..0f267a237b42 100644
@@ -912,6 +912,7 @@ static int rcar_drif_g_fmt_sdr_cap(struct file *file, void *priv,
 {
 	struct rcar_drif_sdr *sdr = video_drvdata(file);
 
+	memset(f->fmt.sdr.reserved, 0, sizeof(f->fmt.sdr.reserved));
 	f->fmt.sdr.pixelformat = sdr->fmt->pixelformat;
 	f->fmt.sdr.buffersize = sdr->fmt->buffersize;
 
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw

Hi Kangjie,

Quoted 5 lines · Kangjie Lu

"f->fmt.sdr.reserved" is uninitialized. As other peer drivers like msi2500 and airspy do, the fix initializes it to avoid memory disclosures.

drivers/media/platform/rcar_drif.c static int rcar_drif_g_fmt_sdr_cap(struct file *file, void *priv, · line 917

Quoted 9 lines
drivers/media/platform/rcar_drif.c +1 -0
@@ -912,6 +912,7 @@ static int rcar_drif_g_fmt_sdr_cap(struct file *file, void *priv,
 {
        struct rcar_drif_sdr *sdr = video_drvdata(file);
 
+       memset(f->fmt.sdr.reserved, 0, sizeof(f->fmt.sdr.reserved));
        f->fmt.sdr.pixelformat = sdr->fmt->pixelformat;
        f->fmt.sdr.buffersize = sdr->fmt->buffersize;

I would do the memset() at the end, though, to follow declaration order of the struct members.

Gr{oetje,eeting}s,

Geert

--
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