[Toybox] [PATCH] losetup: fix the race.

Rob Landley rob at landley.net
Thu Aug 8 17:24:38 PDT 2019


On 8/8/19 4:07 PM, enh wrote:
>> The Android devices I've seen all use an ordinary tmpfs on /dev, not devtmpfs.
>>
>> (on a walleye device)
>> $ adb shell mount | grep ' /dev '
>> tmpfs on /dev type tmpfs (rw,seclabel,nosuid,relatime,size=1853688k,nr_inodes=463422,mode=755)
> 
> i think Rob thought that it would cure your race, but as he seems to
> have discovered later (and i remember Tom explaining to me when i
> asked him the same question months ago), it just moves the problem
> around rather than actually fixing it.

Actually fixing it would be having the startup code do:

  echo "major:minor=uid:gid,major:*=uid:gid..." > /sys/module/devtmpfs/owner_mapping

either before mounting devtmpfs or have devtmpfs automatically chown the ones
that aren't "dirty" yet when the mapping changes (since it already tracks that
state for udev), so the kernel would know who devices should belong to (and
could just give everything it hasn't got a mapping for to root), WITHOUT having
policy in kernel space.

Alas, Kay Sievers proposed something stupid instead and got the entire concept
shot down, and nobody ever followed up, and now "this flaw exists therefore we
must retain it" inertia has set in. :(

Anyway, yes race exists today and requires workaround. Got it. Still not caught
up on email from the disk crash though. :)

Rob



More information about the Toybox mailing list