]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
sparc: fix ldom_reboot buffer overflow harder
authorKees Cook <keescook@chromium.org>
Wed, 2 Oct 2013 05:13:34 +0000 (22:13 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 3 Oct 2013 00:01:56 +0000 (20:01 -0400)
The length argument to strlcpy was still wrong. It could overflow the end of
full_boot_str by 5 bytes. Instead of strcat and strlcpy, just use snprint.

Reported-by: Brad Spengler <spender@grsecurity.net>
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
arch/sparc/kernel/ds.c

index 4d9ac8406f323a96e895d7bf482eaa18a97974c6..dff60abbea012f30a8b55221cc8d7a3a60a762ea 100644 (file)
@@ -849,9 +849,8 @@ void ldom_reboot(const char *boot_command)
        if (boot_command && strlen(boot_command)) {
                unsigned long len;
 
-               strcpy(full_boot_str, "boot ");
-               strlcpy(full_boot_str + strlen("boot "), boot_command,
-                       sizeof(full_boot_str));
+               snprintf(full_boot_str, sizeof(full_boot_str), "boot %s",
+                        boot_command);
                len = strlen(full_boot_str);
 
                if (reboot_data_supported) {