Commit 891fa32
authored
fix(vfs): use caller fs root for pivot_root (#2130)
* fix(vfs): use caller fs root for pivot_root
Resolve and pin the caller fs root, new_root, and put_old as mount-aware paths so pivot_root follows Linux object identity and reachability semantics after chroot.
Serialize task publication with exact root/pwd migration, keep mount and dentry topology under one guard, and pre-reserve all edge and task-tracking capacity before the infallible commit. Preserve stacked mount ordering and Linux errno precedence without visible-path approximations.
Add focused dunitests for chrooted pivots, namespace-root failures, cross-process fs reference updates, stacked mounts, symlink and bind aliases, and unrelated upper mounts.
Tests: make kernel
Tests: test_pivot_root_test (20/20)
Tests: mount_object_topology_test (9/9)
Tests: mount_move_test (11/11)
Tests: mount_propagation_test (24/24)
Signed-off-by: longjin <longjin@dragonos.org>
* fix(vfs): address pivot_root review races
Restore the namespace-root pivot path while preserving DragonOS mount namespace invariants and publish the replacement root only after the topology commit is complete.
Serialize fs_struct copying and publication against pivot_root migration with a reader-writer barrier covering fork, unshare, setns, and exec namespace switches.
Extend pivot_root coverage to verify the standard namespace-root operation and the old-root attachment.
Signed-off-by: longjin <longjin@dragonos.org>
* test(vfs): cover shared namespace root pivot
Distinguish the caller's shared root mount from the private parent of the new root, matching Linux pivot_root propagation checks.
Keep markers on both the replacement root and the relocated old root so the test also verifies the committed topology.
Signed-off-by: longjin <longjin@dragonos.org>
* fix(process): release fs slot before cleanup
Clear the exiting task's filesystem slot under its update lock, then release the lock before dropping the final FsStruct owner.
This matches Linux exit_fs lifetime ordering and keeps path-pin and mount lifecycle cleanup outside the pivot_root slot critical section.
Signed-off-by: longjin <longjin@dragonos.org>
* fix(vfs): avoid pivot_root lock inversion
Acquire every dentry mount gate touched by pivot_root before taking the dentry topology snapshot. Sort and deduplicate the fixed gate set, and require an unforgeable commit token for prelocked mount-edge operations so the canonical order is enforced by the API.
Revalidate namespace membership, exact mount roots, connectivity, propagation constraints, and path reachability only after lifecycle, namespace, gate, and dentry locks are held. Keep all fallible reservations before the first edge mutation and preserve the topology guard across fs reference repair.
This removes the ABBA cycle with unlink, rmdir, and rename, which acquire mount gates before the dentry topology writer.
Signed-off-by: longjin <longjin@dragonos.org>
* style(vfs): satisfy repository format checks
Apply the repository rustfmt layout and remove a needless borrow reported by the deny-by-default clippy configuration.
Signed-off-by: longjin <longjin@dragonos.org>
* perf(process): narrow fork fs publication barrier
Complete signal, address-space, architecture, and metadata copies before entering the fs reference publication barrier. Keep copy_fs and copy_namespaces adjacent, and retain the read guard through namespace-dependent PID setup and final PCB publication.
Release the guard immediately after add_pcb so pivot_root still observes every copied fs_struct without making unrelated cgroup accounting and fork counters part of the global critical section.
Signed-off-by: longjin <longjin@dragonos.org>
---------
Signed-off-by: longjin <longjin@dragonos.org>1 parent c6808a8 commit 891fa32
14 files changed
Lines changed: 1169 additions & 340 deletions
File tree
- kernel/src
- filesystem
- vfs
- mount
- syscall
- process
- manager
- namespace
- user/apps/tests/dunitest/suites/normal
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
169 | 196 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
135 | 143 | | |
136 | 144 | | |
137 | 145 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
61 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
| |||
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
72 | 196 | | |
73 | 197 | | |
74 | 198 | | |
| |||
98 | 222 | | |
99 | 223 | | |
100 | 224 | | |
101 | | - | |
102 | | - | |
| 225 | + | |
103 | 226 | | |
104 | 227 | | |
105 | 228 | | |
| |||
1271 | 1394 | | |
1272 | 1395 | | |
1273 | 1396 | | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
1274 | 1411 | | |
1275 | 1412 | | |
1276 | 1413 | | |
1277 | 1414 | | |
1278 | 1415 | | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
| 1419 | + | |
| 1420 | + | |
| 1421 | + | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
| 1425 | + | |
1279 | 1426 | | |
1280 | 1427 | | |
1281 | 1428 | | |
| |||
1287 | 1434 | | |
1288 | 1435 | | |
1289 | 1436 | | |
1290 | | - | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
1291 | 1446 | | |
1292 | 1447 | | |
1293 | 1448 | | |
| |||
1554 | 1709 | | |
1555 | 1710 | | |
1556 | 1711 | | |
1557 | | - | |
| 1712 | + | |
1558 | 1713 | | |
1559 | 1714 | | |
1560 | 1715 | | |
| |||
1571 | 1726 | | |
1572 | 1727 | | |
1573 | 1728 | | |
1574 | | - | |
| 1729 | + | |
1575 | 1730 | | |
1576 | 1731 | | |
1577 | 1732 | | |
1578 | 1733 | | |
1579 | 1734 | | |
| 1735 | + | |
| 1736 | + | |
| 1737 | + | |
| 1738 | + | |
| 1739 | + | |
| 1740 | + | |
| 1741 | + | |
| 1742 | + | |
| 1743 | + | |
| 1744 | + | |
| 1745 | + | |
| 1746 | + | |
| 1747 | + | |
| 1748 | + | |
| 1749 | + | |
| 1750 | + | |
| 1751 | + | |
| 1752 | + | |
| 1753 | + | |
| 1754 | + | |
| 1755 | + | |
| 1756 | + | |
| 1757 | + | |
| 1758 | + | |
1580 | 1759 | | |
1581 | 1760 | | |
1582 | 1761 | | |
1583 | 1762 | | |
1584 | | - | |
| 1763 | + | |
1585 | 1764 | | |
1586 | 1765 | | |
1587 | 1766 | | |
1588 | | - | |
1589 | 1767 | | |
1590 | 1768 | | |
1591 | 1769 | | |
| |||
1602 | 1780 | | |
1603 | 1781 | | |
1604 | 1782 | | |
| 1783 | + | |
| 1784 | + | |
| 1785 | + | |
| 1786 | + | |
| 1787 | + | |
| 1788 | + | |
| 1789 | + | |
| 1790 | + | |
| 1791 | + | |
| 1792 | + | |
| 1793 | + | |
| 1794 | + | |
| 1795 | + | |
| 1796 | + | |
| 1797 | + | |
| 1798 | + | |
| 1799 | + | |
| 1800 | + | |
| 1801 | + | |
| 1802 | + | |
| 1803 | + | |
| 1804 | + | |
1605 | 1805 | | |
1606 | 1806 | | |
1607 | 1807 | | |
1608 | | - | |
1609 | 1808 | | |
1610 | 1809 | | |
1611 | 1810 | | |
| |||
2279 | 2478 | | |
2280 | 2479 | | |
2281 | 2480 | | |
2282 | | - | |
2283 | 2481 | | |
2284 | 2482 | | |
2285 | | - | |
| 2483 | + | |
2286 | 2484 | | |
2287 | 2485 | | |
2288 | 2486 | | |
2289 | 2487 | | |
2290 | 2488 | | |
2291 | 2489 | | |
2292 | | - | |
| 2490 | + | |
| 2491 | + | |
| 2492 | + | |
2293 | 2493 | | |
2294 | 2494 | | |
2295 | 2495 | | |
| |||
2710 | 2910 | | |
2711 | 2911 | | |
2712 | 2912 | | |
| 2913 | + | |
| 2914 | + | |
| 2915 | + | |
| 2916 | + | |
| 2917 | + | |
| 2918 | + | |
| 2919 | + | |
| 2920 | + | |
| 2921 | + | |
2713 | 2922 | | |
2714 | 2923 | | |
2715 | 2924 | | |
| |||
0 commit comments