From: Coly Li Date: Sat, 9 Feb 2019 04:53:07 +0000 (+0800) Subject: bcache: fix input overflow to writeback_rate_minimum X-Git-Tag: for-5.1/block-20190224~46 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=dab71b2db98dcdd4657d151b01a7be88ce10f9d1;p=linux-2.6-block.git bcache: fix input overflow to writeback_rate_minimum dc->writeback_rate_minimum is type unsigned integer variable, it is set via sysfs interface, and converte from input string to unsigned integer by d_strtoul_nonzero(). When the converted input value is larger than UINT_MAX, overflow to unsigned integer happens. This patch fixes the overflow by using sysfs_strotoul_clamp() to convert input string and limit the value in range [1, UINT_MAX], then the overflow can be avoided. Signed-off-by: Coly Li Signed-off-by: Jens Axboe --- diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c index c6677c93e368..d292eb757ac4 100644 --- a/drivers/md/bcache/sysfs.c +++ b/drivers/md/bcache/sysfs.c @@ -308,7 +308,9 @@ STORE(__cached_dev) sysfs_strtoul_clamp(writeback_rate_p_term_inverse, dc->writeback_rate_p_term_inverse, 1, UINT_MAX); - d_strtoul_nonzero(writeback_rate_minimum); + sysfs_strtoul_clamp(writeback_rate_minimum, + dc->writeback_rate_minimum, + 1, UINT_MAX); sysfs_strtoul_clamp(io_error_limit, dc->error_limit, 0, INT_MAX);