-
Notifications
You must be signed in to change notification settings - Fork 787
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
apparmor: build/run: net ns permission denied with pasta #5440
Comments
As far as I know, this is specific to openSUSE, see also https://bugzilla.suse.com/show_bug.cgi?id=1221840#c6 -- this part works with Debian because of https://salsa.debian.org/sbrivio/passt/-/commit/5bb812e79143670a57440cd8aa7f2979583c5a0a. What's missing, also for Debian and Ubuntu, is something like |
Any idea on fixing this? I can't update any of my podman containers? |
Adding |
@dylangerdaly if you're hitting this on openSUSE, see https://bugzilla.suse.com/show_bug.cgi?id=1221840#c6 -- I'm waiting on an answer to that. If you're hitting a similar issue on another distribution, please describe it. |
@Luap99 PTAL |
@rhatdan @Luap99 just to be clear, this isn't in any way an issue with Podman or Buildah themselves. Summary of my current understanding:
|
@sbrivio-rh; responded on bugzilla but I still seem to be running into the same issue unless of course, I'm missing something. So, to be clear, you're suggesting a two-way fix that creates a hard link (instead of a sym) for pasta targeted to passt. Additionally, we also need to modify the AppArmor profiles for both usr.bin.pasta and usr.bin.passt? Am I understanding this correctly? |
That will be needed, yes.
That too, but the one we ship upstream for usr.bin.pasta is anyway causing issues now, so let me fix that first. |
This should do the trick. |
As mentioned on the podman issue containers/podman#22168 (comment) I do not think it is realistic to have the profile to limit it to certain paths. XDG_RUNTIME_DIR and so on are configurable to use different paths so assuming only defaults are ever used is wrong IMO. I don't think it is helpful to force every user who likes to use a different path to edit their profile but again I know nothing about apparmor and if that stuff is common or if their are proper solutions for stuff like this. I can properly document the paths we will choose today but nothing changes the fact that the base paths are configurable by users and cannot assumed to be static. I guess the same kind of issue applies to the pasta options --pcap, --log-file and --pid as it can take any path as arg. |
Also if pasta is so worried about allowing it to open all kind of paths maybe using landlock could be an option to add "dynamic" rules at runtime to block all paths besides the ones it got as arguments then it wouldn't need to rely only on selinux/apparmor to block these. |
Mind that AppArmor profiles are usually considered configuration matter by distributions. For example, on Debian, if you delete This isn't a clear-cut issue, but in general, the established practice with SELinux and AppArmor policies in distributions is to cover paths that are used by default, or commonly.
I understand, but it's also reasonable to assume that if users configure base paths to values that are not the default on their distribution, they might have to adjust rules in their Linux Security Module policy. Is there some other path I missed in the policies?
Definitely, it does, and there it's even worse in some sense as there's no default path for stand-alone usage. For libvirt, we cover For stand-alone usage, we assume the user will use their home directory, or
The added value of AppArmor and SELinux here is that they are external components, so they would be unaffected in case of arbitrary code execution in the initial stages. In this sense, I don't think Landlock would give us much of an advantage as passt and pasta anyway remount their |
If we assume defaults I think they are fine now after the rootless-netns change so that should be good. Although I do not see any patch on the passt ML for this ( If this is something that should not be added to the pasta profile but rather some podman/buildah profile then we can do it as well but this is not something podman/buildah maintainers can figure out. However I am open to include such a profile upstream in our repo if that is contributed by someone so that all apparmor distros could use it from here.
Right I guess that should be sufficient then. |
Also I am going to close this one as the root issue seems to be the incorrect apparmor setup in opensuse and not a upstream bug at all but we continue the conversation. |
Right, I haven't posted that yet, I was waiting for a conclusion on https://bugzilla.suse.com/show_bug.cgi?id=1221840 first.
Oh, I forgot about that, thanks for pointing it out.
Ideally yes, but:
...that's not really a simple profile to write, so I would fix this up anyway in pasta's profile for the moment being. |
…tion For the policy to work as expected across either AppArmor commit 9d3f8c6cc05d ("parser: fix parsing of source as mount point for propagation type flags") and commit 300889c3a4b7 ("parser: fix option flag processing for single conditional rules"), we need one mount rule with matching mount options as "source" (that is, without source), and one without mount options and an explicit, empty source. Link: containers/buildah#5440 Link: https://bugzilla.suse.com/show_bug.cgi?id=1221840 Signed-off-by: Stefano Brivio <[email protected]>
… too With Podman's custom networks, pasta will typically need to open the target network namespace at /run/user/<UID>/containers/networks: grant access to anything under /run/user/<UID> instead of limiting it to some subpath. Note that in this case, Podman will need pasta to write out a PID file, so we need write access, for similar locations, too. Reported-by: Jörg Sonnenberger <[email protected]> Link: containers/buildah#5440 Link: https://bugzilla.suse.com/show_bug.cgi?id=1221840 Signed-off-by: Stefano Brivio <[email protected]>
From an original patch by Danish Prakash. With commit ff22a78 ("pasta: Don't try to watch namespaces in procfs with inotify, use timer instead"), if a filesystem-bound target namespace is passed on the command line, we'll grab a handle on its parent directory. That commit, however, didn't introduce a matching AppArmor rule. Add it here. To access a network namespace procfs entry, we also need a 'ptrace' rule. See commit 594dce6 ("isolation: keep CAP_SYS_PTRACE when required") for details as to when we need this -- essentially, it's about operation with Buildah. Reported-by: Jörg Sonnenberger <[email protected]> Link: containers/buildah#5440 Link: https://bugzilla.suse.com/show_bug.cgi?id=1221840 Fixes: ff22a78 ("pasta: Don't try to watch namespaces in procfs with inotify, use timer instead") Signed-off-by: Stefano Brivio <[email protected]>
Description
Buildah build fails with a permission denied error on the network namespace with pasta as the rootless networking backend. Folks have had success with modifying AppArmor rules (https://bugzilla.suse.com/show_bug.cgi?id=1221840#c3).
This problem arose with the switch to pasta as the default rootless networking mode. Upon switching to slirp4netns in containers.conf, everything works as expected.
Steps to reproduce the issue:
Describe the results you received:
Describe the results you expected:
Build to complete successfully as it does currently if I switch to slirp4netns.
Output of
rpm -q buildah
orapt list buildah
:Output of
buildah version
:Output of
cat /etc/*release
:Output of
uname -a
:Output of
cat /etc/containers/storage.conf
:The text was updated successfully, but these errors were encountered: