]> git.baikalelectronics.ru Git - kernel.git/commit
bcache: fix input integer overflow of congested threshold
authorColy Li <colyli@suse.de>
Sat, 9 Feb 2019 04:53:00 +0000 (12:53 +0800)
committerJens Axboe <axboe@kernel.dk>
Sat, 9 Feb 2019 14:18:31 +0000 (07:18 -0700)
commit1734ebc5279c6f18b9cb56343071d656e18105b0
tree1a1ee0684bdad2647fbdb03a2ac479eec772a8e9
parent4a879f8303eb9b3f4ef090488689c916bea79272
bcache: fix input integer overflow of congested threshold

Cache set congested threshold values congested_read_threshold_us and
congested_write_threshold_us can be set via sysfs interface. These
two values are 'unsigned int' type, but sysfs interface uses strtoul
to convert input string. So if people input a large number like
9999999999, the value indeed set is 1410065407, which is not expected
behavior.

This patch replaces sysfs_strtoul() by sysfs_strtoul_clamp() when
convert input string to unsigned int value, and set value range in
[0, UINT_MAX], to avoid the above integer overflow errors.

Signed-off-by: Coly Li <colyli@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/md/bcache/sysfs.c