hw/sd: Allow card size not power of 2 again
cover hw/sd: Allow card size not power of 2 again
Hi Ubi-Wan Kenubi and Tom,
In commit a9bcedd (SD card size has to be power of 2) we decided to restrict SD card size to avoid security problems (CVE-2020-13253) but this became not practical to some users.
This RFC series tries to remove the limitation, keeping our functional tests working. It is unfinished work because I had to attend other topics, but sending it early as RFC to get feedback. I'll keep working when I get more time, except if one if you can help me.
Alexander, could you generate a qtest reproducer with the fuzzer corpus? See: https://bugs.launchpad.net/qemu/+bug/1878054
Thanks,
Phil.
Philippe Mathieu-Daudé (9):
hw/sd: When card is in wrong state, log which state it is hw/sd: Extract address_in_range() helper, log invalid accesses tests/acceptance: Tag NetBSD tests as 'os:netbsd' tests/acceptance: Extract image_expand() helper tests/acceptance: Use image_expand() in
test_arm_orangepi_uboot_netbsd9
tests/acceptance: Use image_expand() in test_arm_orangepi_bionic_20_08 tests/acceptance: Do not expand SD card image in test_arm_orangepi_sd tests/acceptance: Remove now unused pow2ceil()
hw/sd: Allow card size not power of 2 again
hw/sd/sd.c | 60 +++++++++++++------------- tests/acceptance/boot_linux_console.py | 39 ++++++++--------- tests/acceptance/ppc_prep_40p.py | 2 + 3 files changed, 52 insertions(+), 49 deletions(-)
Signature · 1 line
2.31.1
PATCH 1/9 hw/sd: When card is in wrong state, log which state it is
We report the card is in an inconsistent state, but don't precise in which state it is. Add this information, as it is useful when debugging problems.
--- hw/sd/sd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/sd/sd.c +2 -1
@@ -1504,7 +1504,8 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req)return sd_illegal; } -qemu_log_mask (LOG_GUEST_ERROR ,"SD: CMD%i in a wrong state\n" , req.cmd); +qemu_log_mask (LOG_GUEST_ERROR ,"SD: CMD%i in a wrong state: %s\n" , + req.cmd,sd_state_name (sd->state));return sd_illegal; }
Signature · 1 line
2.31.1
Re: [PATCH 1/9] hw/sd: When card is in wrong state, log which state it is
Quoted 1 line · Philippe Mathieu-Daudé
We report the card is in an inconsistent state, but don't precise
s/don't/aren't/
Quoted 7 lines
in which state it is. Add this information, as it is useful when debugging problems.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/sd/sd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 19 lines
hw/sd/sd.c +2
-1@@ -1504,7 +1504,8 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req)return sd_illegal; } -qemu_log_mask (LOG_GUEST_ERROR ,"SD: CMD%i in a wrong state\n" , req.cmd); +qemu_log_mask (LOG_GUEST_ERROR ,"SD: CMD%i in a wrong state: %s\n" , + req.cmd,sd_state_name (sd->state));return sd_illegal; }Signature · 1 line
2.31.1
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
PATCH 2/9 hw/sd: Extract address_in_range() helper, log invalid accesses
In reply to Philippe Mathieu-DaudéMultiple commands have to check the address requested is valid. Extract this code pattern as a new address_in_range() helper, and log invalid accesses as guest errors.
--- hw/sd/sd.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-)
hw/sd/sd.c +20 -12
@@ -937,6 +937,18 @@ static void sd_lock_command(SDState *sd) sd->card_status &= ~CARD_IS_LOCKED ; } +static bool address_in_range (SDState *sd,const char *desc, +uint64_t addr,uint32_t length) +{ +if (addr + length > sd->size) { +qemu_log_mask (LOG_GUEST_ERROR ,"%s offset %lu > card %lu [%%%u]\n" , + desc, addr, sd->size, length); + sd->card_status |=ADDRESS_ERROR ; +return false; + } +return true; +} +static sd_rsp_type_t sd_normal_command (SDState *sd,SDRequest req) {uint32_t rca =0x0000 ;
@@ -1218,8 +1230,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req)switch (sd->state) {case sd_transfer_state: -if (addr + sd->blk_len > sd->size) { - sd->card_status |=ADDRESS_ERROR ; +if (!address_in_range (sd,"READ_BLOCK" , addr, sd->blk_len)) {return sd_r1; }
@@ -1264,8 +1275,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req)switch (sd->state) {case sd_transfer_state: -if (addr + sd->blk_len > sd->size) { - sd->card_status |=ADDRESS_ERROR ; +if (!address_in_range (sd,"WRITE_BLOCK" , addr, sd->blk_len)) {return sd_r1; }
@@ -1325,8 +1335,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req)switch (sd->state) {case sd_transfer_state: -if (addr >= sd->size) { - sd->card_status |=ADDRESS_ERROR ; +if (!address_in_range (sd,"SET_WRITE_PROT" , addr,1 )) {return sd_r1b; }
@@ -1348,8 +1357,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req)switch (sd->state) {case sd_transfer_state: -if (addr >= sd->size) { - sd->card_status |=ADDRESS_ERROR ; +if (!address_in_range (sd,"CLR_WRITE_PROT" , addr,1 )) {return sd_r1b; }
@@ -1826,8 +1834,8 @@ void sd_write_byte(SDState *sd, uint8_t value)case 25 :/* CMD25: WRITE_MULTIPLE_BLOCK */ if (sd->data_offset ==0 ) {/* Start of the block - let's check the address is valid */ -if (sd->data_start + sd->blk_len > sd->size) { - sd->card_status |=ADDRESS_ERROR ; +if (!address_in_range (sd,"WRITE_MULTIPLE_BLOCK" , + sd->data_start, sd->blk_len)) {break ; }if (sd->size <=SDSC_MAX_CAPACITY ) {
@@ -1999,8 +2007,8 @@ uint8_t sd_read_byte(SDState *sd)case 18 :/* CMD18: READ_MULTIPLE_BLOCK */ if (sd->data_offset ==0 ) { -if (sd->data_start + io_len > sd->size) { - sd->card_status |=ADDRESS_ERROR ; +if (!address_in_range (sd,"READ_MULTIPLE_BLOCK" , + sd->data_start, io_len)) {return 0x00 ; }BLK_READ_BLOCK (sd->data_start, io_len);
Signature · 1 line
2.31.1
Re: [PATCH 2/9] hw/sd: Extract address_in_range() helper, log invalid accesses
Quoted 1 line · Philippe Mathieu-Daudé
Multiple commands have to check the address requested is valid.
check that the
Quoted 13 lines
Extract this code pattern as a new
address_in_range()helper, and log invalid accesses as guest errors.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/sd/sd.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-)hw/sd/sd.c +0
-0
hw/sd/sd.c static void sd_lock_command(SDState *sd) · line 945
Quoted 9 lines
hw/sd/sd.c +6
-0@@ -937,6 +937,18 @@ static void sd_lock_command(SDState *sd) sd->card_status &= ~CARD_IS_LOCKED ; } +static bool address_in_range (SDState *sd,const char *desc, +uint64_t addr,uint32_t length) +{ +if (addr + length > sd->size) { +qemu_log_mask (LOG_GUEST_ERROR ,"%s offset %lu > card %lu [%%%u]\n" , + desc, addr, sd->size, length);
For a (fictitiously small) device with 2048 bytes and a read request of 2k at offset 1k, this results in the odd message:
READ_BLOCK offset 1024 > card 2048 [%2048]
Would it be any better as:
"%s offset+length %lu+%lu > card size %lu\n"
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
PATCH 3/9 tests/acceptance: Tag NetBSD tests as 'os:netbsd'
In reply to Philippe Mathieu-DaudéAvocado allows us to select set of tests using tags. When wanting to run all tests using a NetBSD guest OS, it is convenient to have them tagged, add the 'os:netbsd' tag.
--- tests/acceptance/boot_linux_console.py | 1 + tests/acceptance/ppc_prep_40p.py | 2 ++ 2 files changed, 3 insertions(+)
tests/acceptance/boot_linux_console.py +1 -0
@@ -862,6 +862,7 @@ def test_arm_orangepi_uboot_netbsd9(self): :avocado: tags=arch:arm :avocado: tags=machine:orangepi-pc :avocado: tags=device:sd + :avocado: tags=os:netbsd """ # This test download a 304MB compressed image and expand it to 2GB deb_url = ('http://snapshot.debian.org/archive/debian/'
tests/acceptance/ppc_prep_40p.py +2 -0
@@ -27,6 +27,7 @@ def test_factory_firmware_and_netbsd(self): """ :avocado: tags=arch:ppc :avocado: tags=machine:40p + :avocado: tags=os:netbsd :avocado: tags=slowness:high """ bios_url = ('http://ftpmirror.your.org/pub/misc/'
@@ -64,6 +65,7 @@ def test_openbios_and_netbsd(self): """ :avocado: tags=arch:ppc :avocado: tags=machine:40p + :avocado: tags=os:netbsd """ drive_url = ('https://cdn.netbsd.org/pub/NetBSD/iso/7.1.2/' 'NetBSD-7.1.2-prep.iso')
Signature · 1 line
2.31.1
Re: [PATCH 3/9] tests/acceptance: Tag NetBSD tests as 'os:netbsd'
CC'ing NetBSD maintainers.
Quoted 44 lines · Philippe Mathieu-Daudé
Avocado allows us to select set of tests using tags. When wanting to run all tests using a NetBSD guest OS, it is convenient to have them tagged, add the 'os:netbsd' tag.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- tests/acceptance/boot_linux_console.py | 1 + tests/acceptance/ppc_prep_40p.py | 2 ++ 2 files changed, 3 insertions(+)tests/acceptance/boot_linux_console.py +1
-0@@ -862,6 +862,7 @@ def test_arm_orangepi_uboot_netbsd9(self): :avocado: tags=arch:arm :avocado: tags=machine:orangepi-pc :avocado: tags=device:sd + :avocado: tags=os:netbsd """ # This test download a 304MB compressed image and expand it to 2GB deb_url = ('http://snapshot.debian.org/archive/debian/'tests/acceptance/ppc_prep_40p.py +2
-0@@ -27,6 +27,7 @@ def test_factory_firmware_and_netbsd(self): """ :avocado: tags=arch:ppc :avocado: tags=machine:40p + :avocado: tags=os:netbsd :avocado: tags=slowness:high """ bios_url = ('http://ftpmirror.your.org/pub/misc/'@@ -64,6 +65,7 @@ def test_openbios_and_netbsd(self): """ :avocado: tags=arch:ppc :avocado: tags=machine:40p + :avocado: tags=os:netbsd """ drive_url = ('https://cdn.netbsd.org/pub/NetBSD/iso/7.1.2/' 'NetBSD-7.1.2-prep.iso')
Re: [PATCH 3/9] tests/acceptance: Tag NetBSD tests as 'os:netbsd'
Quoted 8 lines · Philippe Mathieu-Daudé
CC'ing NetBSD maintainers.
Quoted 4 lines · Philippe Mathieu-Daudé
Avocado allows us to select set of tests using tags. When wanting to run all tests using a NetBSD guest OS, it is convenient to have them tagged, add the 'os:netbsd' tag.
I'll amend an command line example to run the NetBSD tests:
$ avocado --show=app,console run -t os:netbsd tests/acceptance/
Quoted 40 lines
Quoted 39 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- tests/acceptance/boot_linux_console.py | 1 + tests/acceptance/ppc_prep_40p.py | 2 ++ 2 files changed, 3 insertions(+)tests/acceptance/boot_linux_console.py +1
-0@@ -862,6 +862,7 @@ def test_arm_orangepi_uboot_netbsd9(self): :avocado: tags=arch:arm :avocado: tags=machine:orangepi-pc :avocado: tags=device:sd + :avocado: tags=os:netbsd """ # This test download a 304MB compressed image and expand it to 2GB deb_url = ('http://snapshot.debian.org/archive/debian/'tests/acceptance/ppc_prep_40p.py +2
-0@@ -27,6 +27,7 @@ def test_factory_firmware_and_netbsd(self): """ :avocado: tags=arch:ppc :avocado: tags=machine:40p + :avocado: tags=os:netbsd :avocado: tags=slowness:high """ bios_url = ('http://ftpmirror.your.org/pub/misc/'@@ -64,6 +65,7 @@ def test_openbios_and_netbsd(self): """ :avocado: tags=arch:ppc :avocado: tags=machine:40p + :avocado: tags=os:netbsd """ drive_url = ('https://cdn.netbsd.org/pub/NetBSD/iso/7.1.2/' 'NetBSD-7.1.2-prep.iso')
Niek Linnenbank
Reviewed-byRe: [PATCH 3/9] tests/acceptance: Tag NetBSD tests as 'os:netbsd'
for test_arm_orangepi_uboot_netbsd9:
Op za 3 jul. 2021 10:44 schreef Philippe Mathieu-Daudé <[email protected]>:
Quoted 59 lines
Quoted 8 lines · Philippe Mathieu-Daudé
CC'ing NetBSD maintainers.
Quoted 4 lines · Philippe Mathieu-Daudé
Avocado allows us to select set of tests using tags. When wanting to run all tests using a NetBSD guest OS, it is convenient to have them tagged, add the 'os:netbsd' tag.
I'll amend an command line example to run the NetBSD tests:
$ avocado --show=app,console run -t os:netbsd tests/acceptance/Quoted 7 lines
Review
Quoted 7 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- tests/acceptance/boot_linux_console.py | 1 + tests/acceptance/ppc_prep_40p.py | 2 ++ 2 files changed, 3 insertions(+)(quoted diff) +0
-0
b/tests/acceptance/boot_linux_console.pyQuoted 10 lines
tests/acceptance/boot_linux_console.py def test_arm_orangepi_uboot_netbsd9(self): · line 867
Quoted 10 lines
index
cded547d1d4..20d57c1a8c6100644tests/acceptance/boot_linux_console.py +1
-0@@ -862,6 +862,7 @@ def test_arm_orangepi_uboot_netbsd9(self): :avocado: tags=arch:arm :avocado: tags=machine:orangepi-pc :avocado: tags=device:sd + :avocado: tags=os:netbsd """ # This test download a 304MB compressed image and expand itto 2GB
Quoted 2 lines
Review
Quoted 2 lines
tests/acceptance/boot_linux_console.py +0
-0deb_url = ('http://snapshot.debian.org/archive/debian/'(quoted diff) +0
-0
b/tests/acceptance/ppc_prep_40p.pyQuoted 21 lines
Quoted 20 lines
index
96ba13b8943..2993ee3b078100644tests/acceptance/ppc_prep_40p.py +2
-0@@ -27,6 +27,7 @@ def test_factory_firmware_and_netbsd(self): """ :avocado: tags=arch:ppc :avocado: tags=machine:40p + :avocado: tags=os:netbsd :avocado: tags=slowness:high """ bios_url = ('http://ftpmirror.your.org/pub/misc/'@@ -64,6 +65,7 @@ def test_openbios_and_netbsd(self): """ :avocado: tags=arch:ppc :avocado: tags=machine:40p + :avocado: tags=os:netbsd """ drive_url = ('https://cdn.netbsd.org/pub/NetBSD/iso/7.1.2/' 'NetBSD-7.1.2-prep.iso')
Re: [PATCH 3/9] tests/acceptance: Tag NetBSD tests as 'os:netbsd'
Hi Niek,
Quoted 4 lines · Niek Linnenbank
for test_arm_orangepi_uboot_netbsd9:
Reviewed-by Niek Linnenbank <[email protected]<mailto:[email protected]>>
Thanks for the review. Does your R-b tag applies for this single patch or all patches related to test_arm_orangepi_uboot_netbsd9 in this series (3-5)?
Re: [PATCH 3/9] tests/acceptance: Tag NetBSD tests as 'os:netbsd'
Quoted 11 lines · Philippe Mathieu-Daudé
Hi Niek,
Quoted 4 lines · Niek Linnenbank
for test_arm_orangepi_uboot_netbsd9:
Reviewed-by Niek Linnenbank <[email protected]<mailto:[email protected]>>
Thanks for the review. Does your R-b tag applies for this single patch or all patches related to
test_arm_orangepi_uboot_netbsd9in this series (3-5)?
Soft-freeze is in 2 days and no review from the NetBSD team, so postponing these patches to v6.2.
Re: [PATCH 3/9] tests/acceptance: Tag NetBSD tests as 'os:netbsd'
In reply to Philippe Mathieu-DaudéQuoted 6 lines · Philippe Mathieu-Daudé
Avocado allows us to select set of tests using tags. When wanting to run all tests using a NetBSD guest OS, it is convenient to have them tagged, add the 'os:netbsd' tag.
Quoted 6 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- tests/acceptance/boot_linux_console.py | 1 + tests/acceptance/ppc_prep_40p.py | 2 ++ 2 files changed, 3 insertions(+)
Re: [PATCH 3/9] tests/acceptance: Tag NetBSD tests as 'os:netbsd'
In reply to Philippe Mathieu-DaudéQuoted 10 lines · Philippe Mathieu-Daudé
Avocado allows us to select set of tests using tags. When wanting to run all tests using a NetBSD guest OS, it is convenient to have them tagged, add the 'os:netbsd' tag.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- tests/acceptance/boot_linux_console.py | 1 + tests/acceptance/ppc_prep_40p.py | 2 ++ 2 files changed, 3 insertions(+)
Phil,
I can ammend the commit message and queue this one if you think it's a good idea.
Cheers,
- Cleber.
PATCH 4/9 tests/acceptance: Extract image_expand() helper
In reply to Philippe Mathieu-DaudéTo be able to expand an image to a non-power-of-2 value, extract image_expand() from image_pow2ceil_expand().
--- tests/acceptance/boot_linux_console.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
tests/acceptance/boot_linux_console.py +9 -5
@@ -35,15 +35,19 @@ def pow2ceil(x): return 1 if x == 0 else 2**(x - 1).bit_length() +""" +Expand file size +""" +def image_expand(path, size): + if size != os.path.getsize(path): + with open(path, 'ab+') as fd: + fd.truncate(size) + """ Expand file size to next power of 2 """ def image_pow2ceil_expand(path): - size = os.path.getsize(path) - size_aligned = pow2ceil(size) - if size != size_aligned: - with open(path, 'ab+') as fd: - fd.truncate(size_aligned) + image_expand(path, pow2ceil(os.path.getsize(path))) class LinuxKernelTest(Test): KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
Signature · 1 line
2.31.1
Re: [PATCH 4/9] tests/acceptance: Extract image_expand() helper
Quoted 9 lines · Philippe Mathieu-Daudé
To be able to expand an image to a non-power-of-2 value, extract
image_expand()fromimage_pow2ceil_expand().Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- tests/acceptance/boot_linux_console.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
Re: [PATCH 4/9] tests/acceptance: Extract image_expand() helper
In reply to Philippe Mathieu-DaudéQuoted 14 lines · Philippe Mathieu-Daudé
To be able to expand an image to a non-power-of-2 value, extract
image_expand()fromimage_pow2ceil_expand().Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- tests/acceptance/boot_linux_console.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)tests/acceptance/boot_linux_console.py +0
-0@@ -35,15 +35,19 @@ def pow2ceil(x):
tests/acceptance/boot_linux_console.py line 45
Quoted 10 lines
tests/acceptance/boot_linux_console.py +8
-0return 1 if x == 0 else 2**(x - 1).bit_length() +""" +Expand file size +""" +def image_expand(path, size): + if size != os.path.getsize(path): + with open(path, 'ab+') as fd: + fd.truncate(size) +
This would be a good time to make the comment section, into a proper docstring, that is:
def image_expand(path, size):
"""Expand file size"""
if size != os.path.getsize(path):
with open(path, 'ab+') as fd:
fd.truncate(size)
- Cleber.
PATCH 5/9 tests/acceptance: Use image_expand() in test_arm_orangepi_uboot_netbsd9
In reply to Philippe Mathieu-DaudéThe NetBSD OrangePi image must be at least 2GiB, not less. Expand the SD card image to this size before using it.
--- tests/acceptance/boot_linux_console.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
tests/acceptance/boot_linux_console.py +7 -2
@@ -868,7 +868,12 @@ def test_arm_orangepi_uboot_netbsd9(self): :avocado: tags=device:sd :avocado: tags=os:netbsd """ - # This test download a 304MB compressed image and expand it to 2GB + # This test download a 304MB compressed image and expand it to 2GB, + # which is the minimum card size required by the NetBSD installer: + # https://wiki.netbsd.org/ports/evbarm/raspberry_pi/#index7h2 + # "A 2 GB card is the smallest workable size that the installation + # image will fit on." + NETBSD_SDCARD_MINSIZE = 2 * 1024 * 1024 * 1024 deb_url = ('http://snapshot.debian.org/archive/debian/' '20200108T145233Z/pool/main/u/u-boot/' 'u-boot-sunxi_2020.01%2Bdfsg-1_armhf.deb')
@@ -886,7 +891,7 @@ def test_arm_orangepi_uboot_netbsd9(self): image_path_gz = self.fetch_asset(image_url, asset_hash=image_hash) image_path = os.path.join(self.workdir, 'armv7.img') archive.gzip_uncompress(image_path_gz, image_path) - image_pow2ceil_expand(image_path) + image_expand(image_path, NETBSD_SDCARD_MINSIZE) image_drive_args = 'if=sd,format=raw,snapshot=on,file=' + image_path # dd if=u-boot-sunxi-with-spl.bin of=armv7.img bs=1K seek=8 conv=notrunc
Signature · 1 line
2.31.1
Re: [PATCH 5/9] tests/acceptance: Use image_expand() in test_arm_orangepi_uboot_netbsd9
Quoted 9 lines · Philippe Mathieu-Daudé
The NetBSD OrangePi image must be at least 2GiB, not less. Expand the SD card image to this size before using it.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- tests/acceptance/boot_linux_console.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
Re: [PATCH 5/9] tests/acceptance: Use image_expand() in test_arm_orangepi_uboot_netbsd9
In reply to Philippe Mathieu-DaudéHi Niek,
Quoted 13 lines · Philippe Mathieu-Daudé
The NetBSD OrangePi image must be at least 2GiB, not less. Expand the SD card image to this size before using it.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- tests/acceptance/boot_linux_console.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)tests/acceptance/boot_linux_console.py +0
-0
tests/acceptance/boot_linux_console.py def test_arm_orangepi_uboot_netbsd9(self): · line 875
Quoted 9 lines
tests/acceptance/boot_linux_console.py +5
-1@@ -868,7 +868,12 @@ def test_arm_orangepi_uboot_netbsd9(self): :avocado: tags=device:sd :avocado: tags=os:netbsd """ - # This test download a 304MB compressed image and expand it to 2GB + # This test download a 304MB compressed image and expand it to 2GB, + # which is the minimum card size required by the NetBSD installer: + # https://wiki.netbsd.org/ports/evbarm/raspberry_pi/#index7h2 + # "A 2 GB card is the smallest workable size that the installation + # image will fit on."
Do you agree with this comment and the one in the next patch?
Quoted 14 lines
tests/acceptance/boot_linux_console.py +2
-1+ NETBSD_SDCARD_MINSIZE = 2 * 1024 * 1024 * 1024 deb_url = ('http://snapshot.debian.org/archive/debian/' '20200108T145233Z/pool/main/u/u-boot/' 'u-boot-sunxi_2020.01%2Bdfsg-1_armhf.deb')@@ -886,7 +891,7 @@ def test_arm_orangepi_uboot_netbsd9(self): image_path_gz = self.fetch_asset(image_url, asset_hash=image_hash) image_path = os.path.join(self.workdir, 'armv7.img') archive.gzip_uncompress(image_path_gz, image_path) - image_pow2ceil_expand(image_path) + image_expand(image_path, NETBSD_SDCARD_MINSIZE) image_drive_args = 'if=sd,format=raw,snapshot=on,file=' + image_path # dd if=u-boot-sunxi-with-spl.bin of=armv7.img bs=1K seek=8 conv=notrunc
Niek Linnenbank
Reviewed-byRe: [PATCH 5/9] tests/acceptance: Use image_expand() in test_arm_orangepi_uboot_netbsd9
Hi Philippe,
Op wo 4 aug. 2021 22:55 schreef Philippe Mathieu-Daudé <[email protected]>:
Quoted 24 lines
Hi Niek,
Review
Quoted 9 lines · Philippe Mathieu-Daudé
The NetBSD OrangePi image must be at least 2GiB, not less. Expand the SD card image to this size before using it.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- tests/acceptance/boot_linux_console.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)(quoted diff) +0
-0
b/tests/acceptance/boot_linux_console.pytests/acceptance/boot_linux_console.py def test_arm_orangepi_uboot_netbsd9(self): · line 871
Quoted 8 lines
index
61069f0064f..b10f7257503100644tests/acceptance/boot_linux_console.py +0
-1@@ -868,7 +868,12 @@ def test_arm_orangepi_uboot_netbsd9(self): :avocado: tags=device:sd :avocado: tags=os:netbsd """ - # This test download a 304MB compressed image and expand it to2GB
tests/acceptance/boot_linux_console.py def test_arm_orangepi_uboot_netbsd9(self): · line 871
Quoted 1 line
tests/acceptance/boot_linux_console.py +1
-0+ # This test download a 304MB compressed image and expand it to2GB,
Quoted 9 lines
tests/acceptance/boot_linux_console.py def test_arm_orangepi_uboot_netbsd9(self): · line 872
Quoted 1 line
tests/acceptance/boot_linux_console.py +1
-0+ # which is the minimum card size required by the NetBSDinstaller:
tests/acceptance/boot_linux_console.py def test_arm_orangepi_uboot_netbsd9(self): · line 874
Quoted 2 lines
tests/acceptance/boot_linux_console.py +2
-0+ # https://wiki.netbsd.org/ports/evbarm/raspberry_pi/#index7h2 + # "A 2 GB card is the smallest workable size that theinstallation
tests/acceptance/boot_linux_console.py def test_arm_orangepi_uboot_netbsd9(self): · line 875
Quoted 1 line
tests/acceptance/boot_linux_console.py +1
-0+ # image will fit on."Do you agree with this comment and the one in the next patch?
Yes, this change looks fine for me.
Quoted 19 lines
tests/acceptance/boot_linux_console.py def test_arm_orangepi_uboot_netbsd9(self): · line 891
Quoted 6 lines
tests/acceptance/boot_linux_console.py +1
-0+ NETBSD_SDCARD_MINSIZE = 2 * 1024 * 1024 * 1024 deb_url = ('http://snapshot.debian.org/archive/debian/' '20200108T145233Z/pool/main/u/u-boot/' 'u-boot-sunxi_2020.01%2Bdfsg-1_armhf.deb')@@ -886,7 +891,7 @@ def test_arm_orangepi_uboot_netbsd9(self): image_path_gz = self.fetch_asset(image_url,asset_hash=image_hash)
tests/acceptance/boot_linux_console.py def test_arm_orangepi_uboot_netbsd9(self):
Quoted 5 lines
tests/acceptance/boot_linux_console.py +1
-1image_path = os.path.join(self.workdir, 'armv7.img') archive.gzip_uncompress(image_path_gz, image_path) - image_pow2ceil_expand(image_path) + image_expand(image_path, NETBSD_SDCARD_MINSIZE) image_drive_args = 'if=sd,format=raw,snapshot=on,file=' +
image_pathtests/acceptance/boot_linux_console.py def test_arm_orangepi_uboot_netbsd9(self): · line 896
Quoted 2 lines
tests/acceptance/boot_linux_console.py +0
-0# dd if=u-boot-sunxi-with-spl.bin of=armv7.img bs=1K seek=8conv=notrunc
Quoted 1 line
RFC PATCH 6/9 tests/acceptance: Use image_expand() in test_arm_orangepi_bionic_20_08
In reply to Philippe Mathieu-DaudéU-Boot expects the SD card size to be at least 2GiB, so expand the SD card image to this size before using it.
---
TODO: U-Boot reference?
--- tests/acceptance/boot_linux_console.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
tests/acceptance/boot_linux_console.py +6 -4
@@ -820,11 +820,13 @@ def test_arm_orangepi_bionic_20_08(self): :avocado: tags=arch:arm :avocado: tags=machine:orangepi-pc :avocado: tags=device:sd + :avocado: tags=u-boot """ - # This test download a 275 MiB compressed image and expand it - # to 1036 MiB, but the underlying filesystem is 1552 MiB... - # As we expand it to 2 GiB we are safe. + # This test download a 275 MiB compressed image and inflate it + # to 1036 MiB, but 1/ the underlying filesystem is 1552 MiB, + # 2/ U-Boot loads TFTP filenames from the last sector below + # 2 GiB, so we need to expand the image further more to 2 GiB. image_url = ('https://archive.armbian.com/orangepipc/archive/' 'Armbian_20.08.1_Orangepipc_bionic_current_5.8.5.img.xz')
@@ -833,7 +835,7 @@ def test_arm_orangepi_bionic_20_08(self): image_path_xz = self.fetch_asset(image_url, asset_hash=image_hash, algorithm='sha256') image_path = archive.extract(image_path_xz, self.workdir) - image_pow2ceil_expand(image_path) + image_expand(image_path, 2 * 1024 * 1024 * 1024) self.vm.set_console() self.vm.add_args('-drive', 'file=' + image_path + ',if=sd,format=raw',
Signature · 1 line
2.31.1
Re: [RFC PATCH 6/9] tests/acceptance: Use image_expand() in test_arm_orangepi_bionic_20_08
Quoted 11 lines · Philippe Mathieu-Daudé
U-Boot expects the SD card size to be at least 2GiB, so expand the SD card image to this size before using it.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
TODO: U-Boot reference?--- tests/acceptance/boot_linux_console.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
Re: [RFC PATCH 6/9] tests/acceptance: Use image_expand() in test_arm_orangepi_bionic_20_08
In reply to Philippe Mathieu-DaudéHi Philippe,
Op wo 23 jun. 2021 20:00 schreef Philippe Mathieu-Daudé <[email protected]>:
Quoted 17 lines
U-Boot expects the SD card size to be at least 2GiB, so expand the SD card image to this size before using it.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
TODO: U-Boot reference?--- tests/acceptance/boot_linux_console.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)tests/acceptance/boot_linux_console.py +0
-0@@ -820,11 +820,13 @@ def test_arm_orangepi_bionic_20_08(self): :avocado: tags=arch:arm
tests/acceptance/boot_linux_console.py def test_arm_orangepi_bionic_20_08(self): · line 827
Quoted 10 lines
tests/acceptance/boot_linux_console.py +2
-3:avocado: tags=machine:orangepi-pc :avocado: tags=device:sd + :avocado: tags=u-boot """ - # This test download a 275 MiB compressed image and expand it - # to 1036 MiB, but the underlying filesystem is 1552 MiB... - # As we expand it to 2 GiB we are safe. + # This test download a 275 MiB compressed image and inflate it
Only a few typos here:
download -> downloads
inflate -> inflates
Otherwise, looks fine:
+ # to 1036 MiB, but 1/ the underlying filesystem is 1552 MiB,
Quoted 20 lines
tests/acceptance/boot_linux_console.py +2
-0+ # 2/ U-Boot loads TFTP filenames from the last sector below + # 2 GiB, so we need to expand the image further more to 2 GiB. image_url = ('https://archive.armbian.com/orangepipc/archive/''Armbian_20.08.1_Orangepipc_bionic_current_5.8.5.img.xz')
tests/acceptance/boot_linux_console.py +1
-1@@ -833,7 +835,7 @@ def test_arm_orangepi_bionic_20_08(self): image_path_xz = self.fetch_asset(image_url, asset_hash=image_hash, algorithm='sha256') image_path = archive.extract(image_path_xz, self.workdir) - image_pow2ceil_expand(image_path) + image_expand(image_path, 2 * 1024 * 1024 * 1024) self.vm.set_console() self.vm.add_args('-drive', 'file=' + image_path +',if=sd,format=raw',
--
2.31.1
RFC PATCH 7/9 tests/acceptance: Do not expand SD card image in test_arm_orangepi_sd
In reply to Philippe Mathieu-DaudéXXX it seems to work...
--- tests/acceptance/boot_linux_console.py | 1 - 1 file changed, 1 deletion(-)
tests/acceptance/boot_linux_console.py +0 -1
@@ -783,7 +783,6 @@ def test_arm_orangepi_sd(self): rootfs_path_xz = self.fetch_asset(rootfs_url, asset_hash=rootfs_hash) rootfs_path = os.path.join(self.workdir, 'rootfs.cpio') archive.lzma_uncompress(rootfs_path_xz, rootfs_path) - image_pow2ceil_expand(rootfs_path) self.vm.set_console() kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
Signature · 1 line
2.31.1
PATCH 8/9 tests/acceptance: Remove now unused pow2ceil()
In reply to Philippe Mathieu-DaudéWe don't use pow2ceil() anymore, remove it.
--- tests/acceptance/boot_linux_console.py | 12 ------------ 1 file changed, 12 deletions(-)
tests/acceptance/boot_linux_console.py +0 -12
@@ -29,12 +29,6 @@ except CmdNotFoundError: P7ZIP_AVAILABLE = False -""" -Round up to next power of 2 -""" -def pow2ceil(x): - return 1 if x == 0 else 2**(x - 1).bit_length() - """ Expand file size """
@@ -43,12 +37,6 @@ def image_expand(path, size): with open(path, 'ab+') as fd: fd.truncate(size) -""" -Expand file size to next power of 2 -""" -def image_pow2ceil_expand(path): - image_expand(path, pow2ceil(os.path.getsize(path))) - class LinuxKernelTest(Test): KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
Signature · 1 line
2.31.1
Re: [PATCH 8/9] tests/acceptance: Remove now unused pow2ceil()
Quoted 8 lines · Philippe Mathieu-Daudé
We don't use
pow2ceil()anymore, remove it.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- tests/acceptance/boot_linux_console.py | 12 ------------ 1 file changed, 12 deletions(-)
RFC PATCH 9/9 hw/sd: Allow card size not power of 2 again
In reply to Philippe Mathieu-DaudéIn commit a9bcedd15a5 ("hw/sd/sdcard: Do not allow invalid SD card sizes") we tried to protect us from CVE-2020-13253 by only allowing card with power-of-2 sizes. However doing so we disrupted valid user cases. As a compromise, allow any card size, but warn only power of 2 sizes are supported, still suggesting the user how to increase a card with 'qemu-img resize'.
--- hw/sd/sd.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-)
hw/sd/sd.c +9 -16
@@ -2131,23 +2131,16 @@ static void sd_realize(DeviceState *dev, Error **errp) blk_size =blk_getlength (sd->blk);if (blk_size >0 && !is_power_of_2 (blk_size)) {int64_t blk_size_aligned =pow2ceil (blk_size); -char *blk_size_str; + g_autofree char *blk_size_s = size_to_str(blk_size); + g_autofree char *blk_size_aligned_s = size_to_str(blk_size_aligned); - blk_size_str =size_to_str (blk_size); -error_setg (errp,"Invalid SD card size: %s" , blk_size_str); -g_free (blk_size_str); - - blk_size_str =size_to_str (blk_size_aligned); -error_append_hint (errp, -"SD card size has to be a power of 2, e.g. %s.\n" -"You can resize disk images with" -" 'qemu-img resize <imagefile> <new-size>'\n" -"(note that this will lose data if you make the" -" image smaller than it currently is).\n" , - blk_size_str); -g_free (blk_size_str); - -return ; +warn_report ("SD card size is not a power of 2 (%s). It might work" +" but is not supported by QEMU. If possible, resize" +" your disk image to %s with:" , + blk_size_s, blk_size_aligned_s); +warn_report (" 'qemu-img resize <imagefile> <new-size>'" ); +warn_report ("(note that this will lose data if you make the" +" image smaller than it currently is)." ); } ret = blk_set_perm(sd->blk, BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE,
Signature · 1 line
2.31.1
Quoted 39 lines · Philippe Mathieu-Daudé
In commit
a9bcedd15a5("hw/sd/sdcard: Do not allow invalid SD card sizes") we tried to protect us from CVE-2020-13253 by only allowing card with power-of-2 sizes. However doing so we disrupted valid user cases. As a compromise, allow any card size, but warn only power of 2 sizes are supported, still suggesting the user how to increase a card with 'qemu-img resize'.Cc Tom Yan <[email protected]>Cc Warner Losh <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/sd/sd.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-)hw/sd/sd.c +2
-13@@ -2131,23 +2131,16 @@ static void sd_realize(DeviceState *dev, Error **errp) blk_size =blk_getlength (sd->blk);if (blk_size >0 && !is_power_of_2 (blk_size)) {int64_t blk_size_aligned =pow2ceil (blk_size); -char *blk_size_str; + g_autofree char *blk_size_s = size_to_str(blk_size); + g_autofree char *blk_size_aligned_s = size_to_str(blk_size_aligned); - blk_size_str =size_to_str (blk_size); -error_setg (errp,"Invalid SD card size: %s" , blk_size_str); -g_free (blk_size_str); - - blk_size_str =size_to_str (blk_size_aligned); -error_append_hint (errp, -"SD card size has to be a power of 2, e.g. %s.\n" -"You can resize disk images with" -" 'qemu-img resize <imagefile> <new-size>'\n" -"(note that this will lose data if you make the" -" image smaller than it currently is).\n" , - blk_size_str);
hw/sd/sd.c static void sd_realize(DeviceState *dev, Error **errp) · line 2143
Quoted 10 lines
hw/sd/sd.c +7
-3-g_free (blk_size_str); - -return ; +warn_report ("SD card size is not a power of 2 (%s). It might work" +" but is not supported by QEMU. If possible, resize" +" your disk image to %s with:" , + blk_size_s, blk_size_aligned_s); +warn_report (" 'qemu-img resize <imagefile> <new-size>'" ); +warn_report ("(note that this will lose data if you make the" +" image smaller than it currently is)." );
In what scenarios will non-power of 2 not work and what is the effect ? Is it a QEMU bug or not ?
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Hi,
Quoted 40 lines · Philippe Mathieu-Daudé
In commit
a9bcedd15a5("hw/sd/sdcard: Do not allow invalid SD card sizes") we tried to protect us from CVE-2020-13253 by only allowing card with power-of-2 sizes. However doing so we disrupted valid user cases. As a compromise, allow any card size, but warn only power of 2 sizes are supported, still suggesting the user how to increase a card with 'qemu-img resize'.Cc Tom Yan <[email protected]>Cc Warner Losh <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/sd/sd.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-)hw/sd/sd.c +2
-13@@ -2131,23 +2131,16 @@ static void sd_realize(DeviceState *dev, Error **errp) blk_size =blk_getlength (sd->blk);if (blk_size >0 && !is_power_of_2 (blk_size)) {int64_t blk_size_aligned =pow2ceil (blk_size); -char *blk_size_str; + g_autofree char *blk_size_s = size_to_str(blk_size); + g_autofree char *blk_size_aligned_s = size_to_str(blk_size_aligned); - blk_size_str =size_to_str (blk_size); -error_setg (errp,"Invalid SD card size: %s" , blk_size_str); -g_free (blk_size_str); - - blk_size_str =size_to_str (blk_size_aligned); -error_append_hint (errp, -"SD card size has to be a power of 2, e.g. %s.\n" -"You can resize disk images with" -" 'qemu-img resize <imagefile> <new-size>'\n" -"(note that this will lose data if you make the" -" image smaller than it currently is).\n" , - blk_size_str);
hw/sd/sd.c static void sd_realize(DeviceState *dev, Error **errp) · line 2143
Quoted 10 lines
hw/sd/sd.c +7
-3-g_free (blk_size_str); - -return ; +warn_report ("SD card size is not a power of 2 (%s). It might work" +" but is not supported by QEMU. If possible, resize" +" your disk image to %s with:" , + blk_size_s, blk_size_aligned_s); +warn_report (" 'qemu-img resize <imagefile> <new-size>'" ); +warn_report ("(note that this will lose data if you make the" +" image smaller than it currently is)." );
Not trying to be picky, but I don't think this is much better. IMHO it's quite irresponsible to give a warning like that, leaving users in a state like "Should I use it or not then?", without giving a concrete reference to what exactly might/would lead to the warned problem.
I really think we should get (/ have gotten) things clear first. What exactly is the bug we have been talking about here? I mean like, where does it occur and what's the nature of it.
1. Is it specific to a certain type / model of backend / physical storage device that will be made use of by qemu for the emulated storage? (I presume not since you mention about image, unless you irrationally related/bound the emulated storage type and the physical storage type together.)
2. Does it have anything to do with a certain flaw in qemu itself? Like the code that does read/write operation is flawed that it cannot be handled by a certain *proper* backend device?
3. Or is it actually a bug in a certain driver / firmware blob that will be used by an *emulated* device in the guest? In that case, can we emulate another model so that it won't be using the problematic driver / firmware?
Also, could you provide any information / reference to what the bug really is? Like a bug report (for the problem itself, not some vague claim that qemu should workaround the problem)?
Quoted 6 lines
hw/sd/sd.c +0
-1} ret = blk_set_perm(sd->blk, BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE, --2.31.1
Quoted 10 lines · Tom Yan
I really think we should get (/ have gotten) things clear first. What exactly is the bug we have been talking about here? I mean like, where does it occur and what's the nature of it.
1. Is it specific to a certain type / model of backend / physical storage device that will be made use of by qemu for the emulated storage? (I presume not since you mention about image, unless you irrationally related/bound the emulated storage type and the physical storage type together.)
Quoted 8 lines
2. Does it have anything to do with a certain flaw in qemu itself? Like the code that does read/write operation is flawed that it cannot be handled by a certain *proper* backend device?
3. Or is it actually a bug in a certain driver / firmware blob that will be used by an *emulated* device in the guest? In that case, can we emulate another model so that it won't be using the problematic driver / firmware?
Definitely agreed -- before we start changing QEMU code we need to identify clearly (a) what the real hardware does and (b) what the situation was we were originally trying to fix.
thanks
-- PMM
Quoted 19 lines · Peter Maydell
Quoted 14 lines · Tom Yan
I really think we should get (/ have gotten) things clear first. What exactly is the bug we have been talking about here? I mean like, where does it occur and what's the nature of it.
1. Is it specific to a certain type / model of backend / physical storage device that will be made use of by qemu for the emulated storage? (I presume not since you mention about image, unless you irrationally related/bound the emulated storage type and the physical storage type together.)
2. Does it have anything to do with a certain flaw in qemu itself? Like the code that does read/write operation is flawed that it cannot be handled by a certain *proper* backend device?
Quoted 8 lines
Quoted 4 lines
3. Or is it actually a bug in a certain driver / firmware blob that will be used by an *emulated* device in the guest? In that case, can we emulate another model so that it won't be using the problematic driver / firmware?
Definitely agreed -- before we start changing QEMU code we need to identify clearly (a) what the real hardware does and (b) what the situation was we were originally trying to fix.
Real SD and MMC cards do not have power-of-two constraints in the number of blocks. None of the SD/MMC bridges I’ve ever dealt with have a power-of-two constraint on the size of the card. The only constraint on the size related to the card is the block size.
If non-power-of-2 sized cards fail, that’s a cat-1 sev-1 bug that needs to be fixed, rather than a warning be generated.
Warner
Quoted 6 lines · Philippe Mathieu-Daudé
Hi Ubi-Wan Kenubi and Tom,
In commit a9bcedd (SD card size has to be power of 2) we decided to restrict SD card size to avoid security problems (CVE-2020-13253) but this became not practical to some users.
Quoted 8 lines
This RFC series tries to remove the limitation, keeping our functional tests working. It is unfinished work because I had to attend other topics, but sending it early as RFC to get feedback. I'll keep working when I get more time, except if one if you can help me.
Alexander, could you generate a qtest reproducer with the fuzzer corpus? See: https://bugs.launchpad.net/qemu/+bug/1878054
I think that bug was already fixed - the reproducer no logner causes a timeout on 6.0. Did I misunderstand something?
I applied this series and ran the OSS-Fuzz corpus for the sdhci-v3 config. The only problem it found is this assert() (that exists without the patch anyways):
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=29225
Let me know if this is something you think I should report on gitlab..
I'll leave the fuzzer running for another 24h or so, but otherwise I'm happy to leave a Tested-by, once there is a V1 series
-Alex
Quoted 24 lines
Thanks,
Phil.
Philippe Mathieu-Daudé (9):
hw/sd: When card is in wrong state, log which state it is hw/sd: Extractaddress_in_range()helper, log invalid accesses tests/acceptance: Tag NetBSD tests as 'os:netbsd' tests/acceptance: Extractimage_expand()helper tests/acceptance: Useimage_expand()in
test_arm_orangepi_uboot_netbsd9
tests/acceptance: Useimage_expand()intest_arm_orangepi_bionic_20_08tests/acceptance: Do not expand SD card image intest_arm_orangepi_sdtests/acceptance: Remove now unusedpow2ceil()
hw/sd: Allow card size not power of 2 againhw/sd/sd.c | 60 +++++++++++++------------- tests/acceptance/boot_linux_console.py | 39 ++++++++--------- tests/acceptance/ppc_prep_40p.py | 2 + 3 files changed, 52 insertions(+), 49 deletions(-)Signature · 1 line
2.31.1
Quoted 13 lines · Alexander Bulekov
Quoted 12 lines · Philippe Mathieu-Daudé
Hi Ubi-Wan Kenubi and Tom,
In commit a9bcedd (SD card size has to be power of 2) we decided to restrict SD card size to avoid security problems (CVE-2020-13253) but this became not practical to some users.
This RFC series tries to remove the limitation, keeping our functional tests working. It is unfinished work because I had to attend other topics, but sending it early as RFC to get feedback. I'll keep working when I get more time, except if one if you can help me.
Quoted 5 lines
Quoted 2 lines
Alexander, could you generate a qtest reproducer with the fuzzer corpus? See: https://bugs.launchpad.net/qemu/+bug/1878054
I think that bug was already fixed - the reproducer no logner causes a timeout on 6.0. Did I misunderstand something?
That bug was fixed but now I'm changing the code and would like to feel sure I'm not re-introducing the problem, so having the reproducer in the tree would help.
Quoted 4 lines
I applied this series and ran the OSS-Fuzz corpus for the sdhci-v3 config. The only problem it found is this
assert()(that exists without the patch anyways):
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=29225
Sigh.
Quoted 1 line
Let me know if this is something you think I should report on gitlab..
Yes please :(
Quoted 3 lines
I'll leave the fuzzer running for another 24h or so, but otherwise I'm happy to leave a Tested-by, once there is a V1 series
-Alex
Thanks!
Phil.
Quoted 17 lines · Philippe Mathieu-Daudé
Quoted 16 lines · Alexander Bulekov
Quoted 14 lines · Philippe Mathieu-Daudé
Hi Ubi-Wan Kenubi and Tom,
In commit a9bcedd (SD card size has to be power of 2) we decided to restrict SD card size to avoid security problems (CVE-2020-13253) but this became not practical to some users.
This RFC series tries to remove the limitation, keeping our functional tests working. It is unfinished work because I had to attend other topics, but sending it early as RFC to get feedback. I'll keep working when I get more time, except if one if you can help me.
Alexander, could you generate a qtest reproducer with the fuzzer corpus? See: https://bugs.launchpad.net/qemu/+bug/1878054
Quoted 6 lines
Quoted 2 lines
I think that bug was already fixed - the reproducer no logner causes a timeout on 6.0. Did I misunderstand something?
That bug was fixed but now I'm changing the code and would like to feel sure I'm not re-introducing the problem, so having the reproducer in the tree would help.
Ok - I'll try to come up with one. Minimizing reproducers for timeouts is trickier than crashes :-)
Quoted 11 lines
Quoted 5 lines
I applied this series and ran the OSS-Fuzz corpus for the sdhci-v3 config. The only problem it found is this
assert()(that exists without the patch anyways):
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=29225Sigh.
Quoted 1 line
Let me know if this is something you think I should report on gitlab..
Yes please :(
Ok here it is: https://gitlab.com/qemu-project/qemu/-/issues/450
The fuzzer I left running for 24h also found another bug (looks like DMA reentrancy), which I thought was introduced by this patchset, since OSS-Fuzz had not reported it in months of fuzzing. However, as a sanity-check I tried it against qemu.git and it crashed - strange... Anyways here it is: https://gitlab.com/qemu-project/qemu/-/issues/451
-Alex
Quoted 8 lines
Quoted 4 lines
I'll leave the fuzzer running for another 24h or so, but otherwise I'm happy to leave a Tested-by, once there is a V1 series
-AlexThanks!
Phil.