On Fri, Nov 13, 2026 at 04:34:52PM -0600, Eric Blake wrote:
> Feifan Qian posted a sample script generated with the help of AI that
> created a known-broken NBD server that intentionally replies to a
> structured read with only a subset of bytes, to expose the leak of
> heap data from qemu as an NBD client into an emulated IDE drive. Take
> the idea of that test, but simplify it into a qemu-io test (much
> lighter-weight NBD client, and easier access to see what bytes the NBD
> client code is passing on) that more closely resembles paradigms in my
> recent nbd-robustness iotest.  Also, expand the test to cover multiple
> scenarios: in addition to the original test demonstrating a prefix of
> 20 bytes with unwritten tail, I expanded it to cover out-of-order
> replies, a hole-only reply, and a completely empty reply.
> 
> Reported-by: Feifan Qian <[email protected]>
> Based-on: https://gitlab.com/qemu-project/qemu/-/work_items/3815
> AI-used-for: tests
> Signed-off-by: Eric Blake <[email protected]>
> ---

> +
> +    def test_incomplete_and_out_of_order_reads(self):
> +        # Force heap perturbation so uninitialized bytes show up (if not
> +        # already set in caller, this favors values of 0x5A in unused heap)
> +        os.environ.setdefault("MALLOC_PERTURB_", "165")
> +        nbd_uri = f"nbd+unix:///?socket={self.sock_path}"
> +        out = iotests.qemu_io(

It turns out MALLOC_PERTURB_ does not help or hurt in this case;
that's because qemu-io's read command is hardcoded to (re-)wipe memory
buffers to 0xab before it calls blk_pread(). So setting
MALLOC_PERTURB_=165 with the hopes of seeing 0x5a on fresh buffers and
0xa5 after free didn't change anything (the wipe to 0xab happens
unconditionally in qemu-io), I'll drop it from this patch.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.
Virtualization:  qemu.org | libguestfs.org


Reply via email to