Package: qemu
Version: 1:5.2+dfsg-6
Followup-For: Bug #940533
X-Debbugs-Cc: t...@mirbsd.de, Marc Haber <mh+debian-packa...@zugschlus.de>

This bug is still pertinent. I’ve reproduced it locally right now as:

 # mount an RPi Debian buster image (pristine Debian/arm64, not Raspian)
$ sudo losetup /dev/loop3 ~/tmp/rpi.img
$ sudo kpartx -a -v /dev/loop3
$ sudo mount /dev/mapper/loop3p2 /mnt
 # mount extra filesystems
$ mpt=/mnt
$ sudo mount -t tmpfs swap "$mpt/dev/shm"
$ sudo mount -t proc  proc "$mpt/proc"
$ sudo mount -t tmpfs swap "$mpt/tmp"
$ sudo mount --bind /dev/pts "$mpt/dev/pts"
 # go into the chroot
$ tty
/dev/pts/2
$ sudo chroot /mnt su -
chroot# tty
/dev/pts/2
chroot# su - test
chroot$ tty
/dev/pts/2
chroot$ sudo id
sudo: no tty present and no askpass program specified
chroot$ sudo -S id
[sudo] password for test: ***
uid=0(root) gid=0(root) groups=0(root)


zugschlus dixit:

>On Tue, Sep 17, 2019 at 12:33:26AM +0200, Thorsten Glaser wrote:
>> linux-user/syscall.c:open_self_stat() fills the emulated
>> /proc/self/stat with a lot of 0s,
>
>So the contents of /proc/self/stat has the correct number of fields, but
>all zeroes?

chroot$ /bin/cat /proc/self/stat
8903 (cat) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1099013312 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0
$ /bin/cat /proc/self/stat
8909 (cat) R 8173 8909 8173 34818 8909 4194304 83 0 0 0 0 0 0 0 20 0 1 0 
2027189139 2854912 114 18446744073709551615 4198400 4215449 4292526912 0 0 0 0 
0 0 0 0 0 17 2 0 0 0 0 0 4235008 4235844 8646656 4292528960 4292528985 
4292528985 4292530159 0
chroot# /bin/cat /proc/self/stat
8932 (cat) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1099013472 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0

So, yes. But watch this:

 # avoid use of mksh changing something
chroot$ /bin/dash
chdash$ echo $$
8974
chdash$ cat /proc/8974/stat
8974 (dash) S 8942 8974 8173 34818 8980 4194304 666 0 1 0 7 2 0 0 20 0 2 0 
2027195261 64946176 2611 18446744073709551615 134516736 138848748 4287049936 0 
0 0 0 2637828 2004991739 0 0 0 17 3 0 0 5 0 0 143243668 144636888 186900480 
4287053448 4287053510 4287053510 4287053806 0

Erm… but watch THIS:

chdash$ cat /proc/9045/stat
9045 (cat) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1099013296 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0

(9045 was me lucky-guessing the pid the cat binary became)

-- System Information:
Debian Release: bullseye/sid
  APT prefers unreleased
  APT policy: (500, 'unreleased'), (500, 'buildd-unstable'), (500, 'unstable'), 
(100, 'experimental')
Architecture: x32 (x86_64)
Foreign Architectures: i386, amd64

Kernel: Linux 5.7.0-1-amd64 (SMP w/4 CPU threads)
Kernel taint flags: TAINT_FIRMWARE_WORKAROUND
Locale: LANG=C, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /bin/lksh
Init: sysvinit (via /sbin/init)

-- no debconf information

Reply via email to