]> git.baikalelectronics.ru Git - kernel.git/commit
bcache: fix input overflow to cache set sysfs file io_error_halflife
authorColy Li <colyli@suse.de>
Sat, 9 Feb 2019 04:53:10 +0000 (12:53 +0800)
committerJens Axboe <axboe@kernel.dk>
Sat, 9 Feb 2019 14:18:33 +0000 (07:18 -0700)
commitfbdcad33f9a060ca075a2581176d57dfcd8be27a
tree146a7c1d8048648530d36fd11ec0e31a1557373f
parent13573e2268c9fea7c3c46f3c115f764757839dfe
bcache: fix input overflow to cache set sysfs file io_error_halflife

Cache set sysfs entry io_error_halflife is used to set c->error_decay.
c->error_decay is in type unsigned int, and it is converted by
strtoul_or_return(), therefore overflow to c->error_decay is possible
for a large input value.

This patch fixes the overflow by using strtoul_safe_clamp() to convert
input string to an unsigned long value in range [0, UINT_MAX], then
divides by 88 and set it to c->error_decay.

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