Kees Cook 169015f464 module: Correctly truncate sysfs sections output
commit 11990a5bd7e558e9203c1070fc52fb6f0488e75b upstream.

The only-root-readable /sys/module/$module/sections/$section files
did not truncate their output to the available buffer size. While most
paths into the kernfs read handlers end up using PAGE_SIZE buffers,
it's possible to get there through other paths (e.g. splice, sendfile).
Actually limit the output to the "count" passed into the read function,
and report it back correctly. *sigh*

Reported-by: kernel test robot <lkp@intel.com>
Link: https://lore.kernel.org/lkml/20200805002015.GE23458@shao2-debian
Fixes: ed66f991bb19 ("module: Refactor section attr into bin attribute")
Cc: stable@vger.kernel.org
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Jessica Yu <jeyu@kernel.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-08-21 13:05:28 +02:00
..
2019-05-28 17:46:43 -04:00
2020-01-17 19:48:42 +01:00
2020-03-25 08:25:58 +01:00
2019-05-24 20:16:01 +02:00
2020-03-25 08:25:58 +01:00
2020-01-09 10:19:54 +01:00
2020-05-20 08:20:13 +02:00
2019-07-08 19:36:47 -07:00
2019-07-08 19:36:47 -07:00