dyne / tomb

the Crypto Undertaker
https://dyne.org/software/tomb
GNU General Public License v3.0
1.32k stars 150 forks source link

losetup: cannot find an unused loop device #436

Closed psamim closed 2 years ago

psamim commented 2 years ago

Hi!

I had tomb working but after an update I am getting the error:

losetup: cannot find an unused loop device: Permission denied
tomb [W] Loop mount of volumes is not possible on this machine, this error
tomb [W] often occurs on VPS and kernels that don't provide the loop module.
tomb [W] It is impossible to use Tomb on this machine under these conditions.
tomb [E] Operation aborted.

After downgrading it is working again. Using tomb-git from AUR on Archlinux.

Thanks

psamim commented 2 years ago

I am not sure if it helps, the old working version is tomb-git-2.9.r21.g9323c1c-1-any.pkg.tar.zst the new version is tomb-git-2.9.r25.g6955719-1-any.pkg.tar.zst.

Narrat commented 2 years ago

Thanks for the report and the hints when it worked an when it stopped. git bisect gives this result:

03c93ef976c6555dec2f0b07dc8c8e37d2c5f766 is the first bad commit
commit 03c93ef976c6555dec2f0b07dc8c8e37d2c5f766
Author: Jaromil <jaromil@dyne.org>
Date:   Sun Feb 20 21:57:05 2022 +0100

    Sudo loopback improve (#435)

Will take a look at 03c93ef976c6555dec2f0b07dc8c8e37d2c5f766

Narrat commented 2 years ago

As far as I could deduce, loseetup -f needs evelated privileges if it needs to create the next ununsed loop device. Example: If there is no /dev/loop0. losetup -f needs privileges to return the newly created dev/loop0. If it does exist and the device is unused, losetup -f doesn't need root rights to return the same. Is /dev/loop0 in use, losetup -f needs root rights again to return /dev/loop1. tl;dr: https://github.com/dyne/Tomb/blob/master/tomb#L633 needs _sudo, which got removed in the commit mentioned by git bisect

Narrat commented 1 year ago

By chance I found this documentation from the kernel regarding loop devices and the changed/different behaviour: BLK_DEV_LOOP_MIN

The historic default is 8. If a late 2011 version of losetup(8) is used, it can be set to 0, since needed loop devices can be dynamically allocated with the /dev/loop-control interface.

So it depends on the used kernel config if the check works without privilege escalation (or not)