From: Chen Gang Date: Tue, 28 Jan 2014 01:07:13 +0000 (-0800) Subject: kernel/kexec.c: use vscnprintf() instead of vsnprintf() in vmcoreinfo_append_str() X-Git-Tag: submit/tizen/20160607.132125~5240^2~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a19428e5c3f4f39c302cb97b847dfd23613145c1;p=sdk%2Femulator%2Femulator-kernel.git kernel/kexec.c: use vscnprintf() instead of vsnprintf() in vmcoreinfo_append_str() 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 Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/kernel/kexec.c b/kernel/kexec.c index ac73878..60bafbe 100644 --- a/kernel/kexec.c +++ b/kernel/kexec.c @@ -1537,7 +1537,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);