[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1405373897-31671-8-git-send-email-keescook@chromium.org>
Date: Mon, 14 Jul 2014 14:38:17 -0700
From: Kees Cook <keescook@...omium.org>
To: linux-kernel@...r.kernel.org
Cc: Kees Cook <keescook@...omium.org>,
Ming Lei <ming.lei@...onical.com>,
"Luis R. Rodriguez" <mcgrof@...e.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
James Morris <james.l.morris@...cle.com>,
David Howells <dhowells@...hat.com>, linux-doc@...r.kernel.org,
linux-security-module@...r.kernel.org, linux-firmware@...nel.org,
linux-wireless <linux-wireless@...r.kernel.org>
Subject: [PATCH 7/7] test: add "fd" firmware loading test to selftests
This adds tests for the new "fd" interface to the firmware selftests.
Signed-off-by: Kees Cook <keescook@...omium.org>
---
tools/testing/selftests/firmware/fw_userhelper.sh | 34 ++++++++++++++++++---
1 file changed, 30 insertions(+), 4 deletions(-)
diff --git a/tools/testing/selftests/firmware/fw_userhelper.sh b/tools/testing/selftests/firmware/fw_userhelper.sh
index 6efbade12139..e2766613e5b5 100644
--- a/tools/testing/selftests/firmware/fw_userhelper.sh
+++ b/tools/testing/selftests/firmware/fw_userhelper.sh
@@ -25,6 +25,7 @@ load_fw()
{
local name="$1"
local file="$2"
+ local fd="$3"
# This will block until our load (below) has finished.
echo -n "$name" >"$DIR"/trigger_request &
@@ -40,9 +41,16 @@ load_fw()
fi
done
- echo 1 >"$DIR"/"$name"/loading
- cat "$file" >"$DIR"/"$name"/data
- echo 0 >"$DIR"/"$name"/loading
+ if [ -z "$fd" ]; then
+ echo 1 >"$DIR"/"$name"/loading
+ cat "$file" >"$DIR"/"$name"/data
+ echo 0 >"$DIR"/"$name"/loading
+ else
+ if ! echo "$fd" <"$file" >"$DIR"/"$name"/fd 2>/dev/null ; then
+ # If the echo fails, abort to avoid timeout.
+ echo -1 > "$DIR"/"$name"/loading
+ fi
+ fi
# Wait for request to finish.
wait
@@ -83,7 +91,25 @@ if ! diff -q "$FW" /dev/test_firmware >/dev/null ; then
echo "$0: firmware was not loaded" >&2
exit 1
else
- echo "$0: user helper firmware loading works"
+ echo "$0: user helper firmware via 'loading' works"
+fi
+
+# Request a bad file descriptor, expected to fail.
+load_fw "$NAME" "$FW" 100
+if diff -q "$FW" /dev/test_firmware >/dev/null ; then
+ echo "$0: firmware was not expected to match" >&2
+ exit 1
+else
+ echo "$0: bad file descriptor correctly fails"
+fi
+
+# Request with the correct file descriptor.
+load_fw "$NAME" "$FW" 0
+if ! diff -q "$FW" /dev/test_firmware >/dev/null ; then
+ echo "$0: failed to load with good fd" >&2
+ exit 1
+else
+ echo "$0: user helper firmware via 'fd' works"
fi
exit 0
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists