From: Greg Kroah-Hartman Date: Fri, 10 Nov 2017 14:13:50 +0000 (+0100) Subject: 4.4-stable patches X-Git-Tag: v3.18.81~21 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=149c92bf24a86a4c7b41e2a204b8313cfbdbe64e;p=thirdparty%2Fkernel%2Fstable-queue.git 4.4-stable patches added patches: selftests-firmware-add-empty-string-and-async-tests.patch selftests-firmware-send-expected-errors-to-dev-null.patch test-firmware_class-report-errors-properly-on-failure.patch tools-firmware-check-for-distro-fallback-udev-cancel-rule.patch --- diff --git a/queue-4.4/selftests-firmware-add-empty-string-and-async-tests.patch b/queue-4.4/selftests-firmware-add-empty-string-and-async-tests.patch new file mode 100644 index 00000000000..015cd01e492 --- /dev/null +++ b/queue-4.4/selftests-firmware-add-empty-string-and-async-tests.patch @@ -0,0 +1,47 @@ +From 1b1fe542b6f010cf6bc7e1c92805e1c0e133e007 Mon Sep 17 00:00:00 2001 +From: Brian Norris +Date: Wed, 9 Dec 2015 14:50:29 -0800 +Subject: selftests: firmware: add empty string and async tests + +From: Brian Norris + +commit 1b1fe542b6f010cf6bc7e1c92805e1c0e133e007 upstream. + +Now that we've added a 'trigger_async_request' knob to test the +request_firmware_nowait() API, let's use it. Also add tests for the +empty ("") string, since there have been a couple errors in that +handling already. + +Since we now have real ways that the sysfs write might fail, let's add +the appropriate check on the 'echo' lines too. + +Signed-off-by: Brian Norris +Acked-by: Kees Cook +Signed-off-by: Shuah Khan +[AmitP: Dropped the async trigger testing parts from original commit] +Signed-off-by: Amit Pundir +Signed-off-by: Greg Kroah-Hartman +--- + tools/testing/selftests/firmware/fw_filesystem.sh | 10 +++++++++- + 1 file changed, 9 insertions(+), 1 deletion(-) + +--- a/tools/testing/selftests/firmware/fw_filesystem.sh ++++ b/tools/testing/selftests/firmware/fw_filesystem.sh +@@ -48,8 +48,16 @@ echo "ABCD0123" >"$FW" + + NAME=$(basename "$FW") + ++if printf '\000' >"$DIR"/trigger_request; then ++ echo "$0: empty filename should not succeed" >&2 ++ exit 1 ++fi ++ + # Request a firmware that doesn't exist, it should fail. +-echo -n "nope-$NAME" >"$DIR"/trigger_request ++if echo -n "nope-$NAME" >"$DIR"/trigger_request; then ++ echo "$0: firmware shouldn't have loaded" >&2 ++ exit 1 ++fi + if diff -q "$FW" /dev/test_firmware >/dev/null ; then + echo "$0: firmware was not expected to match" >&2 + exit 1 diff --git a/queue-4.4/selftests-firmware-send-expected-errors-to-dev-null.patch b/queue-4.4/selftests-firmware-send-expected-errors-to-dev-null.patch new file mode 100644 index 00000000000..e213e3784fc --- /dev/null +++ b/queue-4.4/selftests-firmware-send-expected-errors-to-dev-null.patch @@ -0,0 +1,50 @@ +From 880444e214cfd293a2e8cc4bd3505f7ffa6ce33a Mon Sep 17 00:00:00 2001 +From: "Luis R. Rodriguez" +Date: Fri, 16 Dec 2016 03:10:35 -0800 +Subject: selftests: firmware: send expected errors to /dev/null + +From: Luis R. Rodriguez + +commit 880444e214cfd293a2e8cc4bd3505f7ffa6ce33a upstream. + +Error that we expect should not be spilled to stdout. + +Without this we get: + +./fw_filesystem.sh: line 58: printf: write error: Invalid argument +./fw_filesystem.sh: line 63: printf: write error: No such device +./fw_filesystem.sh: line 69: echo: write error: No such file or directory +./fw_filesystem.sh: filesystem loading works +./fw_filesystem.sh: async filesystem loading works + +With it: + +./fw_filesystem.sh: filesystem loading works +./fw_filesystem.sh: async filesystem loading works + +Signed-off-by: Luis R. Rodriguez +[AmitP: Dropped the async trigger testing parts from original commit] +Signed-off-by: Amit Pundir +Signed-off-by: Greg Kroah-Hartman +--- + tools/testing/selftests/firmware/fw_filesystem.sh | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/tools/testing/selftests/firmware/fw_filesystem.sh ++++ b/tools/testing/selftests/firmware/fw_filesystem.sh +@@ -48,13 +48,13 @@ echo "ABCD0123" >"$FW" + + NAME=$(basename "$FW") + +-if printf '\000' >"$DIR"/trigger_request; then ++if printf '\000' >"$DIR"/trigger_request 2> /dev/null; then + echo "$0: empty filename should not succeed" >&2 + exit 1 + fi + + # Request a firmware that doesn't exist, it should fail. +-if echo -n "nope-$NAME" >"$DIR"/trigger_request; then ++if echo -n "nope-$NAME" >"$DIR"/trigger_request 2> /dev/null; then + echo "$0: firmware shouldn't have loaded" >&2 + exit 1 + fi diff --git a/queue-4.4/series b/queue-4.4/series index 20a319186a1..dc1c6f98f08 100644 --- a/queue-4.4/series +++ b/queue-4.4/series @@ -41,3 +41,7 @@ mips-fix-cm-region-target-definitions.patch mips-smp-use-a-completion-event-to-signal-cpu-up.patch mips-fix-race-on-setting-and-getting-cpu_online_mask.patch mips-smp-fix-deadlock-online-race.patch +test-firmware_class-report-errors-properly-on-failure.patch +selftests-firmware-add-empty-string-and-async-tests.patch +selftests-firmware-send-expected-errors-to-dev-null.patch +tools-firmware-check-for-distro-fallback-udev-cancel-rule.patch diff --git a/queue-4.4/test-firmware_class-report-errors-properly-on-failure.patch b/queue-4.4/test-firmware_class-report-errors-properly-on-failure.patch new file mode 100644 index 00000000000..3765b1729e3 --- /dev/null +++ b/queue-4.4/test-firmware_class-report-errors-properly-on-failure.patch @@ -0,0 +1,57 @@ +From 47e0bbb7fa985a0f1b5794a8653fae4f8f49de77 Mon Sep 17 00:00:00 2001 +From: Brian Norris +Date: Wed, 9 Dec 2015 14:50:25 -0800 +Subject: test: firmware_class: report errors properly on failure + +From: Brian Norris + +commit 47e0bbb7fa985a0f1b5794a8653fae4f8f49de77 upstream. + +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 +Signed-off-by: Amit Pundir +Signed-off-by: Greg Kroah-Hartman + +--- + lib/test_firmware.c | 11 ++++++++--- + 1 file changed, 8 insertions(+), 3 deletions(-) + +--- a/lib/test_firmware.c ++++ b/lib/test_firmware.c +@@ -65,14 +65,19 @@ static ssize_t trigger_request_store(str + release_firmware(test_firmware); + test_firmware = NULL; + rc = request_firmware(&test_firmware, name, dev); +- if (rc) ++ if (rc) { + pr_info("load of '%s' failed: %d\n", name, rc); +- pr_info("loaded: %zu\n", test_firmware ? test_firmware->size : 0); ++ goto out; ++ } ++ pr_info("loaded: %zu\n", test_firmware->size); ++ rc = count; ++ ++out: + mutex_unlock(&test_fw_mutex); + + kfree(name); + +- return count; ++ return rc; + } + static DEVICE_ATTR_WO(trigger_request); + diff --git a/queue-4.4/tools-firmware-check-for-distro-fallback-udev-cancel-rule.patch b/queue-4.4/tools-firmware-check-for-distro-fallback-udev-cancel-rule.patch new file mode 100644 index 00000000000..eacd3140fba --- /dev/null +++ b/queue-4.4/tools-firmware-check-for-distro-fallback-udev-cancel-rule.patch @@ -0,0 +1,60 @@ +From afb999cdef69148f366839e74470d8f5375ba5f1 Mon Sep 17 00:00:00 2001 +From: "Luis R. Rodriguez" +Date: Mon, 23 Jan 2017 08:11:07 -0800 +Subject: tools: firmware: check for distro fallback udev cancel rule + +From: Luis R. Rodriguez + +commit afb999cdef69148f366839e74470d8f5375ba5f1 upstream. + +Some distributions (Debian, OpenSUSE) have a udev rule in place to cancel +all fallback mechanism uevents immediately. This would obviously +make it hard to test against the fallback mechanism test interface, +so we need to check for this. + +Signed-off-by: Luis R. Rodriguez +Signed-off-by: Amit Pundir +Signed-off-by: Greg Kroah-Hartman + +--- + tools/testing/selftests/firmware/fw_userhelper.sh | 28 ++++++++++++++++++++-- + 1 file changed, 26 insertions(+), 2 deletions(-) + +--- a/tools/testing/selftests/firmware/fw_userhelper.sh ++++ b/tools/testing/selftests/firmware/fw_userhelper.sh +@@ -64,9 +64,33 @@ trap "test_finish" EXIT + echo "ABCD0123" >"$FW" + NAME=$(basename "$FW") + ++DEVPATH="$DIR"/"nope-$NAME"/loading ++ + # Test failure when doing nothing (timeout works). +-echo 1 >/sys/class/firmware/timeout +-echo -n "$NAME" >"$DIR"/trigger_request ++echo -n 2 >/sys/class/firmware/timeout ++echo -n "nope-$NAME" >"$DIR"/trigger_request 2>/dev/null & ++ ++# Give the kernel some time to load the loading file, must be less ++# than the timeout above. ++sleep 1 ++if [ ! -f $DEVPATH ]; then ++ echo "$0: fallback mechanism immediately cancelled" ++ echo "" ++ echo "The file never appeared: $DEVPATH" ++ echo "" ++ echo "This might be a distribution udev rule setup by your distribution" ++ echo "to immediately cancel all fallback requests, this must be" ++ echo "removed before running these tests. To confirm look for" ++ echo "a firmware rule like /lib/udev/rules.d/50-firmware.rules" ++ echo "and see if you have something like this:" ++ echo "" ++ echo "SUBSYSTEM==\"firmware\", ACTION==\"add\", ATTR{loading}=\"-1\"" ++ echo "" ++ echo "If you do remove this file or comment out this line before" ++ echo "proceeding with these tests." ++ exit 1 ++fi ++ + if diff -q "$FW" /dev/test_firmware >/dev/null ; then + echo "$0: firmware was not expected to match" >&2 + exit 1