Commit 16b45c8
committed
rootfs: make pivot_root(2) dance handle initramfs case
While pivot_root(2) normally refuses to pivot a mount if you are running
with / as initramfs (because initramfs doesn't have a parent mount), you
can create a bind-mount and make that a new root to work around this
problem.
This hack is fairly well known and is used all over the place (see
[1,2]) but until now we have forced users to have a far less secure
configuration with --no-pivot. There are some minor issues with this
trick (the initramfs sticks around at the top of the mount tree, but is
completely masked) but they don't really matter for containers.
[1]: containers/bubblewrap#592 (comment)
[2]: https://aconz2.github.io/2024/07/29/container-from-initramfs.html
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>1 parent 9112335 commit 16b45c8
1 file changed
+31
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1079 | 1079 | | |
1080 | 1080 | | |
1081 | 1081 | | |
1082 | | - | |
1083 | | - | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
1084 | 1113 | | |
1085 | 1114 | | |
1086 | 1115 | | |
| |||
0 commit comments