]> 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>
Tue, 5 Nov 2013 05:57:36 +0000 (16:57 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Tue, 5 Nov 2013 05:57:36 +0000 (16:57 +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 2a74f307c5ec57b050ceeb8a21341f8a394841ef..0abcd688fe2c3ef5c48bac87be9299c3e7b83b4f 100644 (file)
@@ -1533,7 +1533,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);