Skip to content

Commit e5f05f8

Browse files
committed
block: Add option to use driver whitelist even in tools
Currently, the block driver whitelists are only applied for the system emulator. All other binaries still give unrestricted access to all block drivers. There are use cases where this made sense because the main concern was avoiding customers running VMs on less optimised block drivers and getting bad performance. Allowing the same image format e.g. as a target for 'qemu-img convert' is not a problem then. However, if the concern is the supportability of the driver in general, either in full or when used read-write, not applying the list driver whitelist in tools doesn't help - especially since qemu-nbd and qemu-storage-daemon now give access to more or less the same operations in block drivers as running a system emulator. In order to address this, introduce a new configure option that enforces the driver whitelist in all binaries. Signed-off-by: Kevin Wolf <[email protected]> Message-Id: <[email protected]> Reviewed-by: Eric Blake <[email protected]> Signed-off-by: Kevin Wolf <[email protected]>
1 parent d44dae1 commit e5f05f8

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

block.c

+3
Original file line numberDiff line numberDiff line change
@@ -6162,6 +6162,9 @@ BlockDriverState *bdrv_find_backing_image(BlockDriverState *bs,
61626162

61636163
void bdrv_init(void)
61646164
{
6165+
#ifdef CONFIG_BDRV_WHITELIST_TOOLS
6166+
use_bdrv_whitelist = 1;
6167+
#endif
61656168
module_call_init(MODULE_INIT_BLOCK);
61666169
}
61676170

configure

+12-2
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ cross_prefix=""
243243
audio_drv_list=""
244244
block_drv_rw_whitelist=""
245245
block_drv_ro_whitelist=""
246+
block_drv_whitelist_tools="no"
246247
host_cc="cc"
247248
audio_win_int=""
248249
libs_qga=""
@@ -1016,6 +1017,10 @@ for opt do
10161017
;;
10171018
--block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
10181019
;;
1020+
--enable-block-drv-whitelist-in-tools) block_drv_whitelist_tools="yes"
1021+
;;
1022+
--disable-block-drv-whitelist-in-tools) block_drv_whitelist_tools="no"
1023+
;;
10191024
--enable-debug-tcg) debug_tcg="yes"
10201025
;;
10211026
--disable-debug-tcg) debug_tcg="no"
@@ -1800,10 +1805,12 @@ Advanced options (experts only):
18001805
--block-drv-whitelist=L Same as --block-drv-rw-whitelist=L
18011806
--block-drv-rw-whitelist=L
18021807
set block driver read-write whitelist
1803-
(affects only QEMU, not qemu-img)
1808+
(by default affects only QEMU, not tools like qemu-img)
18041809
--block-drv-ro-whitelist=L
18051810
set block driver read-only whitelist
1806-
(affects only QEMU, not qemu-img)
1811+
(by default affects only QEMU, not tools like qemu-img)
1812+
--enable-block-drv-whitelist-in-tools
1813+
use block whitelist also in tools instead of only QEMU
18071814
--enable-trace-backends=B Set trace backend
18081815
Available backends: $trace_backend_list
18091816
--with-trace-file=NAME Full PATH,NAME of file to store traces
@@ -4583,6 +4590,9 @@ if test "$audio_win_int" = "yes" ; then
45834590
fi
45844591
echo "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
45854592
echo "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
4593+
if test "$block_drv_whitelist_tools" = "yes" ; then
4594+
echo "CONFIG_BDRV_WHITELIST_TOOLS=y" >> $config_host_mak
4595+
fi
45864596
if test "$xfs" = "yes" ; then
45874597
echo "CONFIG_XFS=y" >> $config_host_mak
45884598
fi

meson.build

+1
Original file line numberDiff line numberDiff line change
@@ -2996,6 +2996,7 @@ summary_info += {'coroutine pool': config_host['CONFIG_COROUTINE_POOL'] == '1
29962996
if have_block
29972997
summary_info += {'Block whitelist (rw)': config_host['CONFIG_BDRV_RW_WHITELIST']}
29982998
summary_info += {'Block whitelist (ro)': config_host['CONFIG_BDRV_RO_WHITELIST']}
2999+
summary_info += {'Use block whitelist in tools': config_host.has_key('CONFIG_BDRV_WHITELIST_TOOLS')}
29993000
summary_info += {'VirtFS support': have_virtfs}
30003001
summary_info += {'build virtiofs daemon': have_virtiofsd}
30013002
summary_info += {'Live block migration': config_host.has_key('CONFIG_LIVE_BLOCK_MIGRATION')}

0 commit comments

Comments
 (0)