-
Notifications
You must be signed in to change notification settings - Fork 324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
linux: honor mount-label for the notify socket #419
Conversation
LGTM |
Better - I can now see the directory and socket file - but systemd-notify still doesn't work: $ NOTIFY_SOCKET=/tmp/podman-sdnotify/notify ./bin/podman run --rm --sdnotify=container fedora sh -c 'systemd-notify --ready'
Failed to notify init system: Permission denied AVC is now:
|
@rhatdan how can we address this issue? Should we allow writing to the socket? |
@giuseppe It doesn't look like JUST a label problem... You're actually clobbering the /run tmpfs mount.
Gives me
So yes, the label ends up being wrong... but it's wrong on /run which breaks everything |
Context - my NOTIFY_SOCKET is /run/notifytest |
@edsantiago @giuseppe
NOTIFY_SOCKET=/tmp/podman-sdnotify/notify
Also note my scontext is coming in as container_init_t instead of container_t... I'm on Fedora CoreOS. @edsantiago does it work for you if you use /run instead of tmp? |
I've been banging my head against this, with and without crun, I'm just unsure why
|
Nope: $ sudo env NOTIFY_SOCKET=/run/aaa/sock ./bin/podman run --rm --sdnotify=container fedora sh -c 'ls -lZ /run/aaa'
ls: cannot open directory '/run/aaa': Permission denied Without enforcing:
|
@edsantiago can you do 'ps -Z 1; ls -lZ /; ls -lZ /run; ls -lZ /run/aaa' |
TIL there's no
In host:
|
oh yeah right |
Well I answered one of my questions.. --systemd=always changes the label from container_t to container_init_t |
Glad you got it. |
Do this in another terminal window:
Note, I get the same permission denied errors with podman compiled from master, without the --sdnotify branch. |
Sure, thanks for your help! |
I think this: Should be allowing it... |
d330222
to
1a53815
Compare
thanks for debugging it. The NOTIFY_SOCKET implementation really looked only at what systemd passes in but it would break with a generic path. I've added another patch now, so the socket is created one level below. Could you please check if it works for you now? |
This AVC will still not be allowed. Not sure if it should, this looks like podman did not have the correct label on it. |
With this PR the notify socket will get the same label as the container instead of "unconfined". |
@goochjj does the current version look good to you? I've still marked it as draft, I'll wait for your review before merging |
Nope...
Using /run/notify/notify, it works better.. ENV gets set to /run/notify/notify/notify, and /run/notify/notify/notify is labeled...
And yes this FCOS machine is using container-selinux 2.132.0 which I guess doesn't work per rhatdan as far as the sendto bits. I don't think you need to preserve their NOTIFY_SOCKET value at all. You could always mount it to /run/notify/notify.sock or something, and just set the ENV variable appropriately, rather than doing parsing and trying to decide on a convention. If you are going to do a convention what is it right now? |
Yeah w/ NOTIFY_SOCKET=/run/notify/notify.sock to podman
with the wrong label. |
the convention we have now is to create a directory at the specified I've fixed the issue you've reported but I am still seeing on Fedora 32:
|
0dbed09
to
fa6d316
Compare
Signed-off-by: Giuseppe Scrivano <[email protected]>
fa6d316
to
264b76a
Compare
The process creating the socket is not creating the socket with the correct label. |
src/libcrun/linux.c
Outdated
cleanup_free char *socket_path_file = NULL; | ||
xasprintf (&socket_path_file, "%s/notify", host_notify_socket_path); | ||
/* Ignore the error, the worse that can happen is that the container fails to notify it is ready. */ | ||
(void) setxattr (socket_path_file, "security.selinux", container->container_def->linux->mount_label, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setfscreatecon(container->container_def->linux->mount_label) Before creating the socket. Should use setfilecon() rather then calling setxattr directly.
264b76a
to
1eddc1d
Compare
the socket has the label:
sorry that was an error in my patch. I was testing with "crun run" but I forgot that podman uses create+start. It should be fixed now, and I get:
I've updated container-selinux to: https://bodhi.fedoraproject.org/updates/FEDORA-2020-e6bbbe262b |
Signed-off-by: Giuseppe Scrivano <[email protected]>
so there is no risk of overriding another existing mount. If NOTIFY_SOCKET=/run/foo/bar the notify socket will be mounted at /run/foo/bar/notify in the container. Signed-off-by: Giuseppe Scrivano <[email protected]>
1eddc1d
to
c04fd15
Compare
it works if I use 6b721daa0b9ff46a444e174995e5ac6600604db5 for container-selinux |
That should be allowed in latest policy. container-selinux-2.137.0-1.fc32.noarch |
Please update it's karma |
updated package: https://bodhi.fedoraproject.org/updates/FEDORA-2020-9ec7a517d4 |
@goochjj could you give it a last try? As soon as this PR is merged I'll prepare 0.14 |
checking |
Tested, selinux (w/ container-selinux 137) and without selinux, root and rootless, all clear. Thanks! |
@giuseppe LGTM |
@goochjj thanks for checking it out! |
@giuseppe are you planning to do a build? If so I'd like to try another one shortly thereafter, to include a |
Signed-off-by: Giuseppe Scrivano [email protected]