On Mon, Jan 21, 2019 at 01:20:57PM +0100, Miklos Szeredi wrote: > On Tue, Nov 20, 2018 at 6:36 AM Chandan Rajendra > <chandan@xxxxxxxxxxxxxxxxxx> wrote: > > > > 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 validating the length of the "filesystem > > type" argument passed to get_fs_type() function. > > > > Signed-off-by: Chandan Rajendra <chandan@xxxxxxxxxxxxxxxxxx> > > Reported-by: Abdul Haleem <abdhalee@xxxxxxxxxxxxxxxxxx> > > Suggested-by: Joe Perches <joe@xxxxxxxxxxx> > > Acked-by: Miklos Szeredi <mszeredi@xxxxxxxxxx> > > Al, please pick this up, it looks like a good sanity check and lack of > it is causing headaches for IBM QA. Umm... I'm not against that patch, but I wonder if that should be caught earlier... If nothing else, the same string is seen by LSM shite before get_fs_type() gets a chance to reject it, and I wouldn't bet a dime on robustness of that code. Wouldn't it be saner to have char *copy_mount_string(const void __user *data) { return data ? strndup_user(data, PAGE_SIZE) : NULL; } use a more explicit size limit? PATH_MAX, for example?