Skip to contentSkip to conversation

scsi: esas2r: fix potential format string flaw

PATCH RESEND Superseded Kees Cook 4 participants 7 messages Dec 17, 2013 – Dec 18, 2013

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH RESEND 1/1 scsi: esas2r: fix potential format string flaw

This makes sure format strings cannot leak into the printk call via the constructed buffer.

---
 drivers/scsi/esas2r/esas2r_log.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/esas2r/esas2r_log.c +1 -1
index 9bf285df58dd..61fc19d296bd 100644
@@ -171,7 +171,7 @@ static int esas2r_log_master(const long level,
 		if (strlen(event_buffer) < buflen)
 			strcat(buffer, "\n");
 
-		printk(event_buffer);
+		printk("%s", event_buffer);
 
 		spin_unlock_irqrestore(&event_buffer_lock, flags);
 	}
Signature · 6 lines
1.7.9.5


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

This makes sure format strings cannot leak into the printk call via the constructed buffer.

---
 drivers/scsi/esas2r/esas2r_log.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Why is this patch "To:" me? I'm not the author of this driver, or the maintainer of it or the subsystem, and there's not much, if anything I can do with it...

confused,

greg k-h

author
#2 lore raw
Quoted 4 lines · Greg Kroah-Hartman
Quoted 3 lines · Kees Cook

This makes sure format strings cannot leak into the printk call via the constructed buffer.

Quoted 8 lines
Quoted 4 lines
---
 drivers/scsi/esas2r/esas2r_log.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Why is this patch "To:" me? I'm not the author of this driver, or the maintainer of it or the subsystem, and there's not much, if anything I can do with it...

I've resent this before, and since it lived in "drivers", I figured you would be the next up the chain to take it (since it's been ignored).

-Kees

Signature · 2 lines
Kees Cook
Chrome OS Security
#3 lore raw
Quoted 11 lines · Kees Cook
Quoted 9 lines · Greg Kroah-Hartman
Quoted 7 lines · Kees Cook

This makes sure format strings cannot leak into the printk call via the constructed buffer.

---
 drivers/scsi/esas2r/esas2r_log.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 7 lines
Quoted 3 lines

Why is this patch "To:" me? I'm not the author of this driver, or the maintainer of it or the subsystem, and there's not much, if anything I can do with it...

I've resent this before, and since it lived in "drivers", I figured you would be the next up the chain to take it (since it's been ignored).

Heh, while I do seem to maintain a ton of the drivers/ tree, I don't take everything there. This needs to go through James's tree, he can handle it :)

thanks,

greg k-h

Acked-by on v1 1/1
#4 lore raw
In reply to Kees Cook
Quoted 22 lines · Kees Cook

This makes sure format strings cannot leak into the printk call via the constructed buffer.

---
  drivers/scsi/esas2r/esas2r_log.c |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/esas2r/esas2r_log.c +1 -1
index 9bf285df58dd..61fc19d296bd 100644
@@ -171,7 +171,7 @@ static int esas2r_log_master(const long level,
  		if (strlen(event_buffer) < buflen)
  			strcat(buffer, "\n");
 
-		printk(event_buffer);
+		printk("%s", event_buffer);
 
  		spin_unlock_irqrestore(&event_buffer_lock, flags);
  	}
#5 lore raw
In reply to Kees Cook
Quoted 2 lines · Kees Cook

This makes sure format strings cannot leak into the printk call via the constructed buffer.

[]

drivers/scsi/esas2r/esas2r_log.c

Quoted 1 line
drivers/scsi/esas2r/esas2r_log.c +0 -0

[]

drivers/scsi/esas2r/esas2r_log.c static int esas2r_log_master(const long level, · line 174

Quoted 6 lines
drivers/scsi/esas2r/esas2r_log.c +1 -1
@@ -171,7 +171,7 @@ static int esas2r_log_master(const long level,
 		if (strlen(event_buffer) < buflen)
 			strcat(buffer, "\n");
 
-		printk(event_buffer);
+		printk("%s", event_buffer);

It's probably better to remove the

		if (strlen(event_buffer) < buflen)
			strcat(buffer, "\n");

and use

	printk("%s\n", event_buffer);

so that the output is always newline terminated.

author
#6 lore raw
Quoted 15 lines · Joe Perches
Quoted 2 lines · Kees Cook

This makes sure format strings cannot leak into the printk call via the constructed buffer.

[]

drivers/scsi/esas2r/esas2r_log.c

Quoted 1 line
drivers/scsi/esas2r/esas2r_log.c +0 -0

[]

drivers/scsi/esas2r/esas2r_log.c static int esas2r_log_master(const long level, · line 174

Quoted 6 lines
drivers/scsi/esas2r/esas2r_log.c +1 -1
@@ -171,7 +171,7 @@ static int esas2r_log_master(const long level,
              if (strlen(event_buffer) < buflen)
                      strcat(buffer, "\n");
 
-             printk(event_buffer);
+             printk("%s", event_buffer);

It's probably better to remove the

Quoted 8 lines

if (strlen(event_buffer) < buflen)
strcat(buffer, "\n");

and use

        printk("%s\n", event_buffer);

so that the output is always newline terminated.

Ah! Yes, good call.

-Kees

Signature · 2 lines
Kees Cook
Chrome OS Security