• Coly Li's avatar
    bcache: fix input overflow to journal_delay_ms · 453745fb
    Coly Li authored
    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: default avatarColy Li <colyli@suse.de>
    Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
    453745fb
sysfs.c 26.9 KB