Bug 2584565
| Summary: | sshd_session_t denied read on home_root_t, breaking SSH agent forwarding | ||
|---|---|---|---|
| Product: | [Fedora] Fedora | Reporter: | Vadym Chepkov <vchepkov> |
| Component: | selinux-policy | Assignee: | Zdenek Pytela <zpytela> |
| Status: | ASSIGNED --- | QA Contact: | Fedora Extras Quality Assurance <extras-qa> |
| Severity: | medium | Docs Contact: | |
| Priority: | unspecified | ||
| Version: | 45 | CC: | 50bda1cd2babf798, dbelyavs, dwalsh, lvrabec, mmalik, omosnacek, pkoncity, ramercer, thomas, ultrafilter, vchepkov, vmojzis, zpytela |
| Target Milestone: | --- | Flags: | zpytela:
needinfo?
(dbelyavs) |
| Target Release: | --- | ||
| Hardware: | Unspecified | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | --- | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | Type: | --- | |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
(In reply to Vadym Chepkov from comment #0) > Additional Information: > ~/.ssh/agent already exists, labeled ssh_home_t. sshd_session_t appears to > need > read on home_root_t directories to traverse to ~/.ssh/agent. > Hosts on openssh-server 9.9 with the same setup are not affected. Thanks for the report, either an effect of some new openssh version or specific configuration. Fordirectory traversing, the search permission which is allowed is sufficient. I don't quite understand why it needs to read the content of /home. If this helps, this started to fail after upgrading from openssh-server-0:10.5p1-1.fc45.x86_64 to openssh-server-0:10.6p1-1.fc45.x86_64 Thanks for the confirmation, I now read openssh changelog on regular basis, but I am usually unable to isolate parts which could possibly require selinux-policy change. https://www.openssh.org/releasenotes.html I was hit by this bug upon updating to openssh-server As far as I see the root cause is openssh 10.6 added mkdir_path() in misc.c. agent_listener_user() in misc-agent.c calls it to make ~/.ssh/agent and checks before. The function opens with openat(fd, dir, O_RDONLY|O_DIRECTORY). O_RDONLY on a directory needs the SELinux "read" permission, not only "search". 10.5p1 do not have this function. Workarounds (both as root, both have side effects!!): 1. setsebool polyinstantiation_enabled on 2. run: echo "(allow sshd_session_t home_root_t (dir (read)))" > sshd_agent_home.cil semodule -i sshd_agent_home.cil Running sudo setsebool -P polyinstantiation_enabled on resolves the issue for me. This boolean enables way more then required though (In reply to Radosław Stachowiak from comment #4) > As far as I see the root cause is openssh 10.6 added mkdir_path() in misc.c. > agent_listener_user() in misc-agent.c calls it to make ~/.ssh/agent and > checks before. > The function opens with openat(fd, dir, O_RDONLY|O_DIRECTORY). > O_RDONLY on a directory needs the SELinux "read" permission, not only > "search". > > 10.5p1 do not have this function. Dmitri, is the ability to read the content of /home necessary for sshd-session to function? |
Version: selinux-policy-45.24-1.fc45, openssh-server-10.6p1-1.fc45, enforcing /home is a separate filesystem. ssh -A to the host fails: Remote: Agent forwarding disabled: couldn't create listener socket Journal: AVC avc: denied { read } for comm="sshd-session" name="/" dev="dm-2" ino=2 scontext=system_u:system_r:sshd_session_t:s0-s0:c0.c1023 tcontext=system_u:object_r:home_root_t:s0 tclass=dir permissive=0 sshd-session: error: agent_listener_user: failed to create agent socket parent directory ~/.ssh/agent already exists (ssh_home_t). sshd_session_t appears to need read on home_root_t dirs to traverse to ~/.ssh/agent. Related: https://github.com/fedora-selinux/selinux-policy/issues/3384, bz2524485 Reproducible: Always Steps to Reproduce: 1. Fedora 45, SELinux enforcing, /home on a separate filesystem. 2. Install selinux-policy-45.24-1.fc45 and openssh-server-10.6p1-1.fc45. 3. From a client with a loaded agent: ssh -A <host> 'echo $SSH_AUTH_SOCK' Actual Results: SSH_AUTH_SOCK is empty. Client (ssh -v) reports: Remote: Agent forwarding disabled: couldn't create listener socket Server journal: AVC avc: denied { read } for comm="sshd-session" name="/" dev="dm-2" ino=2 scontext=system_u:system_r:sshd_session_t:s0-s0:c0.c1023 tcontext=system_u:object_r:home_root_t:s0 tclass=dir permissive=0 sshd-session: error: agent_listener_user: failed to create agent socket parent directory Expected Results: Agent forwarding works; SSH_AUTH_SOCK points to a socket under ~/.ssh/agent/. Additional Information: ~/.ssh/agent already exists, labeled ssh_home_t. sshd_session_t appears to need read on home_root_t directories to traverse to ~/.ssh/agent. Hosts on openssh-server 9.9 with the same setup are not affected. Related: https://github.com/fedora-selinux/selinux-policy/issues/3384 (create on ssh_home_t sock_file, fixed in 44.8), bz2524485.