lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Fri, 5 Jun 2020 15:59:55 -0700 From: Scott Branden <scott.branden@...adcom.com> To: Luis Chamberlain <mcgrof@...nel.org>, Greg Kroah-Hartman <gregkh@...uxfoundation.org>, David Brown <david.brown@...aro.org>, Alexander Viro <viro@...iv.linux.org.uk>, Shuah Khan <shuah@...nel.org>, bjorn.andersson@...aro.org, Shuah Khan <skhan@...uxfoundation.org>, Arnd Bergmann <arnd@...db.de> Cc: Mimi Zohar <zohar@...ux.ibm.com>, "Rafael J . Wysocki" <rafael@...nel.org>, linux-kernel@...r.kernel.org, linux-arm-msm@...r.kernel.org, linux-fsdevel@...r.kernel.org, BCM Kernel Feedback <bcm-kernel-feedback-list@...adcom.com>, Olof Johansson <olof@...om.net>, Andrew Morton <akpm@...ux-foundation.org>, Dan Carpenter <dan.carpenter@...cle.com>, Colin Ian King <colin.king@...onical.com>, Kees Cook <keescook@...omium.org>, Takashi Iwai <tiwai@...e.de>, linux-kselftest@...r.kernel.org, Andy Gross <agross@...nel.org>, linux-integrity@...r.kernel.org, linux-security-module@...r.kernel.org, Scott Branden <scott.branden@...adcom.com> Subject: [PATCH v6 4/8] firmware: test partial file reads of request_firmware_into_buf Add firmware tests for partial file reads of request_firmware_into_buf. Signed-off-by: Scott Branden <scott.branden@...adcom.com> --- .../selftests/firmware/fw_filesystem.sh | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/tools/testing/selftests/firmware/fw_filesystem.sh b/tools/testing/selftests/firmware/fw_filesystem.sh index fcc281373b4d..38e89ba1b4d3 100755 --- a/tools/testing/selftests/firmware/fw_filesystem.sh +++ b/tools/testing/selftests/firmware/fw_filesystem.sh @@ -149,6 +149,26 @@ config_unset_into_buf() echo 0 > $DIR/config_into_buf } +config_set_buf_size() +{ + echo $1 > $DIR/config_buf_size +} + +config_set_file_offset() +{ + echo $1 > $DIR/config_file_offset +} + +config_set_partial() +{ + echo 1 > $DIR/config_partial +} + +config_unset_partial() +{ + echo 0 > $DIR/config_partial +} + config_set_sync_direct() { echo 1 > $DIR/config_sync_direct @@ -207,6 +227,35 @@ read_firmwares() done } +read_firmwares_partial() +{ + if [ "$(cat $DIR/config_into_buf)" == "1" ]; then + fwfile="${FW_INTO_BUF}" + else + fwfile="${FW}" + fi + + if [ "$1" = "xzonly" ]; then + fwfile="${fwfile}-orig" + fi + + # Strip fwfile down to match partial offset and length + partial_data="$(cat $fwfile)" + partial_data="${partial_data:$2:$3}" + + for i in $(seq 0 3); do + config_set_read_fw_idx $i + + read_firmware="$(cat $DIR/read_firmware)" + + # Verify the contents are what we expect. + if [ $read_firmware != $partial_data ]; then + echo "request #$i: partial firmware was not loaded" >&2 + exit 1 + fi + done +} + read_firmwares_expect_nofile() { for i in $(seq 0 3); do @@ -319,6 +368,21 @@ test_batched_request_firmware_into_buf() echo "OK" } +test_batched_request_firmware_into_buf_partial() +{ + echo -n "Batched request_firmware_into_buf_partial() $2 off=$3 size=$4 try #$1: " + config_reset + config_set_name $TEST_FIRMWARE_INTO_BUF_FILENAME + config_set_into_buf + config_set_partial + config_set_buf_size $4 + config_set_file_offset $3 + config_trigger_sync + read_firmwares_partial $2 $3 $4 + release_all_firmware + echo "OK" +} + test_batched_request_firmware_direct() { echo -n "Batched request_firmware_direct() $2 try #$1: " @@ -371,6 +435,22 @@ for i in $(seq 1 5); do test_batched_request_firmware_into_buf $i normal done +for i in $(seq 1 5); do + test_batched_request_firmware_into_buf_partial $i normal 0 10 +done + +for i in $(seq 1 5); do + test_batched_request_firmware_into_buf_partial $i normal 0 5 +done + +for i in $(seq 1 5); do + test_batched_request_firmware_into_buf_partial $i normal 1 6 +done + +for i in $(seq 1 5); do + test_batched_request_firmware_into_buf_partial $i normal 2 10 +done + for i in $(seq 1 5); do test_batched_request_firmware_direct $i normal done -- 2.17.1
Powered by blists - more mailing lists