Package: schroot Version: 1.6.13-3+b2 Severity: important Tags: patch X-Debbugs-Cc: i...@ilbers.de, ub...@ilbers.de
Hello! In case of multiple schroot processes checking for lock directory presence at the same time more then one process can try to create this directory. It happens because checking itself is not atomic: (etc/setup.d/10mount, function do_umount_all) ``` if [ -e /var/lock/schroot ]; then if [ ! -d /var/lock/schroot ]; then error "/var/lock/schroot is not a directory" exit 1 fi else mkdir -m 0700 /var/lock/schroot fi ``` This will result in the following error: | E: 10mount: mkdir: cannot create directory '/var/lock/schroot': File exists To prevent second process fail on mkdir of already created lock directory (and also allow creation of subfolders if not exist) option -p can be added to mkdir command. Pull request with the patch was sent to upstream repo: https://codeberg.org/shelter/reschroot/pulls/12 -- System Information: Debian Release: 12.8 APT prefers stable APT policy: (500, 'stable') Architecture: amd64 (x86_64) Foreign Architectures: arm64 Kernel: Linux 6.11.5+bpo-amd64 (SMP w/32 CPU threads; PREEMPT) Locale: LANG=C.UTF-8, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE not set Shell: /bin/sh linked to /usr/bin/dash Init: unable to detect Versions of packages schroot depends on: ii debconf [debconf-2.0] 1.5.82 ii libboost-filesystem1.74.0 1.74.0+ds1-21 ii libboost-iostreams1.74.0 1.74.0+ds1-21 ii libboost-program-options1.74.0 1.74.0+ds1-21 ii libc6 2.36-9+deb12u9 ii libgcc-s1 12.2.0-14 ii libpam0g 1.5.2-6+deb12u1 ii libstdc++6 12.2.0-14 ii libuuid1 2.38.1-5+deb12u2 ii schroot-common 1.6.13-3 ii sysvinit-utils [lsb-base] 3.06-4 schroot recommends no packages. Versions of packages schroot suggests: pn aufs-tools | unionfs-fuse <none> pn btrfs-progs <none> ii bzip2 1.0.8-5+b1 ii debootstrap 1.0.128+nmu2+deb12u1 pn lvm2 <none> ii qemu-user-static 1:7.2+dfsg-7+deb12u7 ii xz-utils 5.4.1-0.2 pn zfsutils-linux <none> ii zstd 1.5.4+dfsg2-5 -- debconf information: schroot/bad-names:
>From 96e9404437efb826a0e81b36560b4430922616e6 Mon Sep 17 00:00:00 2001 From: Anton Mikanovich <ami...@ilbers.de> Date: Mon, 2 Dec 2024 08:10:00 +0100 Subject: [PATCH] 10mount: Protect from races on do_umount_all In case of multiple schroot processes checking for lock directory presence at the same time more then one process can try to create this directory. It happens because checking itself is not atomic. This will result in the following error: | E: 10mount: mkdir: cannot create directory '/var/lock/schroot': File exists To prevent second process fail on mkdir of already created lock directory (and also allow creation of subfolders if not exist) add -p option to the command. Signed-off-by: Anton Mikanovich <ami...@ilbers.de> --- etc/setup.d/10mount | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/setup.d/10mount b/etc/setup.d/10mount index 5e734050..9fb8093a 100755 --- a/etc/setup.d/10mount +++ b/etc/setup.d/10mount @@ -83,7 +83,7 @@ do_umount_all() exit 1 fi else - mkdir -m 0700 /var/lock/schroot + mkdir -m 0700 -p /var/lock/schroot fi if [ "$(stat -c "%u %g %a" /var/lock/schroot)" != "0 0 700" ]; then -- 2.39.5