Allow rpmdb to manage files on mounted container filesystems#450
Allow rpmdb to manage files on mounted container filesystems#450lsm5 wants to merge 2 commits intocontainers:mainfrom
Conversation
We want to use the latest packages for test jobs on upstream CI jobs. Signed-off-by: Lokesh Mandvekar <lsm5@redhat.com>
Running `rpmdb --rebuilddb --root=<container-mount-path>` on a mounted
container filesystem fails with the following error when SELinux is
enforcing:
error: can't create transaction lock on
.../merged/var/lib/rpm/.rpm.lock (Permission denied)
The AVC denial is:
avc: denied { search } for comm="rpmdb"
scontext=unconfined_u:unconfined_r:rpmdb_t:s0-s0:c0.c1023
tcontext=system_u:object_r:container_var_lib_t:s0 tclass=dir
The rpmdb_t domain needs access to:
- container_var_lib_t dirs (to traverse /var/lib/containers/storage/)
- container_ro_file_t dirs/files (to traverse overlay directories)
- container_file_t dirs/files (to manage RPM database in the merged fs)
Additionally, rpmdb_t needs the object identity change exemption to
satisfy the UBAC constraint when creating files/dirs. Container
filesystems are created by the container runtime with user identity
system_u, but rpmdb is invoked from an unconfined user session
(unconfined_u). Without the exemption, the user identity mismatch
causes constraint violations on create operations. The map permission
on container_file_t files is also needed for sqlite shared memory
mapping during database operations.
Fixes: RHEL-58185
Signed-off-by: Lokesh Mandvekar <lsm5@redhat.com>
Reviewer's guide (collapsed on small PRs)Reviewer's GuideUpdates SELinux policy to allow the rpmdb_t domain to manage RPM database files on mounted container filesystems and extends the test plan to cover this behavior. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Code Review
This pull request introduces SELinux policy updates in container.te to allow rpmdb_t to manage container files and perform memory mapping. It also modifies the test plan in plans/main.fmf to include a package upgrade step during preparation. A review comment suggests explicitly including container_file_t in the gen_require block to ensure policy clarity and maintainability, as it is used directly in an allow rule.
| gen_require(` | ||
| type rpmdb_t; | ||
| ') |
There was a problem hiding this comment.
The container_file_t type is used directly in the allow rule on line 1188. While it is transitively required by the interfaces called within this block, it is better practice to explicitly include it in the gen_require block for clarity and to ensure the policy remains valid if the interfaces are refactored. This is consistent with how container_file_t is handled as an external type in other parts of this file (e.g., lines 943 and 1101).
gen_require(`
type rpmdb_t, container_file_t;
`)
|
Tests failed. @containers/packit-build please check. |
|
This policy change should go into selinux-policy not here. |
There seems to be precedent for |
|
Lets open this up for discussion with fedora/selinux-policy, to see what they want to do. |
Running
rpmdb --rebuilddb --root=<container-mount-path>on a mounted container filesystem fails with the following error when SELinux is enforcing:The AVC denial is:
The
rpmdb_tdomain needs access to:Additionally, rpmdb_t needs the object identity change exemption to satisfy the UBAC constraint when creating files/dirs. Container filesystems are created by the container runtime with user identity system_u, but rpmdb is invoked from an unconfined user session (unconfined_u). Without the exemption, the user identity mismatch causes constraint violations on create operations. The map permission on container_file_t files is also needed for sqlite shared memory mapping during database operations.
Fixes: RHEL-58185
Summary by Sourcery
Allow rpmdb to rebuild and manage RPM databases on mounted container filesystems under SELinux enforcement by granting appropriate SELinux permissions and exemptions to the rpmdb_t domain.
Bug Fixes:
Enhancements: