aboutsummaryrefslogtreecommitdiff
path: root/lib/test_overflow.c
diff options
context:
space:
mode:
authorChandan Rajendra <[email protected]>2019-01-22 12:21:52 +0530
committerAl Viro <[email protected]>2019-02-01 01:57:33 -0500
commitfbdb44013202305cd2aefb01df0a92bb55819702 (patch)
treed8e4924841ec469e9487eaac145eb8069efbe38b /lib/test_overflow.c
parent35ac1184244f1329783e1d897f74926d8bb1103a (diff)
copy_mount_string: Limit string length to PATH_MAX
On ppc64le, When a string with PAGE_SIZE - 1 (i.e. 64k-1) length is passed as a "filesystem type" argument to the mount(2) syscall, copy_mount_string() ends up allocating 64k (the PAGE_SIZE on ppc64le) worth of space for holding the string in kernel's address space. Later, in set_precision() (invoked by get_fs_type() -> __request_module() -> vsnprintf()), we end up assigning strlen(fs-type-string) i.e. 65535 as the value to 'struct printf_spec'->precision member. This field has a width of 16 bits and it is a signed data type. Hence an invalid value ends up getting assigned. This causes the "WARN_ONCE(spec->precision != prec, "precision %d too large", prec)" statement inside set_precision() to be executed. This commit fixes the bug by limiting the length of the string passed by copy_mount_string() to strndup_user() to PATH_MAX. Signed-off-by: Chandan Rajendra <[email protected]> Reported-by: Abdul Haleem <[email protected]> Suggested-by: Al Viro <[email protected]> Signed-off-by: Al Viro <[email protected]>
Diffstat (limited to 'lib/test_overflow.c')
0 files changed, 0 insertions, 0 deletions