Skip to contentSkip to conversation

dvb: fix potential format string leak

PATCH In review Kees Cook 3 participants 3 messages Sep 16, 2013 – Sep 30, 2013 Media (V4L/DVB)

lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH 1/1 dvb: fix potential format string leak

Make sure that a format string cannot accidentally leak into the printk buffer.

---
 drivers/media/dvb-frontends/dib9000.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/dvb-frontends/dib9000.c +1 -1
index 6201c59..61b2cfe 100644
@@ -649,7 +649,7 @@ static int dib9000_risc_debug_buf(struct dib9000_state *state, u16 * data, u8 si
 	b[2 * (size - 2) - 1] = '\0';	/* Bullet proof the buffer */
 	if (*b == '~') {
 		b++;
-		dprintk(b);
+		dprintk("%s", b);
 	} else
 		dprintk("RISC%d: %d.%04d %s", state->fe_id, ts / 10000, ts % 10000, *b ? b : "<emtpy>");
 	return 1;
Signature · 6 lines
1.7.9.5


-- 
Kees Cook
Chrome OS Security
#1 lore raw
Quoted 2 lines · Kees Cook

Make sure that a format string cannot accidentally leak into the printk buffer.

[]

drivers/media/dvb-frontends/dib9000.c

Quoted 1 line
drivers/media/dvb-frontends/dib9000.c +0 -0

[]

drivers/media/dvb-frontends/dib9000.c static int dib9000_risc_debug_buf(struct dib9000_state *state, u16 * data, u8 si · line 655

Quoted 9 lines
drivers/media/dvb-frontends/dib9000.c +1 -1
@@ -649,7 +649,7 @@ static int dib9000_risc_debug_buf(struct dib9000_state *state, u16 * data, u8 si
 	b[2 * (size - 2) - 1] = '\0';	/* Bullet proof the buffer */
 	if (*b == '~') {
 		b++;
-		dprintk(b);
+		dprintk("%s", b);
 	} else
 		dprintk("RISC%d: %d.%04d %s", state->fe_id, ts / 10000, ts % 10000, *b ? b : "<emtpy>");
 	return 1;

This looks odd.

Perhaps this should be:

	if (*b == '~')
		b++;
	dprintk("etc...);

It'd be nice to fix the <empty> typo too.

#2 lore raw
Quoted 18 lines · Joe Perches
Quoted 2 lines · Kees Cook

Make sure that a format string cannot accidentally leak into the printk buffer.

[]

drivers/media/dvb-frontends/dib9000.c

Quoted 1 line
drivers/media/dvb-frontends/dib9000.c +0 -0

[]

drivers/media/dvb-frontends/dib9000.c static int dib9000_risc_debug_buf(struct dib9000_state *state, u16 * data, u8 si · line 655

Quoted 9 lines
drivers/media/dvb-frontends/dib9000.c +1 -1
@@ -649,7 +649,7 @@ static int dib9000_risc_debug_buf(struct dib9000_state *state, u16 * data, u8 si
      b[2 * (size - 2) - 1] = '\0';   /* Bullet proof the buffer */
      if (*b == '~') {
              b++;
-             dprintk(b);
+             dprintk("%s", b);
      } else
              dprintk("RISC%d: %d.%04d %s", state->fe_id, ts / 10000, ts % 10000, *b ? b : "<emtpy>");
      return 1;

This looks odd.

Quoted 7 lines

Perhaps this should be:

        if (*b == '~')
                b++;
        dprintk("etc...);

It'd be nice to fix the <empty> typo too.

This *does* look odd, I agree. Meanwhile, I do believe this patch leaves things better than before. I'm going to merge Kees' patch for now, but it would be nice to see a better cleanup for that code block.

-Mike Krufky