Skip to content

Commit b0f6b24

Browse files
authored
Merge pull request #1958 from microsoft/agents/issue-1606-setgroups-restore
openvmm: pin the refusal of groups that caller ownership cannot restore
2 parents f3bff9b + 2136897 commit b0f6b24

3 files changed

Lines changed: 53 additions & 18 deletions

File tree

‎doc/openvmm-upstream-roadmap.md‎

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
- Mapped fork tip: `1e492803287f04b40bb7c17e8648c4b96af52ecc`, position 126. The graph, PR
1010
summary, and commit mapping below cover positions 001-126, the PR18 fixups at positions 302,
1111
333, 342, 345, 347, and 351, and the PR13 fixups at positions 340 and 349.
12-
- NVX's pinned OpenVMM revision: `afa67d6a67d76a573439739bf98f8bc85158adcc`, position 354, the head
13-
of microsoft/openvmm#5220, whose commit follows position 353, `de700ffc2`, the head of
12+
- NVX's pinned OpenVMM revision: `655bc319da7e145bbd3a0272fcb830980dab0694`, position 355, the head
13+
of microsoft/openvmm#5221, whose commit follows position 354, `afa67d6a6`, the head of
14+
microsoft/openvmm#5220, whose commit follows position 353, `de700ffc2`, the head of
1415
microsoft/openvmm#5219, whose commit follows position 352, `3aefff9ba`, the head of
1516
microsoft/openvmm#5218, whose commit follows position 351, `8bea555db`, the head of
1617
microsoft/openvmm#5217, whose commit follows position 350, `189dc519f`, the head of
@@ -31,8 +32,8 @@
3132
landed, so each later commit's position is one less than before, and it added five fixups at its
3233
tip, positions 335-339. Of the 334 replayed commits, 47 conflicted with upstream and 13 replayed
3334
with new context; see [Conflicts of the v7.2 rebase](#conflicts-of-the-v72-rebase). The pin is
34-
228 commits past the mapped tip on the same first-parent chain. Positions 127-301, 303-332, 334,
35-
341, 343, 344, 346, 348, 350, and 352-354 are not yet assigned to PRs, positions 302, 333, 342,
35+
229 commits past the mapped tip on the same first-parent chain. Positions 127-301, 303-332, 334,
36+
341, 343, 344, 346, 348, 350, and 352-355 are not yet assigned to PRs, positions 302, 333, 342,
3637
345, 347, and 351 are PR18 fixups, positions 340 and 349 are PR13 fixups, and positions 316 and
3738
335-339 are rebase fixups; see [Commits after the mapped tip](#commits-after-the-mapped-tip).
3839
- Upstream main: `bf353460ff70e4a65627bb7003bed2cad1ce121f` (2026-11-21), the fork base; see
@@ -1643,7 +1644,8 @@ bf353460f
16431644
-> virtio-fs links refused for nodes whose names are all gone [352]
16441645
-> microVM file children attached through relative paths and symbolic links [353]
16451646
-> virtio-fs aggregate root link counts that leave out file children [354]
1646-
-> afa67d6a6 (NVX pin)
1647+
-> caller requests refused while host groups may be unmapped [355]
1648+
-> 655bc319d (NVX pin)
16471649
```
16481650

16491651
For upstream review, PR01-PR03, PR05, PR06, and PR14 can be rebased independently onto current
@@ -1703,7 +1705,7 @@ tests.
17031705

17041706
## Commits after the mapped tip
17051707

1706-
The NVX pin extends the chain past position 126 without merges. Of its 228 later commits, positions
1708+
The NVX pin extends the chain past position 126 without merges. Of its 229 later commits, positions
17071709
302, 333, 342, 345, 347, and 351 are PR18 fixups, positions 340 and 349 are PR13 fixups, position
17081710
316 is the fixup of the v7.1 rebase, positions 335-339 are the fixups of the v7.2 rebase, and the
17091711
others are not yet classified or assigned to PRs.
@@ -1714,15 +1716,15 @@ of the v4.0 reorganization, positions 201-206 followed it, positions 207-213 fol
17141716
reorganization, positions 214 and 215 followed the v5.1 rebase, positions 216-253 followed the
17151717
v6.0 reorganization, positions 254-296 followed the v6.1 rebase, positions 297-315 followed the
17161718
v7.0 reorganization, position 316 is the v7.1 rebase's fixup, positions 317-334 followed the
1717-
v7.1 rebase, positions 335-339 are the v7.2 rebase's fixups, and positions 340-354 followed the
1719+
v7.1 rebase, positions 335-339 are the v7.2 rebase's fixups, and positions 340-355 followed the
17181720
v7.2 rebase, so they combine none, apart from
17191721
position 215, which combines v5.1 positions 222 and 223, and the commits that the v7.0
17201722
reorganization folded into them. Each commit through position 316 has the position that it had in
17211723
v7.0 and v7.1, and each of positions 317-334 is its v7.1 position less one, since the v7.2 rebase
17221724
dropped v7.1 position 317, upstream's microsoft/openvmm#5160, which v7.1 had backported. Each
17231725
commit's v6.1 position is its v6.0 position less seven, the number of commits that the v6.1 rebase
17241726
dropped before it, and its v6.0 position is its v5.1 position through 147 and one less from v5.1
1725-
position 149 on, and positions 297-354 have no earlier position; see
1727+
position 149 on, and positions 297-355 have no earlier position; see
17261728
[Conflicts of the v7.2 rebase](#conflicts-of-the-v72-rebase),
17271729
[The v7.0 reorganization](#the-v70-reorganization),
17281730
[Conflicts of the v6.1 rebase](#conflicts-of-the-v61-rebase), and
@@ -1963,6 +1965,7 @@ whose first 220 commits are those of `feature/microvm/release/v6.0`, and a v4.0
19631965
| 352 | `3aefff9ba` | - | - | - | - | - | - | virtiofs: refuse to link a node whose last name is gone (microsoft/openvmm#5218) |
19641966
| 353 | `de700ffc2` | - | - | - | - | - | - | virtiofs: resolve a microVM file child's path as its identity does (microsoft/openvmm#5219) |
19651967
| 354 | `afa67d6a6` | - | - | - | - | - | - | virtiofs: count only child directories in the synthetic root's nlink (microsoft/openvmm#5220) |
1968+
| 355 | `655bc319d` | - | - | - | - | - | - | lxutil: fail closed before dropping groups it cannot restore (microsoft/openvmm#5221) |
19661969

19671970
The remarks that say whether commits apply to upstream main record what was found on upstream main
19681971
when each commit was mapped: the v3.0 reorganization's base, `b2676222b`, for the commits that it
@@ -1973,7 +1976,7 @@ and `c0694c4da`, upstream main on 2026-11-16, for positions 297-306, `c4419be15`
19731976
main on 2026-11-19, for positions 321-324, `78af54a51`, upstream main on 2026-11-20, for position
19741977
325, `d83f87209`, upstream main later that day, for position 326, `265f0a73f`, upstream main
19751978
later still, for positions 327 and 328, and `bf353460f`, upstream main on 2026-11-21 and the v7.2
1976-
fork base, for positions 329-334 and 340-354.
1979+
fork base, for positions 329-334 and 340-355.
19771980
They name the positions that the commits have now, but neither the v7.2 rebase on `bf353460f`, the
19781981
v7.1 rebase on `9a875b563`, nor the v7.0 reorganization on `e6b458cc0` checked them again, nor did
19791982
the v6.1 rebase check the earlier ones on `7d90c4104`.
@@ -4787,6 +4790,36 @@ its file children. Its change to `aggregate.rs` applies to upstream main, but re
47874790
there conflicts in the microVM's `aggregate_fs_tests.rs`, which upstream main lacks, so it cannot go
47884791
upstream on its own.
47894792

4793+
Position 355 has `SwitchedCredentials::switch`, through which `lxutil::with_fs_identity` performs
4794+
each request of a share with `--mount-owner caller` that may access host files as its guest caller,
4795+
fail with `EPERM` before it changes anything while a supplementary group of the thread may be one
4796+
that its user namespace does not map (microsoft/nvx#1606). In a user namespace, `getgroups` reports
4797+
each group that the namespace's `gid_map` does not map as the overflow GID, and `setgroups` refuses
4798+
a GID that the namespace does not map, so a thread that drops such a group can never regain it.
4799+
Where the namespace's `setgroups` file says `allow`, as where `newgidmap` maps a subordinate GID
4800+
range, a thread with `CAP_SETGID` there could drop one: `switch`, which position 158 adds and which
4801+
position 348 makes drop the groups also when the caller's GID is the overflow GID, saved the list
4802+
that `getgroups` reported and dropped the groups, and the restore in position 158's
4803+
`SwitchedCredentials::drop` then failed with `EINVAL`, whose panic aborted OpenVMM, where the
4804+
overflow GID was unmapped, and otherwise gave the thread the group that the overflow GID maps to
4805+
instead of its own. Such a group can be neither kept, since it may be any group, nor dropped, so
4806+
`switch` now takes the groups from a new `mapped_groups`, which returns them as `getgroups` reports
4807+
them when there are none or when `/proc/self/gid_map` maps every ID, as the initial user namespace
4808+
does, and otherwise reads them again between two reads of the overflow GID, which the administrator
4809+
may change at any time, and fails with `EPERM` unless both reads agree and no group has that GID.
4810+
That refusal covers the case for which position 348 drops the groups, so it replaces that drop and
4811+
its `may_report_other_groups_as`. The saved state keeps its format. It changes `switch` and the
4812+
rustdoc of `with_fs_identity` in `lxutil`'s `credentials.rs`, which position 158 adds and position
4813+
348 changes, replaces position 348's `may_report_other_groups_as` with `mapped_groups`, which uses
4814+
position 348's `overflow_gid` and `maps_every_id`, and adds a test there that requires `CAP_SETGID`
4815+
and runs itself again as the root of a new user namespace that permits `setgroups`. In the Guide's
4816+
virtio-fs page, which PR18's position 085 adds, it rewrites the sentence that position 348 adds to
4817+
the caller-mode paragraph that position 158 adds. It fixes defects of positions 158 and 348, which
4818+
no PR maps, so it is not yet assigned to a PR either and follows position 348. Upstream main lacks
4819+
the defect, since it lacks caller ownership and `credentials.rs`. Replaying the commit there
4820+
conflicts in `credentials.rs` and the Guide's virtio-fs page, which upstream main lacks, so it
4821+
cannot go upstream on its own.
4822+
47904823
## PR summary
47914824

47924825
Each count is of v7.2 commits, which include the fixups that the v3.0, v4.0, v5.0, v6.0, and v7.0

‎doc/run.md‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,14 +1570,16 @@ OpenVMM's user belongs to no other group; every other operation fails with
15701570
`EPERM`. Hosts commonly grant access to `/dev/kvm` or `/dev/mshv` through such
15711571
a group, so `caller` usually needs both capabilities. In a user namespace that
15721572
does not map every group, Linux reports each unmapped group as its overflow
1573-
GID, 65534 by default, which is also the default workload's group, so there
1574-
OpenVMM counts a group of its own that reads as the overflow GID as another
1575-
group, even for a caller with that GID. A managed sandbox's guest agent maps
1576-
the shares before any workload runs, as guest root, which `caller` squashes to
1577-
the owner of the host directory, so a managed sandbox whose OpenVMM cannot
1578-
assume that identity fails to start. Grant OpenVMM no other capabilities:
1579-
`CAP_SETUID` lets it assume any host identity, which `caller` mode confines to
1580-
its export.
1573+
GID, 65534 by default, which is also the default workload's group. OpenVMM can
1574+
neither keep such a group nor regain it after dropping it, so there every
1575+
operation that runs as its caller fails with `EPERM`, even with both
1576+
capabilities, while one of OpenVMM's groups reads as the overflow GID, as in a
1577+
rootless container that keeps the host user's groups; start OpenVMM there
1578+
without such groups. A managed sandbox's guest agent maps the shares before
1579+
any workload runs, as guest root, which `caller` squashes to the owner of the
1580+
host directory, so a managed sandbox whose OpenVMM cannot assume that identity
1581+
fails to start. Grant OpenVMM no other capabilities: `CAP_SETUID` lets it
1582+
assume any host identity, which `caller` mode confines to its export.
15811583

15821584
The guest kernel reports each caller's identity, and guest root may assume any
15831585
identity inside the guest, so guest root and a compromised guest kernel can act

0 commit comments

Comments
 (0)