• Yi Yang's avatar
    Add new string functions strict_strto* and convert kernel params to use them · 06b2a76d
    Yi Yang authored
    Currently, for every sysfs node, the callers will be responsible for
    implementing store operation, so many many callers are doing duplicate
    things to validate input, they have the same mistakes because they are
    calling simple_strtol/ul/ll/uul, especially for module params, they are
    just numeric, but you can echo such values as 0x1234xxx, 07777888 and
    1234aaa, for these cases, module params store operation just ignores
    succesive invalid char and converts prefix part to a numeric although input
    is acctually invalid.
    
    This patch tries to fix the aforementioned issues and implements
    strict_strtox serial functions, kernel/params.c uses them to strictly
    validate input, so module params will reject such values as 0x1234xxxx and
    returns an error:
    
    write error: Invalid argument
    
    Any modules which export numeric sysfs node can use strict_strtox instead of
    simple_strtox to reject any invalid input.
    
    Here are some test results:
    
    Before apply...
    06b2a76d
params.c 17.5 KB