]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 5 Apr 2019 20:29:12 +0000 (22:29 +0200)
commit4f9395b1e706358eceac6803a1cd87ea98098b46
tree45d2f5ef5a75e4d4b7930b449d4a3fa86c60fdcd
parent49145924e8049111dc76ac86e2686d415b18dd14
bcache: fix input overflow to cache set sysfs file io_error_halflife

[ Upstream commit a91fbda49f746119828f7e8ad0f0aa2ab0578f65 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/md/bcache/sysfs.c