[External Mail]Re: [RFC] um: reproducible randomness for time-travel tests

孟令澳 menglingao at xiaomi.com
Thu Nov 19 05:04:42 PST 2026


Hi Johannes,

Thanks for sharing what you had to change for the Wi-Fi tests.

In BSWorld, we run BlueZ in a 32-bit UML guest with time-travel=ext.
We preload a small shared library into the UML process to intercept
the host libc's getrandom(). The harness derives a seed from the guest
label. We also reuse the same kernel build and read-only rootfs,
disable CONFIG_UML_RANDOM, and keep the boot command line stable,
including the HCI serial file descriptor.

https://github.com/XiaoMi/bsworld
https://github.com/XiaoMi/bsworld/blob/d809b998fd42866bd94cddd05edcc0a0b99428a7/src/bsworld/uml/getrandom.c

We compared two runs in the same image and got byte-identical HCI and
over-the-air captures for the BlueZ cases. That's the scope of our
reproducibility check.

The awkward part is that we have to build a separate 32-bit shared
library and rely on UML calling the interposable libc symbol. The shim
fixes the bytes UML gets from the host through that call. The guest
RNG still mixes in other inputs, including the kernel build
information, command line, and interrupt timing you mentioned.

Would it make sense to start with the os_getrandom() seed from your
list, enabled only when a seed is explicitly supplied for a
time-travel boot? If your patch is available, I'd be happy to try it
against our BlueZ tests.

Thanks,
Lingao


> 2026年11月19日 20:47,Johannes Berg <johannes at sipsolutions.net> 写道:
>
> [外部邮件] 此邮件来源于小米公司外部,请谨慎处理。若对邮件安全性存疑,请将邮件转发给misec at xiaomi.com进行反馈
>
> Hi,
>
>> We use UML's time-travel mode for Bluetooth(BlueZ) integration tests. To make
>> runs reproducible, we currently use an LD_PRELOAD shim to control the
>> random data that the UML kernel obtains from the host.
>
> Interesting. We do that for WiFi and have a number of patches to make
> /dev/random reproducible :)
>
>> Would UML accept an opt-in way to supply reproducible random input for
>> time-travel tests? Normal boots would continue to use host randomness.
>> I'd appreciate feedback on the scope and interface before preparing a
>> patch.
>
> It's a good question - thing is that it's fairly involved, and somewhat
> difficult to maintain? In fact, I'm surprised you managed to make it
> work with LD_PRELOAD, given that we patch out:
>
> - interrupt random source (basically stub add_interrupt_randomness,
>   otherwise signal timing from the host can affect it)
>
> - utsname (in random_init_early) because the build time is there
>
> - os_getrandom() to take a seed from environment
>   (probably the least controversial patch here)
>
> - not directly affecting random, but reproducibility, we sort hostfs
>   directory entries so that their host order doesn't affect tests
>
> - similarly, dentry allocation in hostfs
>
> - similarly, patch hostfs to retry on EINTR (this is actually a bugfix
>   we should probably upstream?)
>
> - similarly, some hostfs patch for updating the host inode timestamps
>   when a file is closed (marked as needing extra work for non-TT) and
>   setting timestamps on file creation
>
> - some patches to force out CRYPTO_JITTERENTROPY which doesn't work,
>   but that may no longer be necessary and just historic
>
> I don't conceptually object to having these upstream, specially if
> there's another user (you) actually interested in reproducibility, but
> some of these might need work. Benjamin can maybe comment better on many
> of these.
>
> johannes

#/******本邮件及其附件含有小米公司的保密信息,仅限于发送给上面地址中列出的个人或群组。禁止任何其他人以任何形式使用(包括但不限于全部或部分地泄露、复制、或散发)本邮件中的信息。如果您错收了本邮件,请您立即电话或邮件通知发件人并删除本邮件! This e-mail and its attachments contain confidential information from XIAOMI, which is intended only for the person or entity whose address is listed above. Any use of the information contained herein in any way (including, but not limited to, total or partial disclosure, reproduction, or dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender by phone or email immediately and delete it!******/#


More information about the linux-um mailing list