[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: qemu-user viability (was Re: [SECURITY] [DSA 5983-1] qemu security update)



On 8/23/25 09:19, Thorsten Glaser wrote:
There are no alternatives - qemu is unique in this regard.  And
it has never been designed for this usage.  What we had for 15+
years, unnoticed, is like `chmod u+s /bin/sh`, which is never
supposed to be used like this.

Perhaps, but there’s shades in between.

I find qemu system emulation a LOT less problematic.

For sh4 I boot qemu-system-sh4 and then use a network block device to provide swap (so the 64mb limitation of the board isn't a limiting factor). The sh4 build in toybox's mkroot works fine for this (binaries at https://landley.net/bin/mkroot if you'd like to try). It also works with -hda but I think can only provide _one_ of those so you have to partition it, which I generally don't bother.

qemu-system-sh4: -hdb hdb.img: machine type does not support if=ide,bus=0,unit=1 qemu-system-sh4: -hdc hdc.img: machine type does not support if=ide,bus=1,unit=0 qemu-system-sh4: -hdd hdd.img: machine type does not support if=ide,bus=1,unit=1

(You'd think it could at least do -hdb since that's just master/slave on the same controller but the qemu guys never bothered to wire it up. Anyway, I stick a 4gb ext3 image in /dev/sda so I have lots of scratch space for builds because building on network filesystems tends to have strange permission hiccups for me, or rm -rf fails because nfs didn't _really_ delete a file that's still open but just renamed it, or...)

Anyway, this works fine on little endian, but the qemu-system-sh4eb build has something hinky in the ethernet, I haven't tackled it myself because I don't know whether the device emulation or the driver is what's missing an endian swap. (I don't want to fix it the "wrong way", and don't have big endian physical hardware lying around to try it on. I moved _again_ at the start of the month, just unpacked the storage space with those boxes into my sister's garage last weekend, but haven't sorted very far yet.)

In theory I could use a swap _file_ instead of swap partition, and thus a single /dev/hda would be plenty without partitioning it, but I haven't tried? (When the network doesn't work I can't upload the results of the build in an automated fashion anyway, so...)

You can speed this build process up further by hooking up distcc to call out to the cross compiler, which lets you keep about -j3 busy before the preprocessing, data transmission, and linking become the bottleneck. (I mean ./configure is _always_ the bottleneck but that's because autoconf is really stupid and largely pointless.) I had that distcc setup working (and even automated) back in https://landley.net/aboriginal/about.html and can help anyone interested fish the relevant bits out of those old build scripts.

If you rely on suid/sgid *foreign* binaries, that's where the
problem lies.

Yes. People expect to be able to run foreign-arch chroots.
Entire buildd setups partly rely on this, too…

A qemu-system vm doesn't require any weird translation. As far as the kernel running in the emulator is concerned, everything is entirely native. :)

Rob


Reply to: