/dev/ptmx permission issue

Hello,

I’ve run into a problem with /dev/ptmx file in a privileged Alt Linux container.

/dev/ptmx has 000 permissions and because of it, user processes can’t create ptys:

c--------- 1 root root 5, 2 Oct 31 14:15 /dev/ptmx

The problem goes away if I change permissions to 666 manually but it’s 000 again on the next container’s start.

Here’re the permissions and mounts inside the container:

[root@container ~]# ls -l /dev/pts/ptmx /dev/ptmx
c--------- 1 root root 5, 2 Oct 31 14:18 /dev/ptmx
c--------- 1 root root 5, 2 Oct 31 14:18 /dev/pts/ptmx

[root@container ~]# mount|grep pts
devpts on /dev/lxc/console type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
devpts on /dev/console type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
devpts on /dev/ptmx type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
devpts on /dev/lxc/tty1 type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
devpts on /dev/lxc/tty2 type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
devpts on /dev/lxc/tty3 type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
devpts on /dev/lxc/tty4 type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)

Same on the host:

[root@host ~]# ls -l /dev/pts/ptmx /dev/ptmx
crw-rw-rw- 1 root tty  5, 2 окт 31 14:20 /dev/ptmx
c--------- 1 root root 5, 2 окт 31 13:41 /dev/pts/ptmx

[root@host ~]# mount|grep pts
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)

I also checked permissions in Ubuntu 20.04 container where everything works fine:

mva@ubuntu:~$ ls -l /dev/pts/ptmx /dev/ptmx
crw-rw-rw- 1 root root 5, 2 окт 31 14:21 /dev/ptmx
crw-rw-rw- 1 root root 5, 2 окт 31 14:21 /dev/pts/ptmx

mva@ubuntu:~$ mount|grep pts
devpts on /dev/lxc/console type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
devpts on /dev/console type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=666,max=1024)
devpts on /dev/ptmx type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=666,max=1024)
devpts on /dev/lxc/tty1 type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=666,max=1024)
devpts on /dev/lxc/tty2 type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=666,max=1024)
devpts on /dev/lxc/tty3 type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=666,max=1024)
devpts on /dev/lxc/tty4 type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=666,max=1024)

It seems the problem is in ptmxmode option? How can I fix it?

I found this line in /etc/fstab in the container’s rootfs:

devpts /dev/pts devpts nosuid,noexec,gid=tty,mode=620 0 0

After I added ptmxmode=666 to mount options, /dev/ptmx became 666.

1 Like