04 Feb, 2018

1 commit


11 Aug, 2017

1 commit

  • The firmware API has a feature to enable batching requests for the same fil
    e under one worker, so only one lookup is done. This only triggers if we so
    happen to schedule two lookups for same file around the same time, or if
    release_firmware() has not been called for a successful firmware call. This
    can happen for instance if you happen to have multiple devices and one
    device driver for certain drivers where the stars line up scheduling
    wise.

    This adds a new sync and async test trigger. Instead of adding a new
    trigger for each new test type we make the tests a bit configurable so that
    we could configure the tests in userspace and just kick a test through a
    few basic triggers. With this, for instance the two types of sync requests:

    o request_firmware() and
    o request_firmware_direct()

    can be modified with a knob. Likewise the two type of async requests:

    o request_firmware_nowait(uevent=true) and
    o request_firmware_nowait(uevent=false)

    can be configured with another knob. The call request_firmware_into_buf()
    has no users... yet.

    The old tests are left in place as-is given they serve a few other purposes
    which we are currently not interested in also testing yet. This will change
    later as we will be able to just consolidate all tests under a few basic
    triggers with just one general configuration setup.

    We perform two types of tests, one for where the file is present and one
    for where the file is not present. All test tests go tested and they now
    pass for the following 3 kernel builds possible for the firmware API:

    0. Most distro setup:
    CONFIG_FW_LOADER_USER_HELPER_FALLBACK=n
    CONFIG_FW_LOADER_USER_HELPER=y
    1. Android:
    CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y
    CONFIG_FW_LOADER_USER_HELPER=y
    2. Rare build:
    CONFIG_FW_LOADER_USER_HELPER_FALLBACK=n
    CONFIG_FW_LOADER_USER_HELPER=n

    Signed-off-by: Luis R. Rodriguez
    Signed-off-by: Greg Kroah-Hartman

    Luis R. Rodriguez
     

25 Jan, 2017

3 commits


08 Jan, 2016

3 commits

  • We might want to test for bugs like that found in commit f9692b2699bd
    ("firmware: fix possible use after free on name on asynchronous
    request"), where the asynchronous request API had race conditions.

    Let's add a simple file that will launch the async request, then wait
    until it's complete and report the status. It's not a true async test
    (we're using a mutex + wait_for_completion(), so we can't get more than
    one going at the same time), but it does help make sure the basic API is
    sane, and it can catch some class of bugs.

    Signed-off-by: Brian Norris
    Cc: Luis R. Rodriguez
    Acked-by: Kees Cook
    Signed-off-by: Shuah Khan

    Brian Norris
     
  • We're essentially just doing an open-coded kstrndup(). The only
    differences are with what happens after the first '\0' character, but
    request_firmware() doesn't care about that.

    Suggested-by: Kees Cook
    Signed-off-by: Brian Norris
    Signed-off-by: Shuah Khan

    Brian Norris
     
  • request_firmware() failures currently won't get reported at all (the
    error code is discarded). What's more, we get confusing messages, like:

    # echo -n notafile > /sys/devices/virtual/misc/test_firmware/trigger_request
    [ 8280.311856] test_firmware: loading 'notafile'
    [ 8280.317042] test_firmware: load of 'notafile' failed: -2
    [ 8280.322445] test_firmware: loaded: 0
    # echo $?
    0

    Report the failures via write() errors, and don't say we "loaded"
    anything.

    Signed-off-by: Brian Norris
    Acked-by: Kees Cook
    Signed-off-by: Shuah Khan

    Brian Norris
     

18 Jul, 2014

1 commit

  • This provides a simple interface to trigger the firmware_class loader
    to test built-in, filesystem, and user helper modes. Additionally adds
    tests via the new interface to the selftests tree.

    Signed-off-by: Kees Cook
    Signed-off-by: Greg Kroah-Hartman

    Kees Cook