]> 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>
Thu, 9 Jan 2014 06:17:33 +0000 (17:17 +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);