]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
bcache: fix input overflow to sequential_cutoff
authorColy Li <colyli@suse.de>
Sat, 9 Feb 2019 04:53:01 +0000 (12:53 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 5 Apr 2019 20:29:12 +0000 (22:29 +0200)
commit5f0bef75639800d8780fd7147e1aaac0b77bf930
tree0a188c31dc791fa170d0c5ab49643b4062860231
parent4f9395b1e706358eceac6803a1cd87ea98098b46
bcache: fix input overflow to sequential_cutoff

[ Upstream commit 8c27a3953e92eb0b22dbb03d599f543a05f9574e ]

People may set sequential_cutoff of a cached device via sysfs file,
but current code does not check input value overflow. E.g. if value
4294967295 (UINT_MAX) is written to file sequential_cutoff, its value
is 4GB, but if 4294967296 (UINT_MAX + 1) is written into, its value
will be 0. This is an unexpected behavior.

This patch replaces d_strtoi_h() by sysfs_strtoul_clamp() to convert
input string to unsigned integer value, and limit its range in
[0, UINT_MAX]. Then the input overflow can be fixed.

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