08 Jun, 2020

1 commit

  • Pull driver core updates from Greg KH:
    "Here is the set of driver core patches for 5.8-rc1.

    Not all that huge this release, just a number of small fixes and
    updates:

    - software node fixes

    - kobject now sends KOBJ_REMOVE when it is removed from sysfs, not
    when it is removed from memory (which could come much later)

    - device link additions and fixes based on testing on more devices

    - firmware core cleanups

    - other minor changes, full details in the shortlog

    All have been in linux-next for a while with no reported issues"

    * tag 'driver-core-5.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (23 commits)
    driver core: Update device link status correctly for SYNC_STATE_ONLY links
    firmware_loader: change enum fw_opt to u32
    software node: implement software_node_unregister()
    kobject: send KOBJ_REMOVE uevent when the object is removed from sysfs
    driver core: Remove unnecessary is_fwnode_dev variable in device_add()
    drivers property: When no children in primary, try secondary
    driver core: platform: Fix spelling errors in platform.c
    driver core: Remove check in driver_deferred_probe_force_trigger()
    of: platform: Batch fwnode parsing when adding all top level devices
    driver core: fw_devlink: Add support for batching fwnode parsing
    driver core: Look for waiting consumers only for a fwnode's primary device
    driver core: Move code to the right part of the file
    Revert "Revert "driver core: Set fw_devlink to "permissive" behavior by default""
    drivers: base: Fix NULL pointer exception in __platform_driver_probe() if a driver developer is foolish
    firmware_loader: move fw_fallback_config to a private kernel symbol namespace
    driver core: Add missing '\n' in log messages
    driver/base/soc: Use kobj_to_dev() API
    Add documentation on meaning of -EPROBE_DEFER
    driver core: platform: remove redundant assignment to variable ret
    debugfs: Use the correct style for SPDX License Identifier
    ...

    Linus Torvalds
     

02 Jun, 2020

1 commit

  • Pull printk updates from Petr Mladek:

    - Benjamin Herrenschmidt solved a problem with non-matched console
    aliases by first checking consoles defined on the command line. It is
    a more conservative approach than the previous attempts.

    - Benjamin also made sure that the console accessible via /dev/console
    always has CON_CONSDEV flag.

    - Andy Shevchenko added the %ptT modifier for printing struct time64_t.
    It extends the existing %ptR handling for struct rtc_time.

    - Bruno Meneguele fixed /dev/kmsg error value returned by unsupported
    SEEK_CUR.

    - Tetsuo Handa removed unused pr_cont_once().

    ... and a few small fixes.

    * tag 'printk-for-5.8' of git://git.kernel.org/pub/scm/linux/kernel/git/printk/linux:
    printk: Remove pr_cont_once()
    printk: handle blank console arguments passed in.
    kernel/printk: add kmsg SEEK_CUR handling
    printk: Fix a typo in comment "interator"->"iterator"
    usb: pulse8-cec: Switch to use %ptT
    ARM: bcm2835: Switch to use %ptT
    lib/vsprintf: Print time64_t in human readable format
    lib/vsprintf: update comment about simple_strto() functions
    printk: Correctly set CON_CONSDEV even when preferred console was not registered
    printk: Fix preferred console selection with multiple matches
    printk: Move console matching logic into a separate function
    printk: Convert a use of sprintf to snprintf in console_unlock

    Linus Torvalds
     

27 May, 2020

1 commit

  • Sometimes it is better to unregister individual nodes instead of trying
    to do them all at once with software_node_unregister_nodes(), so create
    software_node_unregister() so that you can unregister them one at a
    time.

    This is especially important when creating nodes in a hierarchy, with
    parent -> children representations. Children always need to be removed
    before a parent is, as the swnode logic assumes this is going to be the
    case.

    Fix up the lib/test_printf.c fwnode_pointer() test which to use this new
    function as it had the problem of tearing things down in the backwards
    order.

    Fixes: f1ce39df508d ("lib/test_printf: Add tests for %pfw printk modifier")
    Cc: stable
    Cc: Andy Shevchenko
    Cc: Brendan Higgins
    Cc: Dmitry Torokhov
    Cc: Petr Mladek
    Cc: Rafael J. Wysocki
    Cc: Rasmus Villemoes
    Cc: Sakari Ailus
    Cc: Sergey Senozhatsky
    Cc: Steven Rostedt
    Reported-by: Naresh Kamboju
    Reported-by: kernel test robot
    Reported-by: Randy Dunlap
    Tested-by: Petr Mladek
    Tested-by: Randy Dunlap
    Tested-by: Guenter Roeck
    Reviewed-by: Heikki Krogerus
    Acked-by: Randy Dunlap
    Link: https://lore.kernel.org/r/20200524153041.2361-1-gregkh@linuxfoundation.org
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

20 May, 2020

2 commits

  • There are users which print time and date represented by content of
    time64_t type in human readable format.

    Instead of open coding that each time introduce %ptT[dt][r] specifier.

    Few test cases for %ptT specifier has been added as well.

    Link: https://lore.kernel.org/r/20200415170046.33374-2-andriy.shevchenko@linux.intel.com
    Signed-off-by: Andy Shevchenko
    Reviewed-by: Alexandre Belloni
    Acked-by: Sergey Senozhatsky
    Rewieved-by: Petr Mladek
    Signed-off-by: Petr Mladek

    Andy Shevchenko
     
  • I don't see what security concern is addressed by obfuscating NULL
    and IS_ERR() error pointers, printed with %p/%pK. Given the number
    of sites where %p is used (over 10000) and the fact that NULL pointers
    aren't uncommon, it probably wouldn't take long for an attacker to
    find the hash that corresponds to 0. Although harder, the same goes
    for most common error values, such as -1, -2, -11, -14, etc.

    The NULL part actually fixes a regression: NULL pointers weren't
    obfuscated until commit 3e5903eb9cff ("vsprintf: Prevent crash when
    dereferencing invalid pointers") which went into 5.2. I'm tacking
    the IS_ERR() part on here because error pointers won't leak kernel
    addresses and printing them as pointers shouldn't be any different
    from e.g. %d with PTR_ERR_OR_ZERO(). Obfuscating them just makes
    debugging based on existing pr_debug and friends excruciating.

    Note that the "always print 0's for %pK when kptr_restrict == 2"
    behaviour which goes way back is left as is.

    Example output with the patch applied:

    ptr error-ptr NULL
    %p: 0000000001f8cc5b fffffffffffffff2 0000000000000000
    %pK, kptr = 0: 0000000001f8cc5b fffffffffffffff2 0000000000000000
    %px: ffff888048c04020 fffffffffffffff2 0000000000000000
    %pK, kptr = 1: ffff888048c04020 fffffffffffffff2 0000000000000000
    %pK, kptr = 2: 0000000000000000 0000000000000000 0000000000000000

    Fixes: 3e5903eb9cff ("vsprintf: Prevent crash when dereferencing invalid pointers")
    Signed-off-by: Ilya Dryomov
    Reviewed-by: Petr Mladek
    Reviewed-by: Sergey Senozhatsky
    Reviewed-by: Andy Shevchenko
    Acked-by: Steven Rostedt (VMware)
    Signed-off-by: Linus Torvalds

    Ilya Dryomov
     

27 Nov, 2019

1 commit

  • Pull device properties framework updates from Rafael Wysocki:
    "Add support for printing fwnode names using a new conversion specifier
    "%pfw" (Sakari Ailus), clean up the software node and
    efi/apple-properties code in preparation for improved software node
    reference properties handling (Dmitry Torokhov) and fix the struct
    fwnode_operations description (Heikki Krogerus)"

    * tag 'devprop-5.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (22 commits)
    software node: simplify property_entry_read_string_array()
    software node: unify PROPERTY_ENTRY_XXX macros
    software node: remove property_entry_read_uNN_array functions
    software node: get rid of property_set_pointer()
    software node: clean up property_copy_string_array()
    software node: mark internal macros with double underscores
    efi/apple-properties: use PROPERTY_ENTRY_U8_ARRAY_LEN
    software node: introduce PROPERTY_ENTRY_XXX_ARRAY_LEN()
    software node: remove DEV_PROP_MAX
    device property: Fix the description of struct fwnode_operations
    lib/test_printf: Add tests for %pfw printk modifier
    lib/vsprintf: Add %pfw conversion specifier for printing fwnode names
    lib/vsprintf: OF nodes are first and foremost, struct device_nodes
    lib/vsprintf: Make use of fwnode API to obtain node names and separators
    lib/vsprintf: Add a note on re-using %pf or %pF
    lib/vsprintf: Remove support for %pF and %pf in favour of %pS and %ps
    device property: Add a function to obtain a node's prefix
    device property: Add fwnode_get_name for returning the name of a node
    device property: Add functions for accessing node's parents
    device property: Move fwnode_get_parent() up
    ...

    Linus Torvalds
     

17 Oct, 2019

1 commit

  • It has been suggested several times to extend vsnprintf() to be able
    to convert the numeric value of ENOSPC to print "ENOSPC". This
    implements that as a %p extension: With %pe, one can do

    if (IS_ERR(foo)) {
    pr_err("Sorry, can't do that: %pe\n", foo);
    return PTR_ERR(foo);
    }

    instead of what is seen in quite a few places in the kernel:

    if (IS_ERR(foo)) {
    pr_err("Sorry, can't do that: %ld\n", PTR_ERR(foo));
    return PTR_ERR(foo);
    }

    If the value passed to %pe is an ERR_PTR, but the library function
    errname() added here doesn't know about the value, the value is simply
    printed in decimal. If the value passed to %pe is not an ERR_PTR, we
    treat it as an ordinary %p and thus print the hashed value (passing
    non-ERR_PTR values to %pe indicates a bug in the caller, but we can't
    do much about that).

    With my embedded hat on, and because it's not very invasive to do,
    I've made it possible to remove this. The errname() function and
    associated lookup tables take up about 3K. For most, that's probably
    quite acceptable and a price worth paying for more readable
    dmesg (once this starts getting used), while for those that disable
    printk() it's of very little use - I don't see a
    procfs/sysfs/seq_printf() file reasonably making use of this - and
    they clearly want to squeeze vmlinux as much as possible. Hence the
    default y if PRINTK.

    The symbols to include have been found by massaging the output of

    find arch include -iname 'errno*.h' | xargs grep -E 'define\s*E'

    In the cases where some common aliasing exists
    (e.g. EAGAIN=EWOULDBLOCK on all platforms, EDEADLOCK=EDEADLK on most),
    I've moved the more popular one (in terms of 'git grep -w Efoo | wc)
    to the bottom so that one takes precedence.

    Link: http://lkml.kernel.org/r/20191015190706.15989-1-linux@rasmusvillemoes.dk
    To: "Jonathan Corbet"
    To: linux-kernel@vger.kernel.org
    Cc: "Andy Shevchenko"
    Cc: "Andrew Morton"
    Cc: "Joe Perches"
    Cc: linux-doc@vger.kernel.org
    Signed-off-by: Rasmus Villemoes
    Acked-by: Uwe Kleine-König
    Reviewed-by: Petr Mladek
    [andy.shevchenko@gmail.com: use abs()]
    Acked-by: Andy Shevchenko
    Signed-off-by: Petr Mladek

    Rasmus Villemoes
     

11 Oct, 2019

1 commit


15 Aug, 2019

2 commits


21 May, 2019

1 commit

  • Add SPDX license identifiers to all files which:

    - Have no license information of any form

    - Have MODULE_LICENCE("GPL*") inside which was used in the initial
    scan/conversion to ignore the file

    These files fall under the project license, GPL v2 only. The resulting SPDX
    license identifier is:

    GPL-2.0-only

    Signed-off-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

08 May, 2019

1 commit

  • Pull printk updates from Petr Mladek:

    - Allow state reset of printk_once() calls.

    - Prevent crashes when dereferencing invalid pointers in vsprintf().
    Only the first byte is checked for simplicity.

    - Make vsprintf warnings consistent and inlined.

    - Treewide conversion of obsolete %pf, %pF to %ps, %pF printf
    modifiers.

    - Some clean up of vsprintf and test_printf code.

    * tag 'printk-for-5.2' of git://git.kernel.org/pub/scm/linux/kernel/git/pmladek/printk:
    lib/vsprintf: Make function pointer_string static
    vsprintf: Limit the length of inlined error messages
    vsprintf: Avoid confusion between invalid address and value
    vsprintf: Prevent crash when dereferencing invalid pointers
    vsprintf: Consolidate handling of unknown pointer specifiers
    vsprintf: Factor out %pO handler as kobject_string()
    vsprintf: Factor out %pV handler as va_format()
    vsprintf: Factor out %p[iI] handler as ip_addr_string()
    vsprintf: Do not check address of well-known strings
    vsprintf: Consistent %pK handling for kptr_restrict == 0
    vsprintf: Shuffle restricted_pointer()
    printk: Tie printk_once / printk_deferred_once into .data.once for reset
    treewide: Switch printk users from %pf and %pF to %ps and %pS, respectively
    lib/test_printf: Switch to bitmap_zalloc()

    Linus Torvalds
     

06 May, 2019

1 commit


26 Apr, 2019

2 commits

  • We already prevent crash when dereferencing some obviously broken
    pointers. But the handling is not consistent. Sometimes we print "(null)"
    only for pure NULL pointer, sometimes for pointers in the first
    page and sometimes also for pointers in the last page (error codes).

    Note that printk() call this code under logbuf_lock. Any recursive
    printks are redirected to the printk_safe implementation and the messages
    are stored into per-CPU buffers. These buffers might be eventually flushed
    in printk_safe_flush_on_panic() but it is not guaranteed.

    This patch adds a check using probe_kernel_read(). It is not a full-proof
    test. But it should help to see the error message in 99% situations where
    the kernel would silently crash otherwise.

    Also it makes the error handling unified for "%s" and the many %p*
    specifiers that need to read the data from a given address. We print:

    + (null) when accessing data on pure pure NULL address
    + (efault) when accessing data on an invalid address

    It does not affect the %p* specifiers that just print the given address
    in some form, namely %pF, %pf, %pS, %ps, %pB, %pK, %px, and plain %p.

    Note that we print (efault) from security reasons. In fact, the real
    address can be seen only by %px or eventually %pK.

    Link: http://lkml.kernel.org/r/20190417115350.20479-9-pmladek@suse.com
    To: Rasmus Villemoes
    Cc: Linus Torvalds
    Cc: "Tobin C . Harding"
    Cc: Joe Perches
    Cc: Andrew Morton
    Cc: Michal Hocko
    Cc: Steven Rostedt
    Cc: Sergey Senozhatsky
    Cc: linux-kernel@vger.kernel.org
    Reviewed-by: Sergey Senozhatsky
    Reviewed-by: Andy Shevchenko
    Signed-off-by: Petr Mladek

    Petr Mladek
     
  • There are few printk formats that make sense only with two or more
    specifiers. Also some specifiers make sense only when a kernel feature
    is enabled.

    The handling of unknown specifiers is inconsistent and not helpful.
    Using WARN() looks like an overkill for this type of error. pr_warn()
    is not good either. It would by handled via printk_safe buffer and
    it might be hard to match it with the problematic string.

    A reasonable compromise seems to be writing the unknown format specifier
    into the original string with a question mark, for example (%pC?).
    It should be self-explaining enough. Note that it is in brackets
    to follow the (null) style.

    Note that it introduces a warning about that test_hashed() function
    is unused. It is going to be used again by a later patch.

    Link: http://lkml.kernel.org/r/20190417115350.20479-8-pmladek@suse.com
    To: Rasmus Villemoes
    Cc: Linus Torvalds
    Cc: "Tobin C . Harding"
    Cc: Joe Perches
    Cc: Andrew Morton
    Cc: Michal Hocko
    Cc: Steven Rostedt
    Cc: Sergey Senozhatsky
    Cc: linux-kernel@vger.kernel.org
    Reviewed-by: Sergey Senozhatsky
    Reviewed-by: Andy Shevchenko
    Signed-off-by: Petr Mladek

    Petr Mladek
     

09 Apr, 2019

2 commits

  • We just added a new C header file for use with test modules that are
    intended to be run with kselftest. We can reduce code duplication by
    using this header.

    Use new kselftest header to reduce code duplication in test_printf and
    test_bitmap test modules.

    Acked-by: Kees Cook
    Signed-off-by: Tobin C. Harding
    Signed-off-by: Shuah Khan

    Tobin C. Harding
     
  • Currently the test_printf module does not have an exit function, this
    prevents the module from being unloaded. If we cannot unload the
    module we cannot run the tests a second time.

    Add an empty exit function.

    Acked-by: Kees Cook
    Signed-off-by: Tobin C. Harding
    Signed-off-by: Shuah Khan

    Tobin C. Harding
     

20 Mar, 2019

1 commit

  • Switch to bitmap_zalloc() to show clearly what we are allocating.
    Besides that it returns pointer of bitmap type instead of opaque void *.

    Link: http://lkml.kernel.org/r/20190304100009.65147-1-andriy.shevchenko@linux.intel.com
    To: linux-kernel@vger.kernel.org
    To: Andrew Morton
    To: linux@rasmusvillemoes.dk
    Signed-off-by: Andy Shevchenko
    Signed-off-by: Petr Mladek

    Andy Shevchenko
     

11 Dec, 2018

1 commit

  • There are users which print time and date represented by content of
    struct rtc_time in human readable format.

    Instead of open coding that each time introduce %ptR[dt][r] specifier.

    Cc: Arnd Bergmann
    Cc: Bartlomiej Zolnierkiewicz
    Cc: Dmitry Torokhov
    Cc: Geert Uytterhoeven
    Cc: Guan Xuetao
    Cc: Ingo Molnar
    Cc: Jason Wessel
    Cc: Jonathan Corbet
    Cc: Jonathan Hunter
    Cc: Krzysztof Kozlowski
    Cc: "Rafael J. Wysocki"
    Cc: Thierry Reding
    Cc: Petr Mladek
    Signed-off-by: Andy Shevchenko
    Reviewed-by: Petr Mladek
    Signed-off-by: Alexandre Belloni

    Andy Shevchenko
     

15 Jun, 2018

1 commit

  • If the test_printf module is loaded before the crng is initialized, the
    plain 'p' tests will fail because the printed address will not be hashed
    and the buffer will contain "(____ptrval____)" or "(ptrval)" instead
    (64-bit vs 32-bit).
    Since we cannot wait for the crng to be initialized for an undefined
    time, both plain 'p' tests now accept the strings "(____ptrval____)" or
    "(ptrval)" as a valid result and print a warning message.

    Link: http://lkml.kernel.org/r/20180613171840.29827-1-thierry.escande@linaro.org
    Fixes: ad67b74d2469d9b82 ("printk: hash addresses printed with %p")
    To: Andrew Morton
    To: David Miller
    Cc: Rasmus Villemoes
    Cc: "Tobin C . Harding"
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Thierry Escande
    Reviewed-by: Andy Shevchenko
    Signed-off-by: Petr Mladek

    Thierry Escande
     

11 Apr, 2018

1 commit

  • Sparse complains that constant is so big for unsigned long on 64-bit
    architecture.

    lib/test_printf.c:217:54: warning: constant 0xffff0123456789ab is so big it is unsigned long
    lib/test_printf.c:246:54: warning: constant 0xffff0123456789ab is so big it is unsigned long

    To satisfy everyone, mark the constant with UL.

    Link: http://lkml.kernel.org/r/20180216210711.79901-1-andriy.shevchenko@linux.intel.com
    To: "Tobin C . Harding"
    To: linux@rasmusvillemoes.dk
    To: Joe Perches
    To: linux-kernel@vger.kernel.org
    To: Andrew Morton
    Signed-off-by: Andy Shevchenko
    [pmladek@suse.com: Changed from ULL to UL as suggested by Luc Van Oostenryck ]
    Signed-off-by: Petr Mladek

    Andy Shevchenko
     

29 Nov, 2017

1 commit

  • Currently there exist approximately 14 000 places in the kernel where
    addresses are being printed using an unadorned %p. This potentially
    leaks sensitive information regarding the Kernel layout in memory. Many
    of these calls are stale, instead of fixing every call lets hash the
    address by default before printing. This will of course break some
    users, forcing code printing needed addresses to be updated.

    Code that _really_ needs the address will soon be able to use the new
    printk specifier %px to print the address.

    For what it's worth, usage of unadorned %p can be broken down as
    follows (thanks to Joe Perches).

    $ git grep -E '%p[^A-Za-z0-9]' | cut -f1 -d"/" | sort | uniq -c
    1084 arch
    20 block
    10 crypto
    32 Documentation
    8121 drivers
    1221 fs
    143 include
    101 kernel
    69 lib
    100 mm
    1510 net
    40 samples
    7 scripts
    11 security
    166 sound
    152 tools
    2 virt

    Add function ptr_to_id() to map an address to a 32 bit unique
    identifier. Hash any unadorned usage of specifier %p and any malformed
    specifiers.

    Signed-off-by: Tobin C. Harding

    Tobin C. Harding
     

16 Mar, 2016

1 commit

  • In mm we use several kinds of flags bitfields that are sometimes printed
    for debugging purposes, or exported to userspace via sysfs. To make
    them easier to interpret independently on kernel version and config, we
    want to dump also the symbolic flag names. So far this has been done
    with repeated calls to pr_cont(), which is unreliable on SMP, and not
    usable for e.g. sysfs export.

    To get a more reliable and universal solution, this patch extends
    printk() format string for pointers to handle the page flags (%pGp),
    gfp_flags (%pGg) and vma flags (%pGv). Existing users of
    dump_flag_names() are converted and simplified.

    It would be possible to pass flags by value instead of pointer, but the
    %p format string for pointers already has extensions for various kernel
    structures, so it's a good fit, and the extra indirection in a
    non-critical path is negligible.

    [linux@rasmusvillemoes.dk: lots of good implementation suggestions]
    Signed-off-by: Vlastimil Babka
    Acked-by: Michal Hocko
    Cc: Steven Rostedt
    Cc: Peter Zijlstra
    Cc: Arnaldo Carvalho de Melo
    Cc: Ingo Molnar
    Cc: Rasmus Villemoes
    Cc: Joonsoo Kim
    Cc: Minchan Kim
    Cc: Sasha Levin
    Cc: "Kirill A. Shutemov"
    Cc: Mel Gorman
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Vlastimil Babka
     

17 Jan, 2016

7 commits

  • Signed-off-by: Rasmus Villemoes
    Cc: Al Viro
    Cc: Andy Shevchenko
    Cc: Ingo Molnar
    Cc: Joe Perches
    Cc: Kees Cook
    Cc: Maurizio Lombardi
    Cc: Tejun Heo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rasmus Villemoes
     
  • Following "lib/vsprintf.c: expand field_width to 24 bits", let's add a
    test to see that we now actually support bitmaps with 65536 bits.

    Signed-off-by: Rasmus Villemoes
    Acked-by: Kees Cook
    Cc: Al Viro
    Cc: Andy Shevchenko
    Cc: Ingo Molnar
    Cc: Joe Perches
    Cc: Maurizio Lombardi
    Cc: Tejun Heo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rasmus Villemoes
     
  • These should also count as performed tests.

    Signed-off-by: Rasmus Villemoes
    Acked-by: Kees Cook
    Cc: Al Viro
    Cc: Andy Shevchenko
    Cc: Ingo Molnar
    Cc: Joe Perches
    Cc: Maurizio Lombardi
    Cc: Tejun Heo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rasmus Villemoes
     
  • This adds a few tests to test_number, one of which serves to document
    another deviation from POSIX/C99 (printing 0 with an explicit precision
    of 0).

    Signed-off-by: Rasmus Villemoes
    Cc: Al Viro
    Cc: Andy Shevchenko
    Cc: Ingo Molnar
    Cc: Joe Perches
    Cc: Kees Cook
    Cc: Maurizio Lombardi
    Cc: Tejun Heo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rasmus Villemoes
     
  • The kernel's printf doesn't follow the standards in a few corner cases
    (which are probably mostly irrelevant). Add tests that document the
    current behaviour.

    Signed-off-by: Rasmus Villemoes
    Cc: Al Viro
    Cc: Andy Shevchenko
    Cc: Ingo Molnar
    Cc: Joe Perches
    Cc: Kees Cook
    Cc: Maurizio Lombardi
    Cc: Tejun Heo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rasmus Villemoes
     
  • Add a few padding bytes on either side of the test buffer, and check
    that these (and the part of the buffer not used) are untouched by
    vsnprintf.

    Signed-off-by: Rasmus Villemoes
    Acked-by: Kees Cook
    Cc: Al Viro
    Cc: Andy Shevchenko
    Cc: Ingo Molnar
    Cc: Joe Perches
    Cc: Maurizio Lombardi
    Cc: Tejun Heo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rasmus Villemoes
     
  • BUG is a completely unnecessarily big hammer, and we're more likely to
    get the internal bug reported if we just pr_err() and ensure the test
    suite fails.

    Signed-off-by: Rasmus Villemoes
    Acked-by: Kees Cook
    Cc: Al Viro
    Cc: Andy Shevchenko
    Cc: Ingo Molnar
    Cc: Joe Perches
    Cc: Maurizio Lombardi
    Cc: Tejun Heo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rasmus Villemoes
     

07 Nov, 2015

1 commit

  • This adds a simple module for testing the kernel's printf facilities.
    Previously, some %p extensions have caused a wrong return value in case
    the entire output didn't fit and/or been unusable in kasprintf(). This
    should help catch such issues. Also, it should help ensure that changes
    to the formatting algorithms don't break anything.

    I'm not sure if we have a struct dentry or struct file lying around at
    boot time or if we can fake one, but most %p extensions should be
    testable, as should the ordinary number and string formatting.

    The nature of vararg functions means we can't use a more conventional
    table-driven approach.

    For now, this is mostly a skeleton; contributions are very
    welcome. Some tests are/will be slightly annoying to write, since the
    expected output depends on stuff like CONFIG_*, sizeof(long), runtime
    values etc.

    Signed-off-by: Rasmus Villemoes
    Reviewed-by: Kees Cook
    Cc: Andy Shevchenko
    Cc: Martin Kletzander
    Cc: Rasmus Villemoes
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rasmus Villemoes