Skip to content

Commit a19428e

Browse files
Chen Gangtorvalds
authored andcommitted
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 <gang.chen@asianux.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 53e0ee9 commit a19428e

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎kernel/kexec.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1537,7 +1537,7 @@ void vmcoreinfo_append_str(const char *fmt, ...)
15371537
size_t r;
15381538

15391539
va_start(args, fmt);
1540-
r = vsnprintf(buf, sizeof(buf), fmt, args);
1540+
r = vscnprintf(buf, sizeof(buf), fmt, args);
15411541
va_end(args);
15421542

15431543
r = min(r, vmcoreinfo_max_size - vmcoreinfo_size);

0 commit comments

Comments
 (0)