Bug 2482 - SELinux integration
Summary: SELinux integration
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: sshd (show other bugs)
Version: 7.1p1
Hardware: Other Linux
: P5 enhancement
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-10-23 03:47 AEDT by Jakub Jelen
Modified: 2021-04-23 15:09 AEST (History)
1 user (show)

See Also:


Attachments
selinux patches (1 - 4) (6.70 KB, patch)
2015-10-23 03:47 AEDT, Jakub Jelen
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jakub Jelen 2015-10-23 03:47:57 AEDT
Created attachment 2733 [details]
selinux patches (1 - 4)

Our bugzilla [1] was another impulse to review SELinux integration in openssh and preferably contribute the changes back to upstream in some understandable format after the years:

1) Usage of hard-coded constant (SECCLASS_CHR_FILE) is not advised anymore, we should use string_to_security_class instead. This is related to removal of selinux/flash header file. [2]

2) The second part is about context handling. We get new context as exec context, from PAM or from ssh_selinux_setup_exec_context. We can't (and don't want to) wait for next fork/exec to change the context for us, since it can be after chroot (which needs to be handled in special way). Therefore we want to do this context swap with other capabilities swap. This adds the context switches in do_setusercontext() function. This will avoid us from need to call additional setexeccon from user context (and the need of this capability) if the user needs to switch password. Also the sftpd_t context is not used anymore (sftp runs under context of the actual user). [1]

3) The last bits so far are related to the privilege separation SELinux context (the net child is confined as sshd_net_t).

4) root logins can be also confined by SELinux, so we should not skip privilege separation in postauth phase (skipping also requires additional permissions to be available for selinux context of this user). [1]

Sorry for posting all patches in one, but they are quire closely related. If there is something not clear from description, I am free to explain further the reasons behind each line.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1269072
[2] https://bugzilla.redhat.com/show_bug.cgi?id=1261496
Comment 1 Jakub Jelen 2018-03-28 01:37:33 AEDT
This was partially fixed by the following commit:

https://github.com/openssh/openssh-portable/commit/bda709b

Thank you.
Comment 2 Damien Miller 2021-04-23 15:09:19 AEST
closing resolved bugs as of 8.6p1 release