- hw/nvme: Remove redundant dma_blk_write - tests/avocado/machine_s390_ccw_virtio: Adapt test to new default resolution - edid: set default resolution to 1280x800 (WXGA) - iotests/308: Fix for CAP_DAC_OVERRIDE - hvf: remove unused but set variable - vvfat: Fix vvfat_write() for writes before the root directory - hw/misc/nrf51_rng: Don't use BIT_MASK() when we mean BIT() - hw/pci: Remove unused pci_irq_pulse() method - ui/gtk: fix leaks found wtih fuzzing - target/i386: fix size of EBP writeback in gen_enter() - tests/qtest/fuzz: fix memleak in qos_fuzz.c - hw/core/loader: gunzip(): fix memory leak on error path - migration: fix a typo - scsi: fetch unit attention when creating the request - raw-format: Fix error message for invalid offset/size - tcg: Reset data_gen_ptr correctly - Fix calculation of minimum in colo_compare_tcp - hw/intc: Don't clear pending bits on IRQ lowering - target/arm: Drop user-only special case in sve_stN_r - usb-hub: Fix handling port power control messages - target/ppc: Set ctx->opcode for decode_insn32() - linux-user: Add proper strace format strings for getdents()/getdents64() - linux-user: Fix TARGET_PROT_SEM for XTENSA - linux-user/hppa: Set TASK_UNMAPPED_BASE to 0xfa000000 for hppa arch - linux-user/hppa: Dump IIR on register dump - tests: Fix typo in check-help output - qdev-core.h: Fix wrongly named reference to TYPE_SPLIT_IRQ - hw/scsi/megasas: Simplify using the ldst API - gqa-win: get_pci_info: Clean dev_info if handle is valid - target/ppc: Fix 7448 support - vvfat: Fix size of temporary qcow file - docs: Correct 'vhost-user-blk' spelling - jackaudio: use ifdefs to hide unavailable functions - simplebench: Fix Python syntax error (reported by LGTM) - python: update type hints for mypy 0.930 - Python/aqmp: fix type definitions for mypy 0.920 - tcg: Allow top bit of SIMD_DATA_BITS to be set in simd_desc() - hw/ppc/e500: Prefer QOM cast - hw/ppc/e500: Remove unused "irqs" parameter - hw/ppc/e500: Add missing device tree properties to i2c controller node - linux-user: Show timespec on strace for futex() - linux-user: Add strace for clock_nanosleep() - linux-user: Fix strace of chmod() if mode == 0 - linux-user: Log failing executable in EXCP_DUMP() - linux-user: Add pidfd_open(), pidfd_send_signal() and pidfd_getfd() syscalls Signed-off-by: Jiabo Feng <fengjiabo1@huawei.com> (cherry picked from commit 87ebac5b5cfb97ddb7ac2af097703758fb0751c4)
82 lines
3.4 KiB
Diff
82 lines
3.4 KiB
Diff
From 769aa1236789f0b5c47255aad220b73a8e286072 Mon Sep 17 00:00:00 2001
|
|
From: Luo Yifan <luoyifan_yewu@cmss.chinamobile.com>
|
|
Date: Mon, 16 Dec 2024 10:32:54 +0800
|
|
Subject: [PATCH] iotests/308: Fix for CAP_DAC_OVERRIDE
|
|
|
|
cherry picked from commit e2eec2819a96f3a5d68f899c836ad365468cec01
|
|
|
|
With CAP_DAC_OVERRIDE (which e.g. root generally has), permission checks
|
|
will be bypassed when opening files.
|
|
|
|
308 in one instance tries to open a read-only file (FUSE export) with
|
|
qemu-io as read/write, and expects this to fail. However, when running
|
|
it as root, opening will succeed (thanks to CAP_DAC_OVERRIDE) and only
|
|
the actual write operation will fail.
|
|
|
|
Note this as "Case not run", but have the test pass in either case.
|
|
|
|
Reported-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
|
|
Fixes: 2c7dd057aa7bd7a875e9b1a53975c220d6380bc4
|
|
("export/fuse: Pass default_permissions for mount")
|
|
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
|
|
Message-Id: <20220103120014.13061-1-hreitz@redhat.com>
|
|
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
Signed-off-by: Luo Yifan <luoyifan_yewu@cmss.chinamobile.com>
|
|
---
|
|
tests/qemu-iotests/308 | 25 +++++++++++++++++++++++--
|
|
tests/qemu-iotests/308.out | 2 +-
|
|
2 files changed, 24 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/tests/qemu-iotests/308 b/tests/qemu-iotests/308
|
|
index 2e3f8f4282..bde4aac2fa 100755
|
|
--- a/tests/qemu-iotests/308
|
|
+++ b/tests/qemu-iotests/308
|
|
@@ -230,8 +230,29 @@ echo '=== Writable export ==='
|
|
fuse_export_add 'export-mp' "'mountpoint': '$EXT_MP', 'writable': true"
|
|
|
|
# Check that writing to the read-only export fails
|
|
-$QEMU_IO -f raw -c 'write -P 42 1M 64k' "$TEST_IMG" 2>&1 \
|
|
- | _filter_qemu_io | _filter_testdir | _filter_imgfmt
|
|
+output=$($QEMU_IO -f raw -c 'write -P 42 1M 64k' "$TEST_IMG" 2>&1 \
|
|
+ | _filter_qemu_io | _filter_testdir | _filter_imgfmt)
|
|
+
|
|
+# Expected reference output: Opening the file fails because it has no
|
|
+# write permission
|
|
+reference="Could not open 'TEST_DIR/t.IMGFMT': Permission denied"
|
|
+
|
|
+if echo "$output" | grep -q "$reference"; then
|
|
+ echo "Writing to read-only export failed: OK"
|
|
+elif echo "$output" | grep -q "write failed: Permission denied"; then
|
|
+ # With CAP_DAC_OVERRIDE (e.g. when running this test as root), the export
|
|
+ # can be opened regardless of its file permissions, but writing will then
|
|
+ # fail. This is not the result for which we want to test, so count this as
|
|
+ # a SKIP.
|
|
+ _casenotrun "Opening RO export as R/W succeeded, perhaps because of" \
|
|
+ "CAP_DAC_OVERRIDE"
|
|
+
|
|
+ # Still, write this to the reference output to make the test pass
|
|
+ echo "Writing to read-only export failed: OK"
|
|
+else
|
|
+ echo "Writing to read-only export failed: ERROR"
|
|
+ echo "$output"
|
|
+fi
|
|
|
|
# But here it should work
|
|
$QEMU_IO -f raw -c 'write -P 42 1M 64k' "$EXT_MP" | _filter_qemu_io
|
|
diff --git a/tests/qemu-iotests/308.out b/tests/qemu-iotests/308.out
|
|
index fc47bb11a2..e4467a10cf 100644
|
|
--- a/tests/qemu-iotests/308.out
|
|
+++ b/tests/qemu-iotests/308.out
|
|
@@ -95,7 +95,7 @@ virtual size: 0 B (0 bytes)
|
|
'mountpoint': 'TEST_DIR/t.IMGFMT.fuse', 'writable': true
|
|
} }
|
|
{"return": {}}
|
|
-qemu-io: can't open device TEST_DIR/t.IMGFMT: Could not open 'TEST_DIR/t.IMGFMT': Permission denied
|
|
+Writing to read-only export failed: OK
|
|
wrote 65536/65536 bytes at offset 1048576
|
|
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
wrote 65536/65536 bytes at offset 1048576
|
|
--
|
|
2.41.0.windows.1
|
|
|