Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a19428e5 authored by Chen Gang's avatar Chen Gang Committed by Linus Torvalds
Browse files

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: default avatarChen Gang <gang.chen@asianux.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 53e0ee9f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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);