]> git.baikalelectronics.ru Git - kernel.git/commit
bcache: fix input overflow to journal_delay_ms
authorColy Li <colyli@suse.de>
Sat, 9 Feb 2019 04:53:08 +0000 (12:53 +0800)
committerJens Axboe <axboe@kernel.dk>
Sat, 9 Feb 2019 14:18:32 +0000 (07:18 -0700)
commit874a752679b878065ed0c7775455f8b81a7ab196
treef8dd8f67d3f4bc2f92fcdae7604719ff46823843
parent562b1df9de87b1b7bb14bdcc7f13efb5badb74e2
bcache: fix input overflow to journal_delay_ms

c->journal_delay_ms is in type unsigned short, it is set via sysfs
interface and converted by sysfs_strtoul() from input string to
unsigned short value. Therefore overflow to unsigned short might be
happen when the converted value exceed USHRT_MAX. e.g. writing
65536 into sysfs file journal_delay_ms, c->journal_delay_ms is set to
0.

This patch uses sysfs_strtoul_clamp() to convert the input string and
limit value range in [0, USHRT_MAX], to avoid the input overflow.

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