spiegel_podman/pkg
Fabian Holler 579c5dc809 Match VT device paths to be blocked from mounting exactly
As @mheon pointed out in PR #17055[^1], isVirtualConsoleDevice() does
not only matches VT device paths but also devices named like
/dev/tty0abcd.
This causes that non VT device paths named /dev/tty[0-9]+[A-Za-z]+ are
not mounted into privileged container and systemd containers accidentally.

This is an unlikely issue because the Linux kernel does not use device
paths like that.
To make it failproof and prevent issues in unlikely scenarios, change
isVirtualConsoleDevice() to exactly match ^/dev/tty[0-9]+$ paths.

Because it is not possible to match this path exactly with Glob syntax,
the path is now checked with strings.TrimPrefix() and
strconv.ParseUint().
ParseUint uses a bitsize of 16, this is sufficient because the max
number of TTY devices is 512 in Linux 6.1.5.
(Checked via 'git grep -e '#define' --and -e 'TTY_MINORS').

The commit also adds a unit-test for isVirtualConsoleDevice().

Fixes: f4c81b0aa5 ("Only prevent VTs to be mounted inside...")

[^1]: https://github.com/containers/podman/pull/17055#issuecomment-1378904068

Signed-off-by: Fabian Holler <mail@fholler.de>
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-01-30 07:33:38 +00:00
..
annotations Remove ReservedAnnotations from kube generate specification 2023-01-18 08:46:24 -05:00
api Merge pull request #17242 from openshift-cherrypick-robot/cherry-pick-17114-to-v4.4 2023-01-27 14:57:19 -05:00
auth [CI:DOCS] Fix spelling and typos 2022-11-19 16:26:00 +01:00
autoupdate bump golangci-lint to v1.49.0 2022-10-17 09:19:41 +02:00
bindings Add support for podman build --group-add 2023-01-19 10:42:10 -05:00
channel bump golangci-lint to v1.50.1 2022-12-15 13:39:56 +01:00
checkpoint checkpoint restore: fix --ignore-static-ip/mac 2022-12-12 18:34:49 +01:00
copy pkg: switch to golang native error wrapping 2022-07-08 08:54:47 +02:00
criu deps: bump go-criu to v6 2022-11-01 13:57:24 +05:30
ctime Replace deprecated ioutil 2022-09-20 15:34:27 -04:00
domain Add (podman {image,manifest} push --sign-by-sigstore=param-file.yaml) 2023-01-27 16:46:28 +01:00
env [CI:DOCS] Fix spelling and typos 2022-11-19 16:26:00 +01:00
errorhandling libpod/runtime: switch to golang native error wrapping 2022-07-04 15:39:00 +02:00
inspect pkg/inspect: remove unused ImageResult type 2022-05-24 16:07:39 +02:00
k8s.io Merge pull request #16560 from eriksjolund/fix_typo_a_an 2022-11-20 17:04:36 -05:00
lookup bump golangci-lint to v1.50.1 2022-12-15 13:39:56 +01:00
machine fix: running check error when podman is default in wsl 2023-01-27 19:47:49 +00:00
namespaces libpod: Add pasta networking mode 2022-11-08 00:16:35 +01:00
parallel Fix stutters 2022-09-10 07:52:00 -04:00
ps DB: make loading container states optional 2023-01-27 09:14:12 +00:00
rctl pkg/rctl: Remove unused cgo dependency 2022-10-31 15:13:48 +00:00
rootless rootless: rename auth-scripts to preexec-hooks 2023-01-17 10:58:46 +01:00
rootlessport go fmt: use go 1.18 conditional-build syntax 2022-03-18 09:11:53 +01:00
seccomp pkg: switch to golang native error wrapping 2022-07-08 08:54:47 +02:00
selinux Fix SELinux functions names to not be repetitive 2020-04-23 15:57:34 -04:00
servicereaper go fmt: use go 1.18 conditional-build syntax 2022-03-18 09:11:53 +01:00
signal Run codespell on code 2022-11-04 10:57:41 -04:00
specgen kube-play: add support for HostPID in podSpec 2023-01-20 17:32:59 +05:30
specgenutil Remove ReservedAnnotations from kube generate specification 2023-01-18 08:46:24 -05:00
systemd quadlet: Add device support for .volume files 2023-01-27 19:48:04 +00:00
terminal podman ssh work, using new c/common interface 2022-08-09 14:00:58 -04:00
timetype bump golangci-lint to v1.49.0 2022-10-17 09:19:41 +02:00
trust pkg/trust: Take the default policy path from c/common/pkg/config 2022-11-25 10:14:15 +00:00
util Match VT device paths to be blocked from mounting exactly 2023-01-30 07:33:38 +00:00