• Luis R. Rodriguez's avatar
    test_kmod: fix bug which allows negative values on two config options · 434b06ae
    Luis R. Rodriguez authored
    Parsing with kstrtol() enables values to be negative, and we failed to
    check for negative values when parsing with test_dev_config_update_uint_sync()
    or test_dev_config_update_uint_range().
    
    test_dev_config_update_uint_range() has a minimum check though so an
    issue is not present there.  test_dev_config_update_uint_sync() is only
    used for the number of threads to use (config_num_threads_store()), and
    indeed this would fail with an attempt for a large allocation.
    
    Although the issue is only present in practice with the first fix both
    by using kstrtoul() instead of kstrtol().
    
    Link: http://lkml.kernel.org/r/20170802211450.27928-4-mcgrof@kernel.org
    Fixes: 39258f448d71 ("kmod: add test driver to stress test the module loader")
    Signed-off-by: default avatarLuis R. Rodriguez <mcgrof@kernel.org>
    Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
    Cc: Colin Ian King <colin.king@canonical.com>
    Cc: David Binderman <dcb314@hotmail.com>
    Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
    Cc: Eric W. Biederman <ebiederm@xmission.com>
    Cc: Jessica Yu <jeyu@redhat.com>
    Cc: Josh Poimboeuf <jpoimboe@redhat.com>
    Cc: Kees Cook <keescook@chromium.org>
    Cc: Michal Marek <mmarek@suse.com>
    Cc: Miroslav Benes <mbenes@suse.cz>
    Cc: Petr Mladek <pmladek@suse.com>
    Cc: Rusty Russell <rusty@rustcorp.com.au>
    Cc: Shuah Khan <shuah@kernel.org>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    434b06ae
test_kmod.c 30.4 KB