]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kernel/kexec.c: use vscnprintf() instead of vsnprintf() in vmcoreinfo_append_str()
authorChen Gang <gang.chen@asianux.com>
Fri, 3 Jan 2014 03:16:51 +0000 (14:16 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Mon, 6 Jan 2014 09:08:15 +0000 (20:08 +1100)
vsnprintf() may let 'r' larger than sizeof(buf), in this case, if 'r' is
also less than "vmcoreinfo_max_size - vmcoreinfo_size" (left size of
destination buffer), next memcpy() will read the unexpected addresses.

Signed-off-by: Chen Gang <gang.chen@asianux.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
kernel/kexec.c

index 9c970167e4025f01be6bd696499eec2504c72ef7..9cf77fd111069c61a753d623de0c364490d6489d 100644 (file)
@@ -1536,7 +1536,7 @@ void vmcoreinfo_append_str(const char *fmt, ...)
        size_t r;
 
        va_start(args, fmt);
-       r = vsnprintf(buf, sizeof(buf), fmt, args);
+       r = vscnprintf(buf, sizeof(buf), fmt, args);
        va_end(args);
 
        r = min(r, vmcoreinfo_max_size - vmcoreinfo_size);