Luca Boccassi
cd4379bb54
nsresourced: harden the transient UID/GID write restriction ( #43196 )
...
nsresourced hands out transient, recyclable UID/GID ranges to
unprivileged user namespaces, and a BPF-LSM policy is what keeps a
client from leaving inodes owned by its transient range on a file system
that outlives the namespace, so that a later client which gets the same
range can't inherit them.
The old policy decided based on the mount a write went through, which is
forgeable: unshare(CLONE_NEWNS) gives you clones of every mount with
fresh mount IDs but the same superblock, and the mount namespace's owner
is yours to pick. overlayfs sidesteps it entirely. So this reworks the
check to look at where the write actually lands on disk.
The first commit (Christian Brauner's) replaces the per-mount allowlist
with two questions answered from fields the client can't forge and that
survive mount cloning: does the file system die together with the user
namespace (sb->s_user_ns at or below the managed one), and does the
transient ID actually reach the disk, or does an idmapped mount
translate it into something else first. It walks the userns chain
upwards so a nested namespace can't escape it. The map layout changed,
so the pins move to userns-restrict.v2 and the old ones are removed on
install.
The second commit handles overlayfs. A write through an overlay creates
the file on the upper layer via vfs_create(), which only trips the inode
LSM hooks, not the path hooks we attach to, and the one path hook that
does fire sees the overlay mount, which belongs to the managed namespace
and so looks like it dies with it even though the upper may be
persistent. So we judge the upper at mount time in sb_kern_mount and
refuse a writable overlay unless its upper dies with the namespace too.
Reading overlayfs' private ovl_fs/ovl_layer uses CO-RE type flavors
guarded by bpf_core_type_exists(), and the service now orders after
modprobe@overlay.service .
The third commit deals with restarts. The managed set only lives in the
pinned maps, so an upgrade that changes the map layout comes up with
empty maps and every already-running namespace silently loses its
restriction. manager_startup() now re-adds the live registry entries to
the maps in the same pass that reaps the dead ones. The setgroups()
denial is restored from a flag we now store in the registry.
One consequence: a managed namespace can only mount a writable overlay
whose upper dies with it, e.g. a tmpfs it set up itself. If you need a
writable persistent upperdir (mkosi does), use a plain unprivileged user
namespace for that, not a transient nsresourced range.
2026-08-21 22:05:25 +01:00
..
2026-06-23 23:10:01 +02:00
2022-07-12 22:54:39 +01:00
2022-07-20 13:15:37 +09:00
2022-07-12 22:54:39 +01:00
2023-09-27 12:33:40 +02:00
2025-01-03 08:32:43 +01:00
2025-01-03 08:32:43 +01:00
2025-01-03 08:32:43 +01:00
2025-01-03 08:32:43 +01:00
2024-03-14 11:34:04 +01:00
2024-10-11 10:36:08 +02:00
2026-07-10 14:01:24 +02:00
2026-02-03 21:00:19 +09:00
2026-02-03 21:00:19 +09:00
2023-05-19 17:47:14 +02:00
2024-05-28 14:48:56 +02:00
2024-05-28 14:48:56 +02:00
2024-03-16 05:31:44 +09:00
2020-11-09 13:23:58 +09:00
2024-05-18 01:28:14 +09:00
2025-03-05 17:03:59 +01:00
2025-03-05 12:37:26 +01:00
2023-06-23 13:46:56 +01:00
2023-06-23 13:46:56 +01:00
2026-02-03 21:00:19 +09:00
2024-05-18 01:28:14 +09:00
2020-11-09 13:23:58 +09:00
2025-02-21 10:03:32 +01:00
2025-02-21 10:03:32 +01:00
2025-09-18 21:54:36 +01:00
2021-04-20 19:11:07 +02:00
2025-09-18 21:54:36 +01:00
2025-09-18 21:54:36 +01:00
2025-09-18 21:54:36 +01:00
2025-09-18 21:54:36 +01:00
2021-04-20 18:26:17 +02:00
2024-05-18 01:28:14 +09:00
2025-09-18 21:54:36 +01:00
2026-02-16 14:32:38 +01:00
2023-05-23 12:39:16 +02:00
2025-07-11 21:38:58 +02:00
2026-08-20 15:30:20 +02:00
2026-02-16 14:32:38 +01:00
2020-11-09 13:23:58 +09:00
2020-11-09 13:23:58 +09:00
2024-05-28 14:48:56 +02:00
2024-05-28 14:48:56 +02:00
2024-03-09 19:32:09 +00:00
2024-03-10 22:57:22 +08:00
2021-06-30 13:25:16 +02:00
2020-11-09 13:23:58 +09:00
2025-02-25 21:40:05 +01:00
2024-03-16 05:31:44 +09:00
2020-11-09 13:23:58 +09:00
2026-02-03 21:00:19 +09:00
2020-11-09 13:23:58 +09:00
2021-06-30 13:25:16 +02:00
2024-05-23 00:06:30 +09:00
2025-07-22 15:01:26 +01:00
2023-11-13 15:45:16 +01:00
2020-11-09 13:23:58 +09:00
2024-05-28 14:48:56 +02:00
2024-05-28 14:48:56 +02:00
2024-05-28 14:48:56 +02:00
2024-05-28 14:48:56 +02:00
2022-09-15 14:59:11 +02:00
2025-06-17 13:16:44 +02:00
2026-05-11 22:34:28 +01:00
2026-07-03 10:10:09 +02:00
2026-07-03 10:10:09 +02:00
2026-07-03 10:10:09 +02:00
2026-03-18 14:58:43 +01:00
2022-09-15 14:59:11 +02:00
2025-01-02 16:37:57 +01:00
2022-09-15 14:59:11 +02:00
2025-03-03 10:47:09 +01:00
2026-06-23 23:10:01 +02:00
2025-01-02 16:39:05 +01:00
2023-07-28 19:34:03 +01:00
2025-09-30 16:34:54 +02:00
2024-05-28 14:48:56 +02:00
2023-07-28 19:34:03 +01:00
2024-04-10 23:40:53 +08:00
2025-05-14 09:34:07 +02:00
2023-01-04 15:18:10 +01:00
2026-06-24 13:05:34 +02:00
2026-06-23 23:10:01 +02:00
2026-02-06 23:15:49 +01:00
2024-07-06 10:17:20 +01:00
2026-04-07 09:51:03 +02:00
2026-04-07 09:51:03 +02:00
2026-04-07 09:51:03 +02:00
2024-02-12 11:57:24 +01:00
2025-08-20 11:42:30 +01:00
2026-06-23 23:10:01 +02:00
2024-08-26 15:40:15 +02:00
2026-06-27 17:28:39 +02:00
2026-06-27 17:28:39 +02:00
2026-06-27 17:28:39 +02:00
2025-03-05 17:03:59 +01:00
2025-03-05 12:37:26 +01:00
2025-03-05 12:37:26 +01:00
2026-06-23 23:10:01 +02:00
2025-03-05 12:37:26 +01:00
2025-09-26 16:40:14 +02:00
2025-07-16 05:47:38 +09:00
2025-07-16 05:47:38 +09:00
2023-07-28 19:34:03 +01:00
2023-07-28 19:34:03 +01:00
2023-06-22 10:33:18 +01:00
2024-04-03 22:07:43 +08:00
2023-09-07 20:21:16 +08:00
2024-01-15 02:59:25 +08:00
2020-11-09 13:23:58 +09:00
2025-09-26 16:19:43 +02:00
2025-03-31 11:51:15 +02:00
2026-03-20 10:04:26 +01:00
2026-06-23 23:10:01 +02:00
2023-05-23 12:39:16 +02:00
2024-01-15 02:59:25 +08:00
2026-05-27 04:36:05 +09:00
2026-06-19 20:05:14 +02:00
2026-06-23 23:10:01 +02:00
2026-06-22 22:03:12 +02:00
2026-06-23 23:10:01 +02:00
2026-03-26 10:54:15 +01:00
2025-04-30 21:27:37 +02:00
2026-06-23 23:10:01 +02:00
2023-05-23 12:39:16 +02:00
2024-05-26 03:11:24 +09:00
2023-07-28 19:34:03 +01:00
2023-07-28 19:34:03 +01:00
2023-10-12 23:10:59 +01:00
2026-06-24 11:47:28 +01:00
2026-06-23 12:41:38 +02:00
2026-06-23 23:10:01 +02:00
2026-02-23 10:43:00 +01:00
2025-06-30 13:10:43 +02:00
2025-06-30 13:10:43 +02:00
2024-05-02 19:41:01 +02:00
2026-06-23 23:10:01 +02:00
2025-07-10 21:38:36 +02:00
2025-06-30 13:10:43 +02:00
2024-05-17 11:57:53 +09:00
2025-06-17 13:16:07 +02:00
2023-06-22 10:33:18 +01:00
2024-01-09 21:57:46 +08:00
2026-06-23 23:10:01 +02:00
2024-10-22 23:44:47 +02:00
2025-02-21 09:57:02 +01:00
2024-03-14 10:26:45 +01:00
2026-06-01 10:56:16 +02:00
2025-09-25 22:43:59 +02:00
2026-06-23 23:10:01 +02:00
2024-03-17 13:33:45 +01:00
2026-03-20 19:19:10 +01:00
2026-06-23 23:10:01 +02:00
2026-06-23 23:10:01 +02:00
2026-06-06 10:47:10 +01:00
2025-10-20 18:17:47 +02:00
2024-04-26 22:16:33 +02:00
2026-06-23 23:10:01 +02:00
2026-06-23 23:10:01 +02:00
2026-06-23 23:10:01 +02:00
2025-10-20 18:17:29 +02:00
2025-10-20 18:17:29 +02:00
2026-02-18 17:58:33 +09:00
2025-11-15 07:52:42 +01:00
2025-07-11 18:17:04 +02:00
2026-08-12 10:49:34 +02:00
2026-07-13 09:53:15 +02:00
2025-04-30 21:27:37 +02:00
2026-06-23 23:10:01 +02:00
2026-06-23 23:10:01 +02:00
2024-08-26 15:40:15 +02:00
2026-03-26 16:11:34 +01:00
2026-03-26 16:11:34 +01:00
2024-03-14 10:26:45 +01:00
2024-03-14 10:26:45 +01:00
2024-03-14 10:26:45 +01:00
2024-03-14 10:26:45 +01:00
2024-03-14 10:26:45 +01:00
2024-03-14 10:26:45 +01:00
2024-03-14 10:26:45 +01:00
2026-06-23 23:10:01 +02:00
2024-08-26 15:40:15 +02:00
2026-05-22 12:15:12 +02:00
2026-03-26 16:11:34 +01:00
2026-06-04 11:23:59 +01:00
2026-03-26 16:11:34 +01:00
2026-03-26 16:11:34 +01:00
2026-03-26 16:11:34 +01:00
2026-03-26 16:11:34 +01:00
2026-03-26 16:11:34 +01:00
2026-03-26 16:11:34 +01:00
2026-03-26 16:11:34 +01:00
2026-01-21 23:13:09 +01:00
2023-07-28 19:34:03 +01:00
2025-07-16 05:47:38 +09:00
2025-07-16 05:47:38 +09:00
2023-07-28 19:34:03 +01:00
2024-05-28 14:48:56 +02:00
2025-09-18 08:46:34 +09:00
2026-06-23 23:10:01 +02:00
2025-09-23 09:22:04 +02:00
2026-06-23 23:10:01 +02:00
2026-05-23 12:58:23 +02:00
2026-06-23 23:10:01 +02:00
2026-05-23 12:58:23 +02:00
2026-06-23 23:10:01 +02:00
2026-06-19 05:23:18 +02:00
2026-06-23 23:10:01 +02:00
2026-06-25 10:33:01 +01:00
2026-08-20 15:30:20 +02:00
2026-08-20 15:30:20 +02:00
2026-06-24 11:47:28 +01:00
2026-06-22 20:42:35 +02:00
2026-06-24 11:47:28 +01:00
2026-06-19 05:23:18 +02:00
2026-06-23 23:10:01 +02:00
2026-06-23 23:10:01 +02:00
2025-04-30 21:27:37 +02:00
2024-03-14 00:10:48 +09:00
2023-07-05 10:58:47 +09:00
2024-05-23 00:06:30 +09:00
2026-06-23 23:10:01 +02:00
2026-04-29 12:25:47 +02:00
2026-06-23 23:10:01 +02:00
2026-04-29 12:25:47 +02:00
2025-09-18 21:30:31 +02:00
2024-01-15 02:59:25 +08:00
2023-07-28 19:34:03 +01:00
2023-07-28 19:34:03 +01:00
2026-04-07 09:51:03 +02:00
2026-04-07 09:51:03 +02:00
2026-04-07 09:51:03 +02:00
2026-06-23 23:10:01 +02:00
2024-08-26 15:40:15 +02:00
2026-07-03 11:16:46 +02:00
2026-07-03 11:16:46 +02:00
2026-07-03 11:16:46 +02:00
2026-07-28 15:20:09 +09:00
2026-06-24 13:05:34 +02:00
2026-06-24 13:05:34 +02:00
2026-06-24 13:05:34 +02:00
2026-06-24 13:05:34 +02:00
2026-06-24 13:05:34 +02:00
2026-06-24 13:05:34 +02:00
2026-05-13 15:09:27 +01:00
2026-07-15 13:27:48 +02:00
2026-06-26 13:01:31 +01:00
2026-06-26 13:01:31 +01:00
2026-06-26 13:01:31 +01:00
2024-11-06 15:44:11 -05:00
2023-08-12 07:55:20 +09:00
2023-09-19 10:05:38 +02:00
2024-01-09 21:57:45 +08:00
2026-08-15 13:12:50 -07:00
2023-06-08 14:09:36 +02:00
2023-08-12 07:55:20 +09:00
2023-08-12 07:55:20 +09:00
2025-07-09 11:08:31 +02:00
2026-03-26 16:11:34 +01:00
2026-03-26 16:11:34 +01:00
2026-03-26 16:11:34 +01:00
2026-07-09 13:33:06 +02:00
2024-04-16 09:45:43 +09:00
2026-07-18 05:29:59 +09:00
2025-06-30 13:10:43 +02:00
2026-07-18 05:29:59 +09:00
2026-07-18 05:29:59 +09:00
2023-07-28 19:34:03 +01:00
2023-07-28 19:34:03 +01:00
2023-07-28 19:34:03 +01:00
2026-06-06 10:47:10 +01:00
2025-04-30 21:27:37 +02:00
2026-06-23 23:10:01 +02:00
2025-03-31 19:23:51 +02:00
2023-11-25 13:27:17 +01:00
2025-07-11 18:17:04 +02:00
2023-07-28 19:34:03 +01:00
2025-02-12 18:16:44 +01:00
2025-03-05 12:37:48 +01:00
2020-11-09 13:23:58 +09:00
2026-05-22 12:15:14 +02:00
2026-05-22 12:15:14 +02:00
2020-11-09 13:23:58 +09:00