Skip to content
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

Allow smbd to load libcephfs proxy conditionally #2555

Open
wants to merge 1 commit into
base: rawhide
Choose a base branch
from

Conversation

anoopcs9
Copy link
Contributor

@anoopcs9 anoopcs9 commented Feb 4, 2025

The design for libcephfs proxy was accepted sometime back with the corresponding implementation subsequently merged into upstream Ceph. This additional way to integrate CephFS with Samba is comprised of two components. The daemon i.e, libcephfsd is responsible for creating the unix domain socket as a starting point of communication. On the other side proxy library, which is designed to be loaded within smbd, connects to the already created socket and thereby communicates with the daemon.

During the development and testing stages we happened to notice some AVC denial messages in the audit logs:

type=AVC msg=audit(1738236295.070:1470): avc: denied { write } for pid=41822 comm="smbd[192.168.12" name="libcephfsd.sock" dev="tmpfs" ino=1908 scontext=system_u:system_r:smbd_t:s0 tcontext=unconfined_u:object_r:var_run_t:s0 tclass=sock_file permissive=1

type=AVC msg=audit(1738236295.070:1470): avc: denied { connectto } for pid=41822 comm="smbd[192.168.12" path="/run/libcephfsd.sock" scontext=system_u:system_r:smbd_t:s0 tcontext=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 tclass=unix_stream_socket permissive=1

Therefore we propose a new boolean - samba_load_libcephfs_proxy, off by default, to contain the necessary allow rules for smbd_t to operate in a proxy mode using libcephfs.

anoopcs9 added a commit to anoopcs9/sit-environment that referenced this pull request Feb 4, 2025
For the time being, until the official fix[1] is available with standard
selinux-policy packages, compile and insert a local SELinux policy to
allow smbd to connect via unix stream sockets for proper fucntioning of
libcephfs proxy. Refer comments from [2] for more details.

[1] fedora-selinux/selinux-policy#2555
[2] samba-in-kubernetes#128

Signed-off-by: Anoop C S <anoopcs@cryptolab.net>
The design for libcephfs proxy[1] was accepted sometime back with the
corresponding implementation subsequently merged[2] into upstream Ceph.
This additional way to integrate CephFS with Samba is comprised of two
components. The daemon i.e, libcephfsd is responsible for creating the
unix domain socket as a starting point of communication. On the other
side proxy library, which is designed[3] to be loaded within smbd,
connects to the already created socket and thereby communicates with
the daemon.

During the development and testing stages we happened to notice some AVC
denial messages in the audit logs:

type=AVC msg=audit(1738236295.070:1470): avc: denied { write } for pid=41822
  comm="smbd[192.168.12" name="libcephfsd.sock" dev="tmpfs" ino=1908
  scontext=system_u:system_r:smbd_t:s0 tcontext=unconfined_u:object_r:var_run_t:s0
  tclass=sock_file permissive=1

type=AVC msg=audit(1738236295.070:1470): avc: denied { connectto } for pid=41822
  comm="smbd[192.168.12" path="/run/libcephfsd.sock"
  scontext=system_u:system_r:smbd_t:s0 tcontext=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
  tclass=unix_stream_socket permissive=1

Therefore we propose a new boolean - samba_load_libcephfs_proxy, off by
default, to contain the necessary allow rules for smbd_t to operate in a
proxy mode using libcephfs.

[1] https://docs.ceph.com/en/latest/dev/libcephfs_proxy/
[2] ceph/ceph#58376
[3] https://gitlab.com/samba-team/samba/-/merge_requests/3792

Signed-off-by: Anoop C S <anoopcs@cryptolab.net>
@anoopcs9 anoopcs9 force-pushed the smbd-load-cephfs-proxy-bool branch from 444f306 to 2aa8f77 Compare February 4, 2025 15:12
anoopcs9 added a commit to samba-in-kubernetes/sit-environment that referenced this pull request Feb 5, 2025
For the time being, until the official fix[1] is available with standard
selinux-policy packages, compile and insert a local SELinux policy to
allow smbd to connect via unix stream sockets for proper fucntioning of
libcephfs proxy. Refer comments from [2] for more details.

[1] fedora-selinux/selinux-policy#2555
[2] #128

Signed-off-by: Anoop C S <anoopcs@cryptolab.net>
@anoopcs9
Copy link
Contributor Author

@zpytela I hope rpm-build:fedora-41-x86_64 job failure is expected.

@anoopcs9
Copy link
Contributor Author

@zpytela Can you please take a look at this change?

optional_policy(`
tunable_policy(`samba_load_libcephfs_proxy',`
unconfined_stream_connect(smbd_t)
rw_sock_files_pattern(smbd_t, var_run_t, var_run_t)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which service creates and/or works with files with the var_run_t type? A private type should be used in cases of allowing write access.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants