SlideShare a Scribd company logo
SELinux introduction
Ľubomír Rintel
<lubo.rintel@gooddata.com>
Traditional UNIX DAC approach
● Owner controls access to object
● File owner/group
● Process with effective UID/GID
● File mode
● Almighty root user above the rules
SELinux MAC approach
● Policy controls access to objects
● Labeled objects (files, sockets, …)
● Labeled processes (domains)
● Policy rules
● Concept of “almighty” unconfined processes is
defined within policy
…
DAC and MAC at the same time
● Allows for tighter privilege control
UNIX SELinux
File owner/group: UID/GID File context (FC): label
Process effective user/group:
UID/GID
Process domain: label
File mode Type Enforcement (TE) rules
setuid() Domain transition
Setuid bit File context + implicit domain
transition rule
Labels
$ ls -Z /var/spool/anacron/cron.daily
-rw-------. root root
system_u:object_r:system_cron_spool_t:s0
/var/spool/anacron/cron.daily
$ ps uxZ |grep /usr/sbin/atd
system_u:system_r:crond_t:s0-s0:c0.c1023
root 4371 0.0 0.0 21448 212 ?
Ss 2012 0:00 /usr/sbin/atd
Policy
● Delivered via RPM packages
● selinux-policy, selinux-policy-targeted
● Reference policy, multiple available
● Modular
● File contexts (*.fc)
● Type enforcement rules (*.te)
● M4 macros, "interfaces" (*.if)
File Contexts
● Labeling rules delivered with policy packages
● RPM applies labels upon package installation
● Files inherit labels otherwise
cron.fc:
/etc/cron.d(/.*)?
gen_context(system_u:object_r:system_cron_spool_t,s0)
/etc/crontab --
gen_context(system_u:object_r:system_cron_spool_t,s0)
/var/spool/anacron(/.*)?
gen_context(system_u:object_r:system_cron_spool_t,s0)
⋮
/var/spool/fcron/systab --
gen_context(system_u:object_r:system_cron_spool_t,s0)
Type Enforcement rules
● Specified in custom DSL + M4
● Compiled & loaded into kernel at runtime
cron.te:
allow system_cronjob_t cron_log_t:file
manage_file_perms;
⋮
list_dirs_pattern(crond_t, system_cron_spool_t,
system_cron_spool_t)
read_files_pattern(crond_t, system_cron_spool_t,
system_cron_spool_t)
Domains
● TE rules control domain transition
● Transitioned into upon execution of labeled file
● Remember the setuid bit?
● "unconfined" domains
cron.te:
init_daemon_domain(system_cronjob_t, anacron_exec_t)
Management Tools
● getenforce 1; getenforce
● /var/sysconfig/selinux
● UNIX tools with -Z argument
● semanage
# semanage fcontext -l |grep /var/spool/anacron
/var/spool/anacron(/.*)?
all files system_u:object_r:system_cron_spool_t:s0
# chcon -t etc_t /var/spool/anacron
# restorecon -v /var/spool/anacron
restorecon reset /var/spool/anacron context
system_u:object_r:etc_t:s0
->system_u:object_r:system_cron_spool_t:s0
What if things don't work?
● audit2why, audit2allow
to analyze
● restorecon to fix context
SELinux introduction
Ľubomír Rintel
<lubo.rintel@gooddata.com>
Traditional UNIX DAC approach
● Owner controls access to object
● File owner/group
● Process with effective UID/GID
● File mode
● Almighty root user above the rules
SELinux MAC approach
● Policy controls access to objects
● Labeled objects (files, sockets, …)
● Labeled processes (domains)
● Policy rules
● Concept of “almighty” unconfined processes is
defined within policy
…
DAC and MAC at the same time
● Allows for tighter privilege control
UNIX SELinux
File owner/group: UID/GID File context (FC): label
Process effective user/group:
UID/GID
Process domain: label
File mode Type Enforcement (TE) rules
setuid() Domain transition
Setuid bit File context + implicit domain
transition rule
Labels
$ ls -Z /var/spool/anacron/cron.daily
-rw-------. root root
system_u:object_r:system_cron_spool_t:s0
/var/spool/anacron/cron.daily
$ ps uxZ |grep /usr/sbin/atd
system_u:system_r:crond_t:s0-s0:c0.c1023
root 4371 0.0 0.0 21448 212 ?
Ss 2012 0:00 /usr/sbin/atd
Policy
● Delivered via RPM packages
● selinux-policy, selinux-policy-targeted
● Reference policy, multiple available
● Modular
● File contexts (*.fc)
● Type enforcement rules (*.te)
● M4 macros, "interfaces" (*.if)
File Contexts
● Labeling rules delivered with policy packages
● RPM applies labels upon package installation
● Files inherit labels otherwise
cron.fc:
/etc/cron.d(/.*)?
gen_context(system_u:object_r:system_cron_spool_t,s0)
/etc/crontab --
gen_context(system_u:object_r:system_cron_spool_t,s0)
/var/spool/anacron(/.*)?
gen_context(system_u:object_r:system_cron_spool_t,s0)
⋮
/var/spool/fcron/systab --
gen_context(system_u:object_r:system_cron_spool_t,s0)
Type Enforcement rules
● Specified in custom DSL + M4
● Compiled & loaded into kernel at runtime
cron.te:
allow system_cronjob_t cron_log_t:file
manage_file_perms;
⋮
list_dirs_pattern(crond_t, system_cron_spool_t,
system_cron_spool_t)
read_files_pattern(crond_t, system_cron_spool_t,
system_cron_spool_t)
Domains
● TE rules control domain transition
● Transitioned into upon execution of labeled file
● Remember the setuid bit?
● "unconfined" domains
cron.te:
init_daemon_domain(system_cronjob_t, anacron_exec_t)
Management Tools
● getenforce 1; getenforce
● /var/sysconfig/selinux
● UNIX tools with -Z argument
● semanage
# semanage fcontext -l |grep /var/spool/anacron
/var/spool/anacron(/.*)?
all files system_u:object_r:system_cron_spool_t:s0
# chcon -t etc_t /var/spool/anacron
# restorecon -v /var/spool/anacron
restorecon reset /var/spool/anacron context
system_u:object_r:etc_t:s0
->system_u:object_r:system_cron_spool_t:s0
What if things don't work?
● audit2why, audit2allow
to analyze
● restorecon to fix context

More Related Content

PPTX
Understanding the Windows Server Administration Fundamentals (Part-1)
PPT
Introduction To SELinux
PDF
MR201406 A Re-introduction to SELinux
PPT
Active Directory
PPT
Linux command ppt
PPT
Storage Management using LVM
PDF
Selinux
Understanding the Windows Server Administration Fundamentals (Part-1)
Introduction To SELinux
MR201406 A Re-introduction to SELinux
Active Directory
Linux command ppt
Storage Management using LVM
Selinux

What's hot (20)

PPT
Active directory slides
ODP
SELinux Basic Usage
PPT
Active directory and application
PPTX
OpenvSwitch Deep Dive
PPT
active-directory-domain-services
PPT
Workgroup vs domain
PDF
Windows server administration
PPTX
1 introduction to windows server 2016
PPTX
Linux standard file system
PPTX
What is active directory
PPT
Microsoft Active Directory
PPTX
Windows server
PDF
SSH - Secure Shell
PPT
Active directory
PPTX
Security Enhanced Linux Overview
PPT
Oracle Transparent Data Encryption (TDE) 12c
PPT
Active directory
PPT
Active Directory Services
PPTX
Active directory domain service
PDF
Alphorm.com Formation VirtualBox
Active directory slides
SELinux Basic Usage
Active directory and application
OpenvSwitch Deep Dive
active-directory-domain-services
Workgroup vs domain
Windows server administration
1 introduction to windows server 2016
Linux standard file system
What is active directory
Microsoft Active Directory
Windows server
SSH - Secure Shell
Active directory
Security Enhanced Linux Overview
Oracle Transparent Data Encryption (TDE) 12c
Active directory
Active Directory Services
Active directory domain service
Alphorm.com Formation VirtualBox
Ad

Viewers also liked (20)

ODP
SELinux for Everyday Users
PDF
Kernel Recipes 2015 - Hardened kernels for everyone
PPTX
COMPUTER SECURITY AND OPERATING SYSTEM
PPTX
Operating system security
PPTX
System protection in Operating System
PPTX
Operating System Security
PPTX
Operating system security
PPTX
Security & protection in operating system
PDF
FreeBSD ports
PDF
Introduction to FreeBSD 7.0
PPT
FreeBSD - LinuxExpo
PPT
PDF
Dovecot
PDF
FreeBSD Document Project
PDF
Dovecot & Postfix バージョンアップ動向 201506-201511
DOC
finalreport1182014
PDF
66_pfSenseTutorial
PPTX
Operating system enhancements to prevent misuse of systems
PDF
FreeBSD: Dev to Prod
PPTX
Unitrends Sales Presentation 2010
SELinux for Everyday Users
Kernel Recipes 2015 - Hardened kernels for everyone
COMPUTER SECURITY AND OPERATING SYSTEM
Operating system security
System protection in Operating System
Operating System Security
Operating system security
Security & protection in operating system
FreeBSD ports
Introduction to FreeBSD 7.0
FreeBSD - LinuxExpo
Dovecot
FreeBSD Document Project
Dovecot & Postfix バージョンアップ動向 201506-201511
finalreport1182014
66_pfSenseTutorial
Operating system enhancements to prevent misuse of systems
FreeBSD: Dev to Prod
Unitrends Sales Presentation 2010
Ad

Similar to SELinux basics (20)

PPTX
SELinux_@gnu_group_meetup
PPTX
SE Linux
PDF
2008-10-15 Red Hat Deep Dive Sessions: SELinux
ODP
chroot and SELinux
PDF
2008 08-12 SELinux: A Key Component in Secure Infrastructures
PDF
Managing SELinux Security - RHCSA (RH134).pdf
PDF
SELinux workshop
PDF
SELinux Johannesburg Linux User Group (JoziJUg)
PDF
Understanding SELinux For the Win
PDF
2009-08-11 IBM Teach the Teachers (IBM T3), Linux Security Overview
PPTX
selinuxbasicusage.pptx
PPTX
SELinux concept in rhel_Linux_today.pptx
PDF
SELinux by Example
PDF
SELinux Kernel Internals and Architecture - FOSS.IN/2005
PDF
PPT_Compiled
PDF
The Linux Audit Framework
PDF
46 customizing se linux policy
PPTX
PDF
کارگاه امنیت با عنوان Stop Disabling SElinux
PDF
2008-09-09 IBM Interaction Conference, Red Hat Update for System z
SELinux_@gnu_group_meetup
SE Linux
2008-10-15 Red Hat Deep Dive Sessions: SELinux
chroot and SELinux
2008 08-12 SELinux: A Key Component in Secure Infrastructures
Managing SELinux Security - RHCSA (RH134).pdf
SELinux workshop
SELinux Johannesburg Linux User Group (JoziJUg)
Understanding SELinux For the Win
2009-08-11 IBM Teach the Teachers (IBM T3), Linux Security Overview
selinuxbasicusage.pptx
SELinux concept in rhel_Linux_today.pptx
SELinux by Example
SELinux Kernel Internals and Architecture - FOSS.IN/2005
PPT_Compiled
The Linux Audit Framework
46 customizing se linux policy
کارگاه امنیت با عنوان Stop Disabling SElinux
2008-09-09 IBM Interaction Conference, Red Hat Update for System z

More from Lubomir Rintel (8)

PDF
Namespaces for Kazimir
PDF
Linux Kernel Debugging Essentials workshop
PDF
Namespaces in Linux
PDF
LinuxAlt 2013: Writing a driver for unknown USB device
PDF
A journey through the years of UNIX and Linux service management
PDF
Practical SystemTAP basics: Perl memory profiling
PDF
Reverse Engineering: Writing a Linux driver for an unknown device
PDF
Brno meetr: Packaging Ruby Gems into RPM
Namespaces for Kazimir
Linux Kernel Debugging Essentials workshop
Namespaces in Linux
LinuxAlt 2013: Writing a driver for unknown USB device
A journey through the years of UNIX and Linux service management
Practical SystemTAP basics: Perl memory profiling
Reverse Engineering: Writing a Linux driver for an unknown device
Brno meetr: Packaging Ruby Gems into RPM

Recently uploaded (20)

PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
August Patch Tuesday
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PPTX
OMC Textile Division Presentation 2021.pptx
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
cloud_computing_Infrastucture_as_cloud_p
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Approach and Philosophy of On baking technology
PPTX
A Presentation on Artificial Intelligence
PDF
Heart disease approach using modified random forest and particle swarm optimi...
PDF
Getting Started with Data Integration: FME Form 101
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
gpt5_lecture_notes_comprehensive_20250812015547.pdf
August Patch Tuesday
SOPHOS-XG Firewall Administrator PPT.pptx
Encapsulation_ Review paper, used for researhc scholars
Univ-Connecticut-ChatGPT-Presentaion.pdf
OMC Textile Division Presentation 2021.pptx
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
NewMind AI Weekly Chronicles - August'25-Week II
Unlocking AI with Model Context Protocol (MCP)
cloud_computing_Infrastucture_as_cloud_p
Programs and apps: productivity, graphics, security and other tools
Approach and Philosophy of On baking technology
A Presentation on Artificial Intelligence
Heart disease approach using modified random forest and particle swarm optimi...
Getting Started with Data Integration: FME Form 101
Assigned Numbers - 2025 - Bluetooth® Document
Per capita expenditure prediction using model stacking based on satellite ima...

SELinux basics

  • 2. Traditional UNIX DAC approach ● Owner controls access to object ● File owner/group ● Process with effective UID/GID ● File mode ● Almighty root user above the rules
  • 3. SELinux MAC approach ● Policy controls access to objects ● Labeled objects (files, sockets, …) ● Labeled processes (domains) ● Policy rules ● Concept of “almighty” unconfined processes is defined within policy …
  • 4. DAC and MAC at the same time ● Allows for tighter privilege control UNIX SELinux File owner/group: UID/GID File context (FC): label Process effective user/group: UID/GID Process domain: label File mode Type Enforcement (TE) rules setuid() Domain transition Setuid bit File context + implicit domain transition rule
  • 5. Labels $ ls -Z /var/spool/anacron/cron.daily -rw-------. root root system_u:object_r:system_cron_spool_t:s0 /var/spool/anacron/cron.daily $ ps uxZ |grep /usr/sbin/atd system_u:system_r:crond_t:s0-s0:c0.c1023 root 4371 0.0 0.0 21448 212 ? Ss 2012 0:00 /usr/sbin/atd
  • 6. Policy ● Delivered via RPM packages ● selinux-policy, selinux-policy-targeted ● Reference policy, multiple available ● Modular ● File contexts (*.fc) ● Type enforcement rules (*.te) ● M4 macros, "interfaces" (*.if)
  • 7. File Contexts ● Labeling rules delivered with policy packages ● RPM applies labels upon package installation ● Files inherit labels otherwise cron.fc: /etc/cron.d(/.*)? gen_context(system_u:object_r:system_cron_spool_t,s0) /etc/crontab -- gen_context(system_u:object_r:system_cron_spool_t,s0) /var/spool/anacron(/.*)? gen_context(system_u:object_r:system_cron_spool_t,s0) ⋮ /var/spool/fcron/systab -- gen_context(system_u:object_r:system_cron_spool_t,s0)
  • 8. Type Enforcement rules ● Specified in custom DSL + M4 ● Compiled & loaded into kernel at runtime cron.te: allow system_cronjob_t cron_log_t:file manage_file_perms; ⋮ list_dirs_pattern(crond_t, system_cron_spool_t, system_cron_spool_t) read_files_pattern(crond_t, system_cron_spool_t, system_cron_spool_t)
  • 9. Domains ● TE rules control domain transition ● Transitioned into upon execution of labeled file ● Remember the setuid bit? ● "unconfined" domains cron.te: init_daemon_domain(system_cronjob_t, anacron_exec_t)
  • 10. Management Tools ● getenforce 1; getenforce ● /var/sysconfig/selinux ● UNIX tools with -Z argument ● semanage # semanage fcontext -l |grep /var/spool/anacron /var/spool/anacron(/.*)? all files system_u:object_r:system_cron_spool_t:s0 # chcon -t etc_t /var/spool/anacron # restorecon -v /var/spool/anacron restorecon reset /var/spool/anacron context system_u:object_r:etc_t:s0 ->system_u:object_r:system_cron_spool_t:s0
  • 11. What if things don't work? ● audit2why, audit2allow to analyze ● restorecon to fix context
  • 13. Traditional UNIX DAC approach ● Owner controls access to object ● File owner/group ● Process with effective UID/GID ● File mode ● Almighty root user above the rules
  • 14. SELinux MAC approach ● Policy controls access to objects ● Labeled objects (files, sockets, …) ● Labeled processes (domains) ● Policy rules ● Concept of “almighty” unconfined processes is defined within policy …
  • 15. DAC and MAC at the same time ● Allows for tighter privilege control UNIX SELinux File owner/group: UID/GID File context (FC): label Process effective user/group: UID/GID Process domain: label File mode Type Enforcement (TE) rules setuid() Domain transition Setuid bit File context + implicit domain transition rule
  • 16. Labels $ ls -Z /var/spool/anacron/cron.daily -rw-------. root root system_u:object_r:system_cron_spool_t:s0 /var/spool/anacron/cron.daily $ ps uxZ |grep /usr/sbin/atd system_u:system_r:crond_t:s0-s0:c0.c1023 root 4371 0.0 0.0 21448 212 ? Ss 2012 0:00 /usr/sbin/atd
  • 17. Policy ● Delivered via RPM packages ● selinux-policy, selinux-policy-targeted ● Reference policy, multiple available ● Modular ● File contexts (*.fc) ● Type enforcement rules (*.te) ● M4 macros, "interfaces" (*.if)
  • 18. File Contexts ● Labeling rules delivered with policy packages ● RPM applies labels upon package installation ● Files inherit labels otherwise cron.fc: /etc/cron.d(/.*)? gen_context(system_u:object_r:system_cron_spool_t,s0) /etc/crontab -- gen_context(system_u:object_r:system_cron_spool_t,s0) /var/spool/anacron(/.*)? gen_context(system_u:object_r:system_cron_spool_t,s0) ⋮ /var/spool/fcron/systab -- gen_context(system_u:object_r:system_cron_spool_t,s0)
  • 19. Type Enforcement rules ● Specified in custom DSL + M4 ● Compiled & loaded into kernel at runtime cron.te: allow system_cronjob_t cron_log_t:file manage_file_perms; ⋮ list_dirs_pattern(crond_t, system_cron_spool_t, system_cron_spool_t) read_files_pattern(crond_t, system_cron_spool_t, system_cron_spool_t)
  • 20. Domains ● TE rules control domain transition ● Transitioned into upon execution of labeled file ● Remember the setuid bit? ● "unconfined" domains cron.te: init_daemon_domain(system_cronjob_t, anacron_exec_t)
  • 21. Management Tools ● getenforce 1; getenforce ● /var/sysconfig/selinux ● UNIX tools with -Z argument ● semanage # semanage fcontext -l |grep /var/spool/anacron /var/spool/anacron(/.*)? all files system_u:object_r:system_cron_spool_t:s0 # chcon -t etc_t /var/spool/anacron # restorecon -v /var/spool/anacron restorecon reset /var/spool/anacron context system_u:object_r:etc_t:s0 ->system_u:object_r:system_cron_spool_t:s0
  • 22. What if things don't work? ● audit2why, audit2allow to analyze ● restorecon to fix context