summaryrefslogtreecommitdiff
path: root/lib/ratelimit.c
diff options
context:
space:
mode:
authorJean Delvare <jdelvare@suse.de>2017-10-04 02:16:38 +0300
committerLinus Torvalds <torvalds@linux-foundation.org>2017-10-04 03:54:26 +0300
commit96802e6b1dbf29d3012b39503c5dd6d9d8e82955 (patch)
tree8c4c37a6c544b8e4983fd705604845187968b67b /lib/ratelimit.c
parent90ceb2a3ad868f800eb1c9f4ede650daddd94b77 (diff)
downloadlinux-96802e6b1dbf29d3012b39503c5dd6d9d8e82955.tar.xz
kernel/params.c: fix an overflow in param_attr_show
Function param_attr_show could overflow the buffer it is operating on. The buffer size is PAGE_SIZE, and the string returned by attribute->param->ops->get is generated by scnprintf(buffer, PAGE_SIZE, ...) so it could be PAGE_SIZE - 1 long, with the terminating '\0' at the very end of the buffer. Calling strcat(..., "\n") on this isn't safe, as the '\0' will be replaced by '\n' (OK) and then another '\0' will be added past the end of the buffer (not OK.) Simply add the trailing '\n' when writing the attribute contents to the buffer originally. This is safe, and also faster. Credits to Teradata for discovering this issue. Link: http://lkml.kernel.org/r/20170928162602.60c379c7@endymion Signed-off-by: Jean Delvare <jdelvare@suse.de> Acked-by: Ingo Molnar <mingo@kernel.org> Cc: Baoquan He <bhe@redhat.com> Cc: Michal Hocko <mhocko@suse.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib/ratelimit.c')
0 files changed, 0 insertions, 0 deletions