Conversation
| fallback_fdinfo: | ||
| r = fd_fdinfo_mnt_id(fd, filename, flags, &mount_id); | ||
| if (r == -EOPNOTSUPP) | ||
| if (IN_SET(r, -EOPNOTSUPP, -EACCES)) |
There was a problem hiding this comment.
I get open("/proc/self/fdinfo/13", O_RDONLY|O_CLOEXEC) = -1 EACCES (Permission denied)
327 mkdir("/proc", 0755 <unfinished ...>
327 <... mkdir resumed> ) = -1 EEXIST (File exists)
327 stat("/proc", <unfinished ...>
327 <... stat resumed> {st_dev=makedev(8, 1), st_ino=28585, st_mode=S_IFDIR|0755, st_nlink=2, st_uid=0, st_gid=0, st_blksize=1024, st_blocks=4, st_size=1024, st_atime=2016/10/14-02:55:32, st_mtime=2016/
327 mount("proc", "/proc", "proc", MS_NOSUID|MS_NODEV|MS_NOEXEC, NULL <unfinished ...>
327 <... mount resumed> ) = 0
327 lstat("/proc", <unfinished ...>
327 <... lstat resumed> {st_dev=makedev(0, 34), st_ino=1, st_mode=S_IFDIR|0555, st_nlink=75, st_uid=65534, st_gid=65534, st_blksize=1024, st_blocks=0, st_size=0, st_atime=2016/10/14-03:13:35.971031263,
327 lstat("/proc/sys", {st_dev=makedev(0, 34), st_ino=4026531855, st_mode=S_IFDIR|0555, st_nlink=1, st_uid=65534, st_gid=65534, st_blksize=1024, st_blocks=0, st_size=0, st_atime=2016/10/14-03:13:39.1630
327 openat(AT_FDCWD, "/proc", O_RDONLY|O_DIRECTORY|O_CLOEXEC|O_PATH) = 11</proc>
327 name_to_handle_at(11</proc>, "sys", {handle_bytes=128}, 0x7ffe3a238604, AT_SYMLINK_FOLLOW) = -1 EOPNOTSUPP (Operation not supported)
327 name_to_handle_at(11</proc>, "", {handle_bytes=128}, 0x7ffe3a238608, AT_EMPTY_PATH) = -1 EOPNOTSUPP (Operation not supported)
327 openat(11</proc>, "sys", O_RDONLY|O_CLOEXEC|O_PATH) = 13</proc/sys>
327 open("/proc/self/fdinfo/13", O_RDONLY|O_CLOEXEC) = -1 EACCES (Permission denied)
327 close(13</proc/sys> <unfinished ...>
327 <... close resumed> ) = 0
327 close(11</proc> <unfinished ...>
327 <... close resumed> ) = 0
-bash-4.3# ls -ld /proc/
dr-xr-xr-x 76 65534 65534 0 Oct 14 02:57 /proc/
-bash-4.3# ls -ld /proc/1
dr-xr-xr-x 9 root root 0 Oct 14 02:57 /proc/1
-bash-4.3# ls -ld /proc/1/fdinfo
dr-x------ 2 65534 65534 0 Oct 14 03:00 /proc/1/fdinfoAnd I'm not sure how to properly fix this.
@tixxdz , any ideas?
minimal reproducer: https://gist.github.com/evverx/ab5cdc72545b6c9033cfc8336dbca66f/fac7e6fbe05c743b1a832cd006406b727b03bd14#file-ns_child-c
how to run/output: https://gist.github.com/evverx/ab5cdc72545b6c9033cfc8336dbca66f/fac7e6fbe05c743b1a832cd006406b727b03bd14#file-how_to_run-md
| } | ||
| } | ||
|
|
||
| r = reset_uid_gid(); |
There was a problem hiding this comment.
|
|
@martinpitt , does the testbed support unified cgroup hierarchy? |
|
I've reproduced:
hm, wtf? :-) |
Partially I suppose -- it's running on kernel 4.4 (Ubuntu 16.04 LTS), so I'm sure there are some recent cgroupv2 features missing. We have a policy to support ≤ 2 years old kernels, so I think running tests on kernel 4.4 is useful. We can of course add tests on Ubuntu 16.10 (kernel 4.8), or maybe move the i386 one to that, so that we have more variation wrt. kernel and plumbing packages. |
|
@martinpitt , thanks!
Totally agree.
It would be great! Anyway, I've found a bug.
|
|
I started an amd64 and i386 test on Ubuntu 16.10 ("yakkety"), let's see how that goes. |
|
@martinpitt , thanks! |
|
@evverx Yep, this fixes But, sorry to sound like a scratched record, please split your commit into two! |
Basically, this test runs:
```
systemd-nspawn --register=no -D "$_root" -b
systemd-nspawn --register=no -D "$_root" --private-network -b
systemd-nspawn --register=no -D "$_root" -U -b
systemd-nspawn --register=no -D "$_root" --private-network -U -b
```
and exports the `UNIFIED_CGROUP_HIERARCHY=[yes|no]`, `SYSTEMD_NSPAWN_USE_CGNS=[yes|no]`
Inspired by
* systemd#3589 (comment)
* systemd#4372 (comment)
* systemd#4223 (comment)
* systemd#1555
and so on :-)
|
@evverx so what the status here? You said you'd add more comments (and maybe split the commit in two)… |
I'm trying to fix broken stuff. Sadly, every new fix breaks some other stuff. This is why I wrote the
Oh, I've added comments:
Updated the PR description.
Yes, I'll beautify this PR later. I want to fix all issues first. |
Basically, this test runs:
```
systemd-nspawn --register=no -D "$_root" -b
systemd-nspawn --register=no -D "$_root" --private-network -b
systemd-nspawn --register=no -D "$_root" -U -b
systemd-nspawn --register=no -D "$_root" --private-network -U -b
```
and exports the `UNIFIED_CGROUP_HIERARCHY=[yes|no]`, `SYSTEMD_NSPAWN_USE_CGNS=[yes|no]`
Inspired by
* systemd#3589 (comment)
* systemd#4372 (comment)
* systemd#4223 (comment)
* systemd#1555
and so on :-)
669c66c to
00b9419
Compare
|
@keszybz , updated Marked as "need-rework": I should split the commit into three @martinpitt , this commit fixes: I guess we should run tests on Ubuntu 16.10 (just to be sure :-)) |
|
Oh, I didn't push the commit "tests: remove an expected failure check in test-nspawn-smoke". Will do |
Sure, please let me know once you have the PR ready; our infra is fairly loaded right now, so I don't want to start unnecessary test runs. |
|
@martinpitt , OK So, @keszybz , does this PR work for you (and looks reasonable)?
|
systemd#4352 has been fixed So, we don't need this workaround anymore
keszybz
left a comment
There was a problem hiding this comment.
Looks good, apart from one return value mixup.
src/nspawn/nspawn-mount.c
Outdated
| if (!in_userns) { | ||
| r = lchown(path, uid_shift, uid_shift); | ||
| if (r < 0) | ||
| return r; |
| r = mkdir_userns(t, mode, in_userns, uid_shift); | ||
| if (r < 0) | ||
| return r; | ||
| } |
There was a problem hiding this comment.
This feels overly complex, but I don't see an easy way to simplify.
There was a problem hiding this comment.
Would it be possible to use normal mkdir_p and then chown in a loop?
There was a problem hiding this comment.
That's posible. But:
- we should traverse the subtree twice
- we should split the
pathinto components twice
Also, I think mkdir and chown is simpler to understand.
Anyway, I'm not sure what is the right solution (I don't like that mkdir_p_internal-copy-pasta too)
@keszybz , @poettering , what do you think?
There was a problem hiding this comment.
We can always prettify the function later, so I'd just leave the current implementation.
00b9419 to
90e2231
Compare
|
@keszybz , updated @martinpitt , I think this PR is ready. And we can start tests on Ubuntu 16.10 |
…f/fdinfo #4372 (comment): I get `open("/proc/self/fdinfo/13", O_RDONLY|O_CLOEXEC) = -1 EACCES (Permission denied)` 327 mkdir("/proc", 0755 <unfinished ...> 327 <... mkdir resumed> ) = -1 EEXIST (File exists) 327 stat("/proc", <unfinished ...> 327 <... stat resumed> {st_dev=makedev(8, 1), st_ino=28585, st_mode=S_IFDIR|0755, st_nlink=2, st_uid=0, st_gid=0, st_blksize=1024, st_blocks=4, st_size=1024, st_atime=2016/10/14-02:55:32, st_mtime=2016/ 327 mount("proc", "/proc", "proc", MS_NOSUID|MS_NODEV|MS_NOEXEC, NULL <unfinished ...> 327 <... mount resumed> ) = 0 327 lstat("/proc", <unfinished ...> 327 <... lstat resumed> {st_dev=makedev(0, 34), st_ino=1, st_mode=S_IFDIR|0555, st_nlink=75, st_uid=65534, st_gid=65534, st_blksize=1024, st_blocks=0, st_size=0, st_atime=2016/10/14-03:13:35.971031263, 327 lstat("/proc/sys", {st_dev=makedev(0, 34), st_ino=4026531855, st_mode=S_IFDIR|0555, st_nlink=1, st_uid=65534, st_gid=65534, st_blksize=1024, st_blocks=0, st_size=0, st_atime=2016/10/14-03:13:39.1630 327 openat(AT_FDCWD, "/proc", O_RDONLY|O_DIRECTORY|O_CLOEXEC|O_PATH) = 11</proc> 327 name_to_handle_at(11</proc>, "sys", {handle_bytes=128}, 0x7ffe3a238604, AT_SYMLINK_FOLLOW) = -1 EOPNOTSUPP (Operation not supported) 327 name_to_handle_at(11</proc>, "", {handle_bytes=128}, 0x7ffe3a238608, AT_EMPTY_PATH) = -1 EOPNOTSUPP (Operation not supported) 327 openat(11</proc>, "sys", O_RDONLY|O_CLOEXEC|O_PATH) = 13</proc/sys> 327 open("/proc/self/fdinfo/13", O_RDONLY|O_CLOEXEC) = -1 EACCES (Permission denied) 327 close(13</proc/sys> <unfinished ...> 327 <... close resumed> ) = 0 327 close(11</proc> <unfinished ...> 327 <... close resumed> ) = 0 -bash-4.3# ls -ld /proc/ dr-xr-xr-x 76 65534 65534 0 Oct 14 02:57 /proc/ -bash-4.3# ls -ld /proc/1 dr-xr-xr-x 9 root root 0 Oct 14 02:57 /proc/1 -bash-4.3# ls -ld /proc/1/fdinfo dr-x------ 2 65534 65534 0 Oct 14 03:00 /proc/1/fdinfo
#4372 (comment): * `mount_all (outer_child)` creates `container_dir/sys/fs/selinux` * `mount_all (outer_child)` doesn't patch `container_dir/sys/fs` and so on. * `mount_sysfs (inner_child)` tries to create `/sys/fs/cgroup` * This fails 370 stat("/sys/fs", {st_dev=makedev(0, 28), st_ino=13880, st_mode=S_IFDIR|0755, st_nlink=3, st_uid=65534, st_gid=65534, st_blksize=4096, st_blocks=0, st_size=60, st_atime=2016/10/14-05:16:43.398665943, st_mtime=2016/10/14-05:16:43.399665943, st_ctime=2016/10/14-05:16:43.399665943}) = 0 370 mkdir("/sys/fs/cgroup", 0755) = -1 EACCES (Permission denied) * `mount_syfs (inner_child)` ignores that error and mount(NULL, "/sys", NULL, MS_RDONLY|MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_REMOUNT|MS_BIND, NULL) = 0 * `mount_cgroups` finally fails
|
I hate commit messages which have no content, only a github discussion link. I now went through your commits and pasted (what I thought is) the relevant part from each link. For the sake of my blood pressure, please add real commit messages in the future ;) I don't quite believe github discussion links will be available in 5 years when somebody is hunting some bug and trying to understand why is the way it is. So... indeed #4352 is fixed with this PR, and everything seems functional. Merging. Thanks. |
@keszybz , thanks!
Well, I agree. But I hate my English too :-) Feel free to suggest the contents. Thanks! |
…f/fdinfo systemd/systemd#4372 (comment): I get `open("/proc/self/fdinfo/13", O_RDONLY|O_CLOEXEC) = -1 EACCES (Permission denied)` 327 mkdir("/proc", 0755 <unfinished ...> 327 <... mkdir resumed> ) = -1 EEXIST (File exists) 327 stat("/proc", <unfinished ...> 327 <... stat resumed> {st_dev=makedev(8, 1), st_ino=28585, st_mode=S_IFDIR|0755, st_nlink=2, st_uid=0, st_gid=0, st_blksize=1024, st_blocks=4, st_size=1024, st_atime=2016/10/14-02:55:32, st_mtime=2016/ 327 mount("proc", "/proc", "proc", MS_NOSUID|MS_NODEV|MS_NOEXEC, NULL <unfinished ...> 327 <... mount resumed> ) = 0 327 lstat("/proc", <unfinished ...> 327 <... lstat resumed> {st_dev=makedev(0, 34), st_ino=1, st_mode=S_IFDIR|0555, st_nlink=75, st_uid=65534, st_gid=65534, st_blksize=1024, st_blocks=0, st_size=0, st_atime=2016/10/14-03:13:35.971031263, 327 lstat("/proc/sys", {st_dev=makedev(0, 34), st_ino=4026531855, st_mode=S_IFDIR|0555, st_nlink=1, st_uid=65534, st_gid=65534, st_blksize=1024, st_blocks=0, st_size=0, st_atime=2016/10/14-03:13:39.1630 327 openat(AT_FDCWD, "/proc", O_RDONLY|O_DIRECTORY|O_CLOEXEC|O_PATH) = 11</proc> 327 name_to_handle_at(11</proc>, "sys", {handle_bytes=128}, 0x7ffe3a238604, AT_SYMLINK_FOLLOW) = -1 EOPNOTSUPP (Operation not supported) 327 name_to_handle_at(11</proc>, "", {handle_bytes=128}, 0x7ffe3a238608, AT_EMPTY_PATH) = -1 EOPNOTSUPP (Operation not supported) 327 openat(11</proc>, "sys", O_RDONLY|O_CLOEXEC|O_PATH) = 13</proc/sys> 327 open("/proc/self/fdinfo/13", O_RDONLY|O_CLOEXEC) = -1 EACCES (Permission denied) 327 close(13</proc/sys> <unfinished ...> 327 <... close resumed> ) = 0 327 close(11</proc> <unfinished ...> 327 <... close resumed> ) = 0 -bash-4.3# ls -ld /proc/ dr-xr-xr-x 76 65534 65534 0 Oct 14 02:57 /proc/ -bash-4.3# ls -ld /proc/1 dr-xr-xr-x 9 root root 0 Oct 14 02:57 /proc/1 -bash-4.3# ls -ld /proc/1/fdinfo dr-x------ 2 65534 65534 0 Oct 14 03:00 /proc/1/fdinfo (cherry picked from commit 548bd57)
Fixes: #4352
I'll add some comments later.I've added some comments:
@keszybz , please, try this patch. I've tested:
4.7.6-200.fc244.8