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

Bug#987419: schroot: Incorrect mount/unmount binfmt handler sequence for start/stop schroot stages



Package: schroot
Version: 1.6.10-6+b1
Severity: important

Dear Maintainer,

I'm using schroot for building packages with sbuild using qemu-arm-static
binfmt handler in chroot environment.

/etc/setup.d/15binfmt handler script incorrectly tries to perform bind mount
while schroot session is stopping. This leads to the mount error and terminates
schroot session end. So such sessions couldn't be ended. So, 15binfmt script
should take into account current $STAGE value to properly handle requested
operation. My modified script shows example of such handling process:

for emulator in $(update-binfmts --find "$shell"); do
    dst="${CHROOT_PATH}$emulator"
    if [ ! -e "$emulator" ]; then
        info "Missing emulator: $emulator; not enabling binfmt support"
    else
        if [ "$STAGE" == "setup-start" ] || \
           [ "$STAGE" == "setup-recover" ]; then
            [ -e "$dst" ] || { mkdir -p "$(dirname "$dst")"; touch "$dst"; }
            mount --bind "$emulator" "$dst"
            mount -o remount,ro,bind "$dst"
        elif [ "$STAGE" == "setup-stop"  ]; then
            umount "$dst"
        fi
    fi
done

It includes modifications, backported from schroot version 1.6.10-12, line:
...
[ -e "$dst" ] || { mkdir -p "$(dirname "$dst")"; touch "$dst"; }
...



-- System Information:
Debian Release: 10.9
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386, armhf

Kernel: Linux 5.10.0-0.bpo.3-amd64 (SMP w/4 CPU cores)
Kernel taint flags: TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=ru_RU.UTF-8, LC_CTYPE=ru_RU.UTF-8 (charmap=UTF-8), LANGUAGE= (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages schroot depends on:
ii  libboost-filesystem1.67.0       1.67.0-13+deb10u1
ii  libboost-iostreams1.67.0        1.67.0-13+deb10u1
ii  libboost-program-options1.67.0  1.67.0-13+deb10u1
ii  libboost-system1.67.0           1.67.0-13+deb10u1
ii  libc6                           2.28-10
ii  libgcc1                         1:8.3.0-6
ii  libpam0g                        1.3.1-5
ii  libstdc++6                      8.3.0-6
ii  libuuid1                        2.33.1-0.1
ii  lsb-base                        10.2019051400
ii  schroot-common                  1.6.10-6

schroot recommends no packages.

Versions of packages schroot suggests:
pn  aufs-tools | unionfs-fuse  <none>
ii  btrfs-progs [btrfs-tools]  4.20.1-2
ii  debootstrap                1.0.114
ii  lvm2                       2.03.02-3
ii  qemu-user-static           1:3.1+dfsg-8+deb10u8

-- Configuration Files:
/etc/schroot/setup.d/15binfmt changed:
set -e
. "$SETUP_DATA_DIR/common-data"
. "$SETUP_DATA_DIR/common-functions"
. "$SETUP_DATA_DIR/common-config"
if [ "$STAGE" != "setup-start" ] && \
   [ "$STAGE" != "setup-stop"  ] && \
   [ "$STAGE" != "setup-recover" ]; then
    exit 0
elif ! which update-binfmts > /dev/null 2>&1; then
    info "Missing update-binfmts; not enabling binfmt support"
    exit 0
fi
shell="${CHROOT_PATH}/bin/sh"
for emulator in $(update-binfmts --find "$shell"); do
    dst="${CHROOT_PATH}$emulator"
    if [ ! -e "$emulator" ]; then
        info "Missing emulator: $emulator; not enabling binfmt support"
    else
        if [ "$STAGE" == "setup-start" ] || \
           [ "$STAGE" == "setup-recover" ]; then
	    [ -e "$dst" ] || { mkdir -p "$(dirname "$dst")"; touch "$dst"; }
	    mount --bind "$emulator" "$dst"
	    mount -o remount,ro,bind "$dst"
        elif [ "$STAGE" == "setup-stop"  ]; then
            umount "$dst"
        fi
    fi
done


-- no debconf information


Reply to: