Package: schroot
Version: 1.6.13-3+b2
Severity: important
X-Debbugs-Cc: i...@ilbers.de, ub...@ilbers.de

Hello!

I have multiple schroot instances running in parallel. Some of them are started
by sbuild, others have been started manually by scripts. All those schroot
instances are sharing the same chroot and session config directories
(/etc/schroot/chroot.d and /var/lib/schroot/session). When any single schroot
is running, it starts with parsing all the files in config directories.
As reading file list and opening every config file are separate operations with
no locking or any way to make it atomic, other schroot instance can stop
session and remove corresponding config file between this operations.
It makes the first instance fail with:

E: /var/lib/schroot/session/<session2_id>: Failed to stat file: No such file or 
directory

or

E: /var/lib/schroot/session/<session2_id>: Failed to open file: No such file or 
directory

depends on which stage it was deleted (before stat or between stat and open
operations).
The only locking currently done is on config file content parsing which is not
enough for such a case.

The same issue is observed on chroot config files when deleting any chroot
config externally.

There are two ways of fixing this issue:

1. Do not fail on file operations if file not exists.
Don't look like the correct way, but easy to implement.

2. Cover both file list obtaining and files opening with a lock.
Locking in chroot_config::add_config_directory() calls can be shared, while
sbuild::chroot::setup_session_info should use exclusive mode.
This lockfile can be accessible by external applications to allow safe chroot
config files removing.

Solution proposed upstream:
https://codeberg.org/shelter/reschroot/pulls/11

-- System Information:
Debian Release: 12.8
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: amd64 (x86_64)

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:

Reply via email to