
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/css" href="http://selinuxproject.org/w/skins/common/feed.css?63"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
	<channel>
		<title>NB LSM - Revision history</title>
		<link>http://selinuxproject.org/w/?title=NB_LSM&amp;action=history</link>
		<description>Revision history for this page on the wiki</description>
		<language>en</language>
		<generator>MediaWiki 1.10.4</generator>
		<lastBuildDate>Sun, 19 May 2013 01:39:52 GMT</lastBuildDate>
		<item>
			<title>Jaxelson at 20:46, 13 September 2010</title>
			<link>http://selinuxproject.org/w/?title=NB_LSM&amp;diff=1026&amp;oldid=prev</link>
			<description>&lt;p&gt;&lt;/p&gt;

			&lt;table border='0' width='98%' cellpadding='0' cellspacing='4' style=&quot;background-color: white;&quot;&gt;
			&lt;tr&gt;
				&lt;td colspan='2' width='50%' align='center' style=&quot;background-color: white;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' width='50%' align='center' style=&quot;background-color: white;&quot;&gt;Revision as of 20:46, 13 September 2010&lt;/td&gt;
			&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; align=&quot;left&quot;&gt;&lt;strong&gt;Line 657:&lt;/strong&gt;&lt;/td&gt;
&lt;td colspan=&quot;2&quot; align=&quot;left&quot;&gt;&lt;strong&gt;Line 657:&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;----&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;----&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&amp;lt;references/&amp;gt;&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&amp;lt;references/&amp;gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; font-size: smaller;&quot;&gt;[[Category:Notebook]]&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</description>
			<pubDate>Mon, 13 Sep 2010 20:46:41 GMT</pubDate>			<dc:creator>Jaxelson</dc:creator>			<comments>http://selinuxproject.org/page/Talk:NB_LSM</comments>		</item>
		<item>
			<title>RichardHaines: /* SELinux Filesystem */</title>
			<link>http://selinuxproject.org/w/?title=NB_LSM&amp;diff=960&amp;oldid=prev</link>
			<description>&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;SELinux Filesystem&lt;/span&gt;&lt;/p&gt;

			&lt;table border='0' width='98%' cellpadding='0' cellspacing='4' style=&quot;background-color: white;&quot;&gt;
			&lt;tr&gt;
				&lt;td colspan='2' width='50%' align='center' style=&quot;background-color: white;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' width='50%' align='center' style=&quot;background-color: white;&quot;&gt;Revision as of 15:57, 17 May 2010&lt;/td&gt;
			&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; align=&quot;left&quot;&gt;&lt;strong&gt;Line 335:&lt;/strong&gt;&lt;/td&gt;
&lt;td colspan=&quot;2&quot; align=&quot;left&quot;&gt;&lt;strong&gt;Line 335:&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;| &amp;lt;div align=&amp;quot;right&amp;quot;&amp;gt;deny_unknown&amp;lt;/div&amp;gt;&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;| &amp;lt;div align=&amp;quot;right&amp;quot;&amp;gt;deny_unknown&amp;lt;/div&amp;gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;| &amp;lt;center&amp;gt;-r--r--r--&amp;lt;/center&amp;gt;&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;| &amp;lt;center&amp;gt;-r--r--r--&amp;lt;/center&amp;gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; font-size: smaller;&quot;&gt;| These two files export unknown deny and reject handling status to user space. This is taken from the handle-unknown parameter set&amp;lt;ref name=&amp;quot;ftn17&amp;quot;&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;gt;&amp;lt;sup&lt;/del&gt;&amp;gt;That is taken from the UNK_PERMS entry in the Reference Policy build.conf  file.&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/sup&amp;gt;&lt;/del&gt;&amp;lt;/ref&amp;gt; in the /etc/selinux/semanage.conf file and are set as follows:&lt;/td&gt;&lt;td&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; font-size: smaller;&quot;&gt;| These two files export unknown deny and reject handling status to user space. This is taken from the &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;tt&amp;gt;&lt;/ins&gt;handle-unknown&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/tt&amp;gt; &lt;/ins&gt;parameter set&amp;lt;ref name=&amp;quot;ftn17&amp;quot;&amp;gt;That is taken from the UNK_PERMS entry in the Reference Policy build.conf  file.&amp;lt;/ref&amp;gt; in the /etc/selinux/semanage.conf file and are set as follows:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;0:0 = allow, 1:0 = deny and 1:1 = reject.&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;0:0 = allow, 1:0 = deny and 1:1 = reject.&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</description>
			<pubDate>Mon, 17 May 2010 15:57:50 GMT</pubDate>			<dc:creator>RichardHaines</dc:creator>			<comments>http://selinuxproject.org/page/Talk:NB_LSM</comments>		</item>
		<item>
			<title>RichardHaines: /* Process Transition Walk-thorough */</title>
			<link>http://selinuxproject.org/w/?title=NB_LSM&amp;diff=959&amp;oldid=prev</link>
			<description>&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Process Transition Walk-thorough&lt;/span&gt;&lt;/p&gt;

			&lt;table border='0' width='98%' cellpadding='0' cellspacing='4' style=&quot;background-color: white;&quot;&gt;
			&lt;tr&gt;
				&lt;td colspan='2' width='50%' align='center' style=&quot;background-color: white;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' width='50%' align='center' style=&quot;background-color: white;&quot;&gt;Revision as of 15:55, 17 May 2010&lt;/td&gt;
			&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; align=&quot;left&quot;&gt;&lt;strong&gt;Line 210:&lt;/strong&gt;&lt;/td&gt;
&lt;td colspan=&quot;2&quot; align=&quot;left&quot;&gt;&lt;strong&gt;Line 210:&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;This section walks through the &amp;lt;tt&amp;gt;execve()&amp;lt;/tt&amp;gt; and checking whether a process transition to the &amp;lt;tt&amp;gt;ext_gateway_t&amp;lt;/tt&amp;gt; domain is allowed, and if so obtain a new SID for the context (&amp;lt;tt&amp;gt;user_u:message_filter_r:ext_gateway_t&amp;lt;/tt&amp;gt;) as shown in the [http://taiga.selinuxproject.org/~rhaines/diagrams/7-domain-transition.png Domain Transition] diagram.&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;This section walks through the &amp;lt;tt&amp;gt;execve()&amp;lt;/tt&amp;gt; and checking whether a process transition to the &amp;lt;tt&amp;gt;ext_gateway_t&amp;lt;/tt&amp;gt; domain is allowed, and if so obtain a new SID for the context (&amp;lt;tt&amp;gt;user_u:message_filter_r:ext_gateway_t&amp;lt;/tt&amp;gt;) as shown in the [http://taiga.selinuxproject.org/~rhaines/diagrams/7-domain-transition.png Domain Transition] diagram.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; font-size: smaller;&quot;&gt;The process starts with the Linux operating system issuing a &amp;lt;tt&amp;gt;do_execve()&amp;lt;/tt&amp;gt;&amp;lt;ref name=&amp;quot;ftn16&amp;quot;&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;gt;&amp;lt;tt&lt;/del&gt;&amp;gt;This function call will pass over the file name to be run and its environment + arguments. Note that for loading shared libraries the exec_mmap function is used.&amp;lt;/ref&amp;gt; call from the CPU specific architecture code to execute a new program (for example, from &amp;lt;tt&amp;gt;arch/ia64/kernel/process.c&amp;lt;/tt&amp;gt;). The &amp;lt;tt&amp;gt;do_execve()&amp;lt;/tt&amp;gt; function is located in the &amp;lt;tt&amp;gt;fs/exec.c&amp;lt;/tt&amp;gt; source code module and does the loading and final exec as described below.&lt;/td&gt;&lt;td&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; font-size: smaller;&quot;&gt;The process starts with the Linux operating system issuing a &amp;lt;tt&amp;gt;do_execve()&amp;lt;/tt&amp;gt;&amp;lt;ref name=&amp;quot;ftn16&amp;quot;&amp;gt;This function call will pass over the file name to be run and its environment + arguments. Note that for loading shared libraries the exec_mmap function is used.&amp;lt;/ref&amp;gt; call from the CPU specific architecture code to execute a new program (for example, from &amp;lt;tt&amp;gt;arch/ia64/kernel/process.c&amp;lt;/tt&amp;gt;). The &amp;lt;tt&amp;gt;do_execve()&amp;lt;/tt&amp;gt; function is located in the &amp;lt;tt&amp;gt;fs/exec.c&amp;lt;/tt&amp;gt; source code module and does the loading and final exec as described below.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&amp;lt;tt&amp;gt;do_execve()&amp;lt;/tt&amp;gt; has a number of calls to &amp;lt;tt&amp;gt;security_bprm_*&amp;lt;/tt&amp;gt; functions that are a part of the LSM (see &amp;lt;tt&amp;gt;security.h&amp;lt;/tt&amp;gt;), and are hooked by SELinux during the initialisation process (in &amp;lt;tt&amp;gt;hooks.c&amp;lt;/tt&amp;gt;). Table 4 briefly describes these &amp;lt;tt&amp;gt;security_bprm&amp;lt;/tt&amp;gt; functions that are hooks for validating program loading and execution (although see &amp;lt;tt&amp;gt;security.h&amp;lt;/tt&amp;gt; for greater detail).&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&amp;lt;tt&amp;gt;do_execve()&amp;lt;/tt&amp;gt; has a number of calls to &amp;lt;tt&amp;gt;security_bprm_*&amp;lt;/tt&amp;gt; functions that are a part of the LSM (see &amp;lt;tt&amp;gt;security.h&amp;lt;/tt&amp;gt;), and are hooked by SELinux during the initialisation process (in &amp;lt;tt&amp;gt;hooks.c&amp;lt;/tt&amp;gt;). Table 4 briefly describes these &amp;lt;tt&amp;gt;security_bprm&amp;lt;/tt&amp;gt; functions that are hooks for validating program loading and execution (although see &amp;lt;tt&amp;gt;security.h&amp;lt;/tt&amp;gt; for greater detail).&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</description>
			<pubDate>Mon, 17 May 2010 15:55:33 GMT</pubDate>			<dc:creator>RichardHaines</dc:creator>			<comments>http://selinuxproject.org/page/Talk:NB_LSM</comments>		</item>
		<item>
			<title>RichardHaines: /* Process Transition Walk-thorough */</title>
			<link>http://selinuxproject.org/w/?title=NB_LSM&amp;diff=958&amp;oldid=prev</link>
			<description>&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Process Transition Walk-thorough&lt;/span&gt;&lt;/p&gt;

			&lt;table border='0' width='98%' cellpadding='0' cellspacing='4' style=&quot;background-color: white;&quot;&gt;
			&lt;tr&gt;
				&lt;td colspan='2' width='50%' align='center' style=&quot;background-color: white;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' width='50%' align='center' style=&quot;background-color: white;&quot;&gt;Revision as of 15:54, 17 May 2010&lt;/td&gt;
			&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; align=&quot;left&quot;&gt;&lt;strong&gt;Line 210:&lt;/strong&gt;&lt;/td&gt;
&lt;td colspan=&quot;2&quot; align=&quot;left&quot;&gt;&lt;strong&gt;Line 210:&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;This section walks through the &amp;lt;tt&amp;gt;execve()&amp;lt;/tt&amp;gt; and checking whether a process transition to the &amp;lt;tt&amp;gt;ext_gateway_t&amp;lt;/tt&amp;gt; domain is allowed, and if so obtain a new SID for the context (&amp;lt;tt&amp;gt;user_u:message_filter_r:ext_gateway_t&amp;lt;/tt&amp;gt;) as shown in the [http://taiga.selinuxproject.org/~rhaines/diagrams/7-domain-transition.png Domain Transition] diagram.&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;This section walks through the &amp;lt;tt&amp;gt;execve()&amp;lt;/tt&amp;gt; and checking whether a process transition to the &amp;lt;tt&amp;gt;ext_gateway_t&amp;lt;/tt&amp;gt; domain is allowed, and if so obtain a new SID for the context (&amp;lt;tt&amp;gt;user_u:message_filter_r:ext_gateway_t&amp;lt;/tt&amp;gt;) as shown in the [http://taiga.selinuxproject.org/~rhaines/diagrams/7-domain-transition.png Domain Transition] diagram.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; font-size: smaller;&quot;&gt;The process starts with the Linux operating system issuing a &amp;lt;tt&amp;gt;do_execve()&amp;lt;ref name=&amp;quot;ftn16&amp;quot;&amp;gt;&amp;lt;tt&amp;gt;This function call will pass over the file name to be run and its environment + arguments. Note that for loading shared libraries the exec_mmap function is used.&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/tt&amp;gt;&lt;/del&gt;&amp;lt;/ref&amp;gt; call from the CPU specific architecture code to execute a new program (for example, from &amp;lt;tt&amp;gt;arch/ia64/kernel/process.c&amp;lt;/tt&amp;gt;). The &amp;lt;tt&amp;gt;do_execve()&amp;lt;/tt&amp;gt; function is located in the &amp;lt;tt&amp;gt;fs/exec.c&amp;lt;/tt&amp;gt; source code module and does the loading and final exec as described below.&lt;/td&gt;&lt;td&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; font-size: smaller;&quot;&gt;The process starts with the Linux operating system issuing a &amp;lt;tt&amp;gt;do_execve()&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/tt&amp;gt;&lt;/ins&gt;&amp;lt;ref name=&amp;quot;ftn16&amp;quot;&amp;gt;&amp;lt;tt&amp;gt;This function call will pass over the file name to be run and its environment + arguments. Note that for loading shared libraries the exec_mmap function is used.&amp;lt;/ref&amp;gt; call from the CPU specific architecture code to execute a new program (for example, from &amp;lt;tt&amp;gt;arch/ia64/kernel/process.c&amp;lt;/tt&amp;gt;). The &amp;lt;tt&amp;gt;do_execve()&amp;lt;/tt&amp;gt; function is located in the &amp;lt;tt&amp;gt;fs/exec.c&amp;lt;/tt&amp;gt; source code module and does the loading and final exec as described below.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&amp;lt;tt&amp;gt;do_execve()&amp;lt;/tt&amp;gt; has a number of calls to &amp;lt;tt&amp;gt;security_bprm_*&amp;lt;/tt&amp;gt; functions that are a part of the LSM (see &amp;lt;tt&amp;gt;security.h&amp;lt;/tt&amp;gt;), and are hooked by SELinux during the initialisation process (in &amp;lt;tt&amp;gt;hooks.c&amp;lt;/tt&amp;gt;). Table 4 briefly describes these &amp;lt;tt&amp;gt;security_bprm&amp;lt;/tt&amp;gt; functions that are hooks for validating program loading and execution (although see &amp;lt;tt&amp;gt;security.h&amp;lt;/tt&amp;gt; for greater detail).&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&amp;lt;tt&amp;gt;do_execve()&amp;lt;/tt&amp;gt; has a number of calls to &amp;lt;tt&amp;gt;security_bprm_*&amp;lt;/tt&amp;gt; functions that are a part of the LSM (see &amp;lt;tt&amp;gt;security.h&amp;lt;/tt&amp;gt;), and are hooked by SELinux during the initialisation process (in &amp;lt;tt&amp;gt;hooks.c&amp;lt;/tt&amp;gt;). Table 4 briefly describes these &amp;lt;tt&amp;gt;security_bprm&amp;lt;/tt&amp;gt; functions that are hooks for validating program loading and execution (although see &amp;lt;tt&amp;gt;security.h&amp;lt;/tt&amp;gt; for greater detail).&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</description>
			<pubDate>Mon, 17 May 2010 15:54:25 GMT</pubDate>			<dc:creator>RichardHaines</dc:creator>			<comments>http://selinuxproject.org/page/Talk:NB_LSM</comments>		</item>
		<item>
			<title>RichardHaines: /* Process Transition Walk-thorough */</title>
			<link>http://selinuxproject.org/w/?title=NB_LSM&amp;diff=957&amp;oldid=prev</link>
			<description>&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Process Transition Walk-thorough&lt;/span&gt;&lt;/p&gt;

			&lt;table border='0' width='98%' cellpadding='0' cellspacing='4' style=&quot;background-color: white;&quot;&gt;
			&lt;tr&gt;
				&lt;td colspan='2' width='50%' align='center' style=&quot;background-color: white;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' width='50%' align='center' style=&quot;background-color: white;&quot;&gt;Revision as of 15:50, 17 May 2010&lt;/td&gt;
			&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; align=&quot;left&quot;&gt;&lt;strong&gt;Line 219:&lt;/strong&gt;&lt;/td&gt;
&lt;td colspan=&quot;2&quot; align=&quot;left&quot;&gt;&lt;strong&gt;Line 219:&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;|-&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;|-&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; font-size: smaller;&quot;&gt;|  security_bprm_alloc-&amp;gt;&lt;/td&gt;&lt;td&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; font-size: smaller;&quot;&gt;|  &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;nowiki&amp;gt;&lt;/ins&gt;security_bprm_alloc-&amp;gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; font-size: smaller;&quot;&gt; selinux_bprm_alloc_security&lt;/td&gt;&lt;td&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; font-size: smaller;&quot;&gt; selinux_bprm_alloc_security&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/nowiki&amp;gt;&lt;/ins&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;| Allocates memory for the &amp;lt;tt&amp;gt;bprm&amp;lt;/tt&amp;gt; structure.&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;| Allocates memory for the &amp;lt;tt&amp;gt;bprm&amp;lt;/tt&amp;gt; structure.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;|-&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;|-&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; font-size: smaller;&quot;&gt;|  security_bprm_free-&amp;gt;&lt;/td&gt;&lt;td&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; font-size: smaller;&quot;&gt;|  &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;nowiki&amp;gt;&lt;/ins&gt;security_bprm_free-&amp;gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; font-size: smaller;&quot;&gt; selinux_bprm_free_security&lt;/td&gt;&lt;td&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; font-size: smaller;&quot;&gt; selinux_bprm_free_security&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/nowiki&amp;gt;&lt;/ins&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;| Frees memory from the &amp;lt;tt&amp;gt;bprm&amp;lt;/tt&amp;gt; structure.&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;| Frees memory from the &amp;lt;tt&amp;gt;bprm&amp;lt;/tt&amp;gt; structure.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;|-&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;|-&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; font-size: smaller;&quot;&gt;|  security_bprm_apply_creds-&amp;gt;&lt;/td&gt;&lt;td&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; font-size: smaller;&quot;&gt;|  &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;nowiki&amp;gt;&lt;/ins&gt;security_bprm_apply_creds-&amp;gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; font-size: smaller;&quot;&gt; selinux_bprm_apply_creds&lt;/td&gt;&lt;td&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; font-size: smaller;&quot;&gt; selinux_bprm_apply_creds&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/nowiki&amp;gt;&lt;/ins&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;| Sets task lock and new security attributes for a transformed process on execve. Seems to be used for libraries, scripts etc. Called from various Linux OS areas via &amp;lt;tt&amp;gt;compute_creds()&amp;lt;/tt&amp;gt; located in &amp;lt;tt&amp;gt;fs/exec.c&amp;lt;/tt&amp;gt;.&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;| Sets task lock and new security attributes for a transformed process on execve. Seems to be used for libraries, scripts etc. Called from various Linux OS areas via &amp;lt;tt&amp;gt;compute_creds()&amp;lt;/tt&amp;gt; located in &amp;lt;tt&amp;gt;fs/exec.c&amp;lt;/tt&amp;gt;.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;|-&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;|-&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; font-size: smaller;&quot;&gt;|  security_bprm_post_apply_creds-&amp;gt;&lt;/td&gt;&lt;td&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; font-size: smaller;&quot;&gt;|  &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;nowiki&amp;gt;&lt;/ins&gt;security_bprm_post_apply_creds-&amp;gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; font-size: smaller;&quot;&gt; selinux_bprm_post_apply_creds&lt;/td&gt;&lt;td&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; font-size: smaller;&quot;&gt; selinux_bprm_post_apply_creds&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/nowiki&amp;gt;&lt;/ins&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;| Supports the &amp;lt;tt&amp;gt;security_bprm_apply_creds&amp;lt;/tt&amp;gt; function for areas that must not be locked.&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;| Supports the &amp;lt;tt&amp;gt;security_bprm_apply_creds&amp;lt;/tt&amp;gt; function for areas that must not be locked.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;|-&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;|-&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; font-size: smaller;&quot;&gt;|  security_bprm_secureexec-&amp;gt;&lt;/td&gt;&lt;td&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; font-size: smaller;&quot;&gt;|  &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;nowiki&amp;gt;&lt;/ins&gt;security_bprm_secureexec-&amp;gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; font-size: smaller;&quot;&gt; selinux_bprm_secureexec&lt;/td&gt;&lt;td&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; font-size: smaller;&quot;&gt; selinux_bprm_secureexec&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/nowiki&amp;gt;&lt;/ins&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;| Called after the &amp;lt;tt&amp;gt;selinux_bprm_post_apply_creds&amp;lt;/tt&amp;gt; function to check &amp;lt;tt&amp;gt;AT_SECURE&amp;lt;/tt&amp;gt; flag for glibc secure mode support.&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;| Called after the &amp;lt;tt&amp;gt;selinux_bprm_post_apply_creds&amp;lt;/tt&amp;gt; function to check &amp;lt;tt&amp;gt;AT_SECURE&amp;lt;/tt&amp;gt; flag for glibc secure mode support.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;|-&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;|-&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; font-size: smaller;&quot;&gt;|  security_bprm_set-&amp;gt;&lt;/td&gt;&lt;td&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; font-size: smaller;&quot;&gt;|  &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;nowiki&amp;gt;&lt;/ins&gt;security_bprm_set-&amp;gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; font-size: smaller;&quot;&gt; selinux_bprm_set_security&lt;/td&gt;&lt;td&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; font-size: smaller;&quot;&gt; selinux_bprm_set_security&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/nowiki&amp;gt;&lt;/ins&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;| Carries out the major checks to validate whether the process can transition to the target context, and obtain a new SID if required.&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;| Carries out the major checks to validate whether the process can transition to the target context, and obtain a new SID if required.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;|-&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;|-&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; font-size: smaller;&quot;&gt;|  security_bprm_check-&amp;gt;&lt;/td&gt;&lt;td&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; font-size: smaller;&quot;&gt;|  &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;nowiki&amp;gt;&lt;/ins&gt;security_bprm_check-&amp;gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; font-size: smaller;&quot;&gt; selinux_bprm_check_security&lt;/td&gt;&lt;td&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; font-size: smaller;&quot;&gt; selinux_bprm_check_security&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/nowiki&amp;gt;&lt;/ins&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;| This hook is not used by SELinux.&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;| This hook is not used by SELinux.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; align=&quot;left&quot;&gt;&lt;strong&gt;Line 264:&lt;/strong&gt;&lt;/td&gt;
&lt;td colspan=&quot;2&quot; align=&quot;left&quot;&gt;&lt;strong&gt;Line 264:&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; font-size: smaller;&quot;&gt;Therefore starting at the &amp;lt;tt&amp;gt;do_execve()&amp;lt;/tt&amp;gt; function and using the [http://taiga.selinuxproject.org/~rhaines/diagrams/11-Transition.png &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;| &lt;/del&gt;Process Transition] diagram, the following major steps will be carried out to check whether the &amp;lt;tt&amp;gt;unconfined_t&amp;lt;/tt&amp;gt; process has permission to transition the &amp;lt;tt&amp;gt;secure_server&amp;lt;/tt&amp;gt; executable to the &amp;lt;tt&amp;gt;ext_gateway_t&amp;lt;/tt&amp;gt; domain:&lt;/td&gt;&lt;td&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; font-size: smaller;&quot;&gt;Therefore starting at the &amp;lt;tt&amp;gt;do_execve()&amp;lt;/tt&amp;gt; function and using the [http://taiga.selinuxproject.org/~rhaines/diagrams/11-Transition.png Process Transition] diagram, the following major steps will be carried out to check whether the &amp;lt;tt&amp;gt;unconfined_t&amp;lt;/tt&amp;gt; process has permission to transition the &amp;lt;tt&amp;gt;secure_server&amp;lt;/tt&amp;gt; executable to the &amp;lt;tt&amp;gt;ext_gateway_t&amp;lt;/tt&amp;gt; domain:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; font-size: smaller;&quot;&gt;&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;# &lt;/del&gt;The executable file is opened, a call issued to the &amp;lt;tt&amp;gt;sched_exec()&amp;lt;/tt&amp;gt; function and the &amp;lt;tt&amp;gt;bprm&amp;lt;/tt&amp;gt; structure is initialised with the file parameters (name, environment and arguments). &lt;/td&gt;&lt;td&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; font-size: smaller;&quot;&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;: 1. &lt;/ins&gt;The executable file is opened, a call issued to the &amp;lt;tt&amp;gt;sched_exec()&amp;lt;/tt&amp;gt; function and the &amp;lt;tt&amp;gt;bprm&amp;lt;/tt&amp;gt; structure is initialised with the file parameters (name, environment and arguments). &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;: The &amp;lt;tt&amp;gt;security_bprm_alloc()-&amp;gt;selinux_bprm_alloc_security()&amp;lt;/tt&amp;gt; function is then called (in &amp;lt;tt&amp;gt;hooks.c&amp;lt;/tt&amp;gt;) where SELinux will allocate memory for the &amp;lt;tt&amp;gt;bprm&amp;lt;/tt&amp;gt; security structure and set the &amp;lt;tt&amp;gt;bsec-&amp;gt;set&amp;lt;/tt&amp;gt; flag to &amp;lt;tt&amp;gt;0&amp;lt;/tt&amp;gt; indicating this is the first time through this process for this exec request.&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;: The &amp;lt;tt&amp;gt;security_bprm_alloc()-&amp;gt;selinux_bprm_alloc_security()&amp;lt;/tt&amp;gt; function is then called (in &amp;lt;tt&amp;gt;hooks.c&amp;lt;/tt&amp;gt;) where SELinux will allocate memory for the &amp;lt;tt&amp;gt;bprm&amp;lt;/tt&amp;gt; security structure and set the &amp;lt;tt&amp;gt;bsec-&amp;gt;set&amp;lt;/tt&amp;gt; flag to &amp;lt;tt&amp;gt;0&amp;lt;/tt&amp;gt; indicating this is the first time through this process for this exec request.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; font-size: smaller;&quot;&gt;&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;# &lt;/del&gt;Via the &amp;lt;tt&amp;gt;prepare_binprm()&amp;lt;/tt&amp;gt; function call the UID and GIDs are checked and a call issued to &amp;lt;tt&amp;gt;security_bprm_set()&amp;lt;/tt&amp;gt; that will carry out the following:&lt;/td&gt;&lt;td&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; font-size: smaller;&quot;&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;: 2. &lt;/ins&gt;Via the &amp;lt;tt&amp;gt;prepare_binprm()&amp;lt;/tt&amp;gt; function call the UID and GIDs are checked and a call issued to &amp;lt;tt&amp;gt;security_bprm_set()&amp;lt;/tt&amp;gt; that will carry out the following:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; font-size: smaller;&quot;&gt;: a) The &amp;lt;tt&amp;gt;selinux_bprm_set_security()&amp;lt;/tt&amp;gt; function will call the &amp;lt;tt&amp;gt;secondary_ops-&amp;gt;bprm_set_security&amp;lt;/tt&amp;gt; function in &amp;lt;tt&amp;gt;capability.c&amp;lt;/tt&amp;gt;, that is effectively a no-op.&lt;/td&gt;&lt;td&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; font-size: smaller;&quot;&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;:&lt;/ins&gt;: a) The &amp;lt;tt&amp;gt;selinux_bprm_set_security()&amp;lt;/tt&amp;gt; function will call the &amp;lt;tt&amp;gt;secondary_ops-&amp;gt;bprm_set_security&amp;lt;/tt&amp;gt; function in &amp;lt;tt&amp;gt;capability.c&amp;lt;/tt&amp;gt;, that is effectively a no-op.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; font-size: smaller;&quot;&gt;: b) The &amp;lt;tt&amp;gt;bsec-&amp;gt;set&amp;lt;/tt&amp;gt; flag will be checked and if &amp;lt;tt&amp;gt;1&amp;lt;/tt&amp;gt; will return as this function can be called multiple times during the exec process.&lt;/td&gt;&lt;td&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; font-size: smaller;&quot;&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;:&lt;/ins&gt;: b) The &amp;lt;tt&amp;gt;bsec-&amp;gt;set&amp;lt;/tt&amp;gt; flag will be checked and if &amp;lt;tt&amp;gt;1&amp;lt;/tt&amp;gt; will return as this function can be called multiple times during the exec process.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; font-size: smaller;&quot;&gt;: c) The target SID is checked to see whether a transition is required (in this case it is), therefore a call will be made to the &amp;lt;tt&amp;gt;security_transition_sid()&amp;lt;/tt&amp;gt; function in &amp;lt;tt&amp;gt;services.c&amp;lt;/tt&amp;gt;. This function will compute the SID for a new subject or object (subject in this case) via the &amp;lt;tt&amp;gt;security_compute_sid()&amp;lt;/tt&amp;gt; function that will (assuming there are no errors):&lt;/td&gt;&lt;td&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; font-size: smaller;&quot;&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;:&lt;/ins&gt;: c) The target SID is checked to see whether a transition is required (in this case it is), therefore a call will be made to the &amp;lt;tt&amp;gt;security_transition_sid()&amp;lt;/tt&amp;gt; function in &amp;lt;tt&amp;gt;services.c&amp;lt;/tt&amp;gt;. This function will compute the SID for a new subject or object (subject in this case) via the &amp;lt;tt&amp;gt;security_compute_sid()&amp;lt;/tt&amp;gt; function that will (assuming there are no errors):&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; font-size: smaller;&quot;&gt;:: .i.   Search the SID table for the source and target SIDs.&lt;/td&gt;&lt;td&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; font-size: smaller;&quot;&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;:&lt;/ins&gt;:: .i.   Search the SID table for the source and target SIDs.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; font-size: smaller;&quot;&gt;:: .ii.  Sets the SELinux user identity.&lt;/td&gt;&lt;td&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; font-size: smaller;&quot;&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;:&lt;/ins&gt;:: .ii.  Sets the SELinux user identity.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; font-size: smaller;&quot;&gt;:: .iii. Set the source role and type.&lt;/td&gt;&lt;td&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; font-size: smaller;&quot;&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;:&lt;/ins&gt;:: .iii. Set the source role and type.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; font-size: smaller;&quot;&gt;:: .iv.  Checks that a &amp;lt;tt&amp;gt;type_transition&amp;lt;/tt&amp;gt; rule exists in the AV table and / or the conditional AV table (see the [http://taiga.selinuxproject.org/~rhaines/diagrams/12-lsm-selinux-arch.png The Main LSM / SELinux Modules] diagram).&lt;/td&gt;&lt;td&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; font-size: smaller;&quot;&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;:&lt;/ins&gt;:: .iv.  Checks that a &amp;lt;tt&amp;gt;type_transition&amp;lt;/tt&amp;gt; rule exists in the AV table and / or the conditional AV table (see the [http://taiga.selinuxproject.org/~rhaines/diagrams/12-lsm-selinux-arch.png The Main LSM / SELinux Modules] diagram).&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; font-size: smaller;&quot;&gt;:: .v.   If a &amp;lt;tt&amp;gt;type_transition&amp;lt;/tt&amp;gt;, then also check for a &amp;lt;tt&amp;gt;role_transition&amp;lt;/tt&amp;gt; (there is a role change in the &amp;lt;tt&amp;gt;ext_gateway.conf&amp;lt;/tt&amp;gt; policy module), set the role.&lt;/td&gt;&lt;td&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; font-size: smaller;&quot;&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;:&lt;/ins&gt;:: .v.   If a &amp;lt;tt&amp;gt;type_transition&amp;lt;/tt&amp;gt;, then also check for a &amp;lt;tt&amp;gt;role_transition&amp;lt;/tt&amp;gt; (there is a role change in the &amp;lt;tt&amp;gt;ext_gateway.conf&amp;lt;/tt&amp;gt; policy module), set the role.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; font-size: smaller;&quot;&gt;:: .vi.  Check if any MLS attributes by calling &amp;lt;tt&amp;gt;mls_compute_sid()&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;mls.c&amp;lt;/tt&amp;gt;. It also checks whether MLS is enabled or not, if so sets up MLS contexts.&lt;/td&gt;&lt;td&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; font-size: smaller;&quot;&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;:&lt;/ins&gt;:: .vi.  Check if any MLS attributes by calling &amp;lt;tt&amp;gt;mls_compute_sid()&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;mls.c&amp;lt;/tt&amp;gt;. It also checks whether MLS is enabled or not, if so sets up MLS contexts.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; font-size: smaller;&quot;&gt;:: .vii. Check whether the contexts are valid by calling &amp;lt;tt&amp;gt;compute_sid_handle_invalid_context()&amp;lt;/tt&amp;gt; that will also log an audit message if the context is invalid.&lt;/td&gt;&lt;td&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; font-size: smaller;&quot;&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;:&lt;/ins&gt;:: .vii. Check whether the contexts are valid by calling &amp;lt;tt&amp;gt;compute_sid_handle_invalid_context()&amp;lt;/tt&amp;gt; that will also log an audit message if the context is invalid.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; font-size: smaller;&quot;&gt;:: .viii. Finally obtains a SID for the new context by calling &amp;lt;tt&amp;gt;sidtab_context_to_sid()&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;sidtab.c&amp;lt;/tt&amp;gt; that will search the SID table (see the [http://taiga.selinuxproject.org/~rhaines/diagrams/12-lsm-selinux-arch.png The Main LSM / SELinux Modules] diagram) and insert a new entry if okay or log a kernel event if invalid.&lt;/td&gt;&lt;td&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; font-size: smaller;&quot;&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;:&lt;/ins&gt;:: .viii. Finally obtains a SID for the new context by calling &amp;lt;tt&amp;gt;sidtab_context_to_sid()&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;sidtab.c&amp;lt;/tt&amp;gt; that will search the SID table (see the [http://taiga.selinuxproject.org/~rhaines/diagrams/12-lsm-selinux-arch.png The Main LSM / SELinux Modules] diagram) and insert a new entry if okay or log a kernel event if invalid.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; font-size: smaller;&quot;&gt;: d) The &amp;lt;tt&amp;gt;selinux_bprm_set_security()&amp;lt;/tt&amp;gt; function will then continue by checking via the &amp;lt;tt&amp;gt;avc_has_perm()&amp;lt;/tt&amp;gt; function (in &amp;lt;tt&amp;gt;avc.c&amp;lt;/tt&amp;gt;) whether the &amp;lt;tt&amp;gt;file_execute_no_trans&amp;lt;/tt&amp;gt; is set (in this case it is not), therefore the &amp;lt;tt&amp;gt;process_transition&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;file_entrypoint&amp;lt;/tt&amp;gt; permissions are checked (in this case they are), therefore the new SID is set, the &amp;lt;tt&amp;gt;bsec-&amp;gt;set&amp;lt;/tt&amp;gt; flag is set to &amp;lt;tt&amp;gt;1&amp;lt;/tt&amp;gt; so that this part of the function is not executed again for this &amp;lt;tt&amp;gt;exec&amp;lt;/tt&amp;gt;, finally control is passed back to the &amp;lt;tt&amp;gt;do_execve&amp;lt;/tt&amp;gt; function:&lt;/td&gt;&lt;td&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; font-size: smaller;&quot;&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;:&lt;/ins&gt;: d) The &amp;lt;tt&amp;gt;selinux_bprm_set_security()&amp;lt;/tt&amp;gt; function will then continue by checking via the &amp;lt;tt&amp;gt;avc_has_perm()&amp;lt;/tt&amp;gt; function (in &amp;lt;tt&amp;gt;avc.c&amp;lt;/tt&amp;gt;) whether the &amp;lt;tt&amp;gt;file_execute_no_trans&amp;lt;/tt&amp;gt; is set (in this case it is not), therefore the &amp;lt;tt&amp;gt;process_transition&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;file_entrypoint&amp;lt;/tt&amp;gt; permissions are checked (in this case they are), therefore the new SID is set, the &amp;lt;tt&amp;gt;bsec-&amp;gt;set&amp;lt;/tt&amp;gt; flag is set to &amp;lt;tt&amp;gt;1&amp;lt;/tt&amp;gt; so that this part of the function is not executed again for this &amp;lt;tt&amp;gt;exec&amp;lt;/tt&amp;gt;, finally control is passed back to the &amp;lt;tt&amp;gt;do_execve&amp;lt;/tt&amp;gt; function:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; font-size: smaller;&quot;&gt;&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;# &lt;/del&gt;Various strings are copied (args etc.) and a check is made to see if the exec succeeded or not (in this case it did), therefore the &amp;lt;tt&amp;gt;security_bprm_free()&amp;lt;/tt&amp;gt; function is called to free the &amp;lt;tt&amp;gt;bprm&amp;lt;/tt&amp;gt; security structure. &lt;/td&gt;&lt;td&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; font-size: smaller;&quot;&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;: 3. &lt;/ins&gt;Various strings are copied (args etc.) and a check is made to see if the exec succeeded or not (in this case it did), therefore the &amp;lt;tt&amp;gt;security_bprm_free()&amp;lt;/tt&amp;gt; function is called to free the &amp;lt;tt&amp;gt;bprm&amp;lt;/tt&amp;gt; security structure. &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; font-size: smaller;&quot;&gt;&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;# &lt;/del&gt;The End.&lt;/td&gt;&lt;td&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; font-size: smaller;&quot;&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;: 4. &lt;/ins&gt;The End.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; font-size: smaller;&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; font-size: smaller;&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;=== SELinux Filesystem ===&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;=== SELinux Filesystem ===&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</description>
			<pubDate>Mon, 17 May 2010 15:50:51 GMT</pubDate>			<dc:creator>RichardHaines</dc:creator>			<comments>http://selinuxproject.org/page/Talk:NB_LSM</comments>		</item>
		<item>
			<title>RichardHaines: /* Fork System Call Walk-thorough */</title>
			<link>http://selinuxproject.org/w/?title=NB_LSM&amp;diff=956&amp;oldid=prev</link>
			<description>&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Fork System Call Walk-thorough&lt;/span&gt;&lt;/p&gt;

			&lt;table border='0' width='98%' cellpadding='0' cellspacing='4' style=&quot;background-color: white;&quot;&gt;
			&lt;tr&gt;
				&lt;td colspan='2' width='50%' align='center' style=&quot;background-color: white;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' width='50%' align='center' style=&quot;background-color: white;&quot;&gt;Revision as of 15:38, 17 May 2010&lt;/td&gt;
			&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; align=&quot;left&quot;&gt;&lt;strong&gt;Line 204:&lt;/strong&gt;&lt;/td&gt;
&lt;td colspan=&quot;2&quot; align=&quot;left&quot;&gt;&lt;strong&gt;Line 204:&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;:: e) Remove permissions that are defined in any constraint via the &amp;lt;tt&amp;gt;constraint_expr_eval()&amp;lt;/tt&amp;gt; function call (in &amp;lt;tt&amp;gt;services.c&amp;lt;/tt&amp;gt;). This function will also check any MLS constraints.&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;:: e) Remove permissions that are defined in any constraint via the &amp;lt;tt&amp;gt;constraint_expr_eval()&amp;lt;/tt&amp;gt; function call (in &amp;lt;tt&amp;gt;services.c&amp;lt;/tt&amp;gt;). This function will also check any MLS constraints.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;:: f) Finally &amp;lt;tt&amp;gt;context_struct_compute_av()&amp;lt;/tt&amp;gt; checks if a process transition is being requested (it is not). If it were, then the &amp;lt;tt&amp;gt;TRANSITION&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;DYNTRANSITION&amp;lt;/tt&amp;gt; permissions are checked and whether the role is changing.&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;:: f) Finally &amp;lt;tt&amp;gt;context_struct_compute_av()&amp;lt;/tt&amp;gt; checks if a process transition is being requested (it is not). If it were, then the &amp;lt;tt&amp;gt;TRANSITION&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;DYNTRANSITION&amp;lt;/tt&amp;gt; permissions are checked and whether the role is changing.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; font-size: smaller;&quot;&gt;: 8&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;) &lt;/del&gt;Once the result has been computed it is returned to the &amp;lt;tt&amp;gt;kernel/fork.c&amp;lt;/tt&amp;gt; system call via the initial &amp;lt;tt&amp;gt;selinux_task_create()&amp;lt;/tt&amp;gt; function. In this case the fork call is allowed. &lt;/td&gt;&lt;td&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; font-size: smaller;&quot;&gt;: 8&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;. &lt;/ins&gt;Once the result has been computed it is returned to the &amp;lt;tt&amp;gt;kernel/fork.c&amp;lt;/tt&amp;gt; system call via the initial &amp;lt;tt&amp;gt;selinux_task_create()&amp;lt;/tt&amp;gt; function. In this case the fork call is allowed. &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; font-size: smaller;&quot;&gt;: 9&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;) &lt;/del&gt;The End.&lt;/td&gt;&lt;td&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; font-size: smaller;&quot;&gt;: 9&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;. &lt;/ins&gt;The End.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; font-size: smaller;&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;=== Process Transition Walk-thorough ===&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;=== Process Transition Walk-thorough ===&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</description>
			<pubDate>Mon, 17 May 2010 15:38:27 GMT</pubDate>			<dc:creator>RichardHaines</dc:creator>			<comments>http://selinuxproject.org/page/Talk:NB_LSM</comments>		</item>
		<item>
			<title>RichardHaines: New page: = Linux Security Module and SELinux = This section gives a high level overview of the LSM and SELinux internal structure and workings. A more detailed view can be found in the &quot;[http://www...</title>
			<link>http://selinuxproject.org/w/?title=NB_LSM&amp;diff=955&amp;oldid=prev</link>
			<description>&lt;p&gt;New page: = Linux Security Module and SELinux = This section gives a high level overview of the LSM and SELinux internal structure and workings. A more detailed view can be found in the &amp;quot;[http://www...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Linux Security Module and SELinux =&lt;br /&gt;
This section gives a high level overview of the LSM and SELinux internal structure and workings. A more detailed view can be found in the &amp;quot;[http://www.nsa.gov/selinux/papers/module/t1.html Implementing SELinux as a Linux Security Module]&amp;quot; that was used extensively to develop this section (with the SELinux kernel source code). The major areas covered are:&lt;br /&gt;
&lt;br /&gt;
* How the LSM and SELinux modules work together.&lt;br /&gt;
* The major SELinux internal services.&lt;br /&gt;
* The fork system call and exec are followed through as an example to tie in with the transition process covered in the [[NB_Objects#Domain_Transition | Domain and Object Transitions]] section.&lt;br /&gt;
* The SELinux filesystem &amp;lt;tt&amp;gt;/selinux&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* The boot sequences that are relevant to SELinux.&lt;br /&gt;
&lt;br /&gt;
== The LSM Module ==&lt;br /&gt;
The LSM is the Linux security framework that allows 3&amp;lt;sup&amp;gt;rd&amp;lt;/sup&amp;gt; party access control mechanisms to be linked into the GNU / Linux kernel. Currently there are two 3&amp;lt;sup&amp;gt;rd&amp;lt;/sup&amp;gt; party services that utilise the LSM: SELinux and SMACK (Simplified Mandatory Access Control Kernel) that both provide mandatory access control services. Details regarding SMACK can be found at: [http://www.schaufler-ca.com/ http://www.schaufler-ca.com/].&lt;br /&gt;
&lt;br /&gt;
The basic idea behind the LSM is to:&lt;br /&gt;
# Insert security function calls (or hooks) and security data structures in the various kernel services to allow access control to be applied over and above that already implemented via DAC. The type of service that have hooks inserted are shown in Table 1 with an example task and program execution shown in the Fork Walk-thorough and Process Transition Walk-thorough sections below.&lt;br /&gt;
# Allow registration and initialisation services for the 3&amp;lt;sup&amp;gt;rd&amp;lt;/sup&amp;gt; party security modules.&lt;br /&gt;
# Allow process security attributes to be available to userspace services by extending the &amp;lt;tt&amp;gt;/proc&amp;lt;/tt&amp;gt; filesystem with a security namespace.&lt;br /&gt;
# Support filesystems that use extended attributes (SELinux uses &amp;lt;tt&amp;gt;security.selinux&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Consolidate the Linux capabilities into an optional module.&lt;br /&gt;
&lt;br /&gt;
It should be noted that the LSM does not provide any security services itself, only the hooks and structures for supporting 3&amp;lt;sup&amp;gt;rd&amp;lt;/sup&amp;gt; party modules. If no 3&amp;lt;sup&amp;gt;rd&amp;lt;/sup&amp;gt; party module is loaded, the capabilities module becomes the default module thus allowing standard DAC access control.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| Program execution&lt;br /&gt;
| Filesystem operations&lt;br /&gt;
| Inode operations&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| File operations&lt;br /&gt;
| Task operations&lt;br /&gt;
| Netlink messaging&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Unix domain networking&lt;br /&gt;
| Socket operations&lt;br /&gt;
| XFRM operations&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Key Management operations&lt;br /&gt;
| IPC operations&lt;br /&gt;
| Memory Segments&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Semaphores&lt;br /&gt;
| Capability&lt;br /&gt;
| Sysctl&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Syslog&lt;br /&gt;
| Audit&lt;br /&gt;
| &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
''Table 1: LSM Hooks - These are the kernel services that LSM has inserted security hooks and structures to allow access control to be managed by 3&amp;lt;sup&amp;gt;rd&amp;lt;/sup&amp;gt; party modules (see &amp;lt;tt&amp;gt;./kernel-2.6.27/include/linux/security.h&amp;lt;/tt&amp;gt;).''&lt;br /&gt;
&lt;br /&gt;
The major kernel source files (relative to &amp;lt;tt&amp;gt;./kernel-2.6.27/security&amp;lt;/tt&amp;gt;) that form the LSM are shown in Table 2. However there is one major header file (&amp;lt;tt&amp;gt;include/linux/security.h&amp;lt;/tt&amp;gt;) that describes all the security hooks and structures defined by the LSM.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Name&lt;br /&gt;
! Function&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  capability.c&lt;br /&gt;
| Some capability functions were in various kernel modules have been consolidated into these source files. These are now (from Kernel 2.6.27) always linked into the kernel. This means the dummy.c security module (mentioned in the &amp;quot;[http://www.nsa.gov/selinux/papers/module/t1.html Implementing SELinux as a Linux Security Module]&amp;quot; document) is no longer required.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  commoncap.c&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  device_cgroup.c&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  inode.c&lt;br /&gt;
| This allows the 3&amp;lt;sup&amp;gt;rd&amp;lt;/sup&amp;gt; party security module to initialise a security filesystem. In the case of SELinux this would be &amp;lt;tt&amp;gt;/selinux&amp;lt;/tt&amp;gt; that is defined in the &amp;lt;tt&amp;gt;selinux/selinuxfs.c&amp;lt;/tt&amp;gt; source file. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  root_plug.c&lt;br /&gt;
| This is a sample 3&amp;lt;sup&amp;gt;rd&amp;lt;/sup&amp;gt; party module and therefore not used.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  security.c&lt;br /&gt;
| Contains the LSM framework initialisation services that will set up the hooks described in &amp;lt;tt&amp;gt;security.h&amp;lt;/tt&amp;gt; and those in the capability source files. It also provides functions to initialise 3&amp;lt;sup&amp;gt;rd&amp;lt;/sup&amp;gt; party modules. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
''Table 2: The core LSM source modules.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== The SELinux Module ==&lt;br /&gt;
This section does not go into detail of all the SELinux module functionality as the &amp;quot;[http://www.nsa.gov/selinux/papers/module/t1.html Implementing SELinux as a Linux Security Module]&amp;quot; document does this, however it attempts to highlight the way some areas work by using the Fork and Domain Transition Walk-thorough and transition process examples and also by describing the SELinux Boot Process.&lt;br /&gt;
&lt;br /&gt;
The major kernel SELinux source files (relative to &amp;lt;tt&amp;gt;./kernel-2.6.27/security/selinux&amp;lt;/tt&amp;gt;) that form the SELinux security module are shown in Table 3. The diagrams [http://taiga.selinuxproject.org/~rhaines/diagrams/2-high-level-arch.png High Level SELinux Architecture] and [http://taiga.selinuxproject.org/~rhaines/diagrams/12-lsm-selinux-arch.png The Main LSM / SELinux Modules] can be used to see how some of these kernel source modules fit together. &lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Name&lt;br /&gt;
! Function&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  avc.c&lt;br /&gt;
| Access Vector Cache functions and structures. The function calls are for the kernel services, however they have been ported to form the &amp;lt;tt&amp;gt;libselinux&amp;lt;/tt&amp;gt; userspace library detailed in the [[LibselinuxAPISummary | API Summary for libselinux]] section.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  exports.c&lt;br /&gt;
| Exported SELinux services for SECMARK (as there is SELinux specific code in the netfilter source tree).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  hooks.c&lt;br /&gt;
| Contains all the SELinux functions that are called by the kernel resources via the &amp;lt;tt&amp;gt;security_ops&amp;lt;/tt&amp;gt; function table (they form the kernel resource object managers). There are also support functions for managing process exec's, managing SID allocation and removal, interfacing into the AVC and Security Server.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  netif.c&lt;br /&gt;
| These manage the mapping between labels and SIDs for the net* language statements when they are declared in the active policy.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  netnode.c&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  netport.c&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  netlabel.c&lt;br /&gt;
| The interface between NetLabel services and SELinux.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  netlink.c&lt;br /&gt;
| Manages the notification of policy updates to resources including userspace applications via &amp;lt;tt&amp;gt;libselinux&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  nlmsgtab.c&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  selinuxfs.c&lt;br /&gt;
| The &amp;lt;tt&amp;gt;selinuxfs&amp;lt;/tt&amp;gt; pseudo filesystem (&amp;lt;tt&amp;gt;/selinux&amp;lt;/tt&amp;gt;) that exports the security policy to userspace services via &amp;lt;tt&amp;gt;libselinux&amp;lt;/tt&amp;gt;. The services exported are shown in the SELinux Filesystem section below.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  xfrm.c&lt;br /&gt;
| Contains the IPSec XFRM hooks for SELinux.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  include/flask.h&lt;br /&gt;
| This contains all the kernel security classes and initial SIDs. Note that the Reference Policy source (&amp;lt;tt&amp;gt;policy/flask&amp;lt;/tt&amp;gt; directory) contains a list of all the kernel and userspace security classes and permissions. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  ss/avtab.c&lt;br /&gt;
| AVC table functions for inserting / deleting entries.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  ss/conditional.c&lt;br /&gt;
| Support boolean statement functions and implements a conditional AV table to hold entries.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  ss/avtab.c&lt;br /&gt;
| AVC table functions for inserting / deleting entries.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  ss/ebitmap.c&lt;br /&gt;
| Bitmaps to represent sets of values, such as types, roles, categories, and classes.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  ss/hashtab.c&lt;br /&gt;
| Hash table.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  ss/mls.c&lt;br /&gt;
| Functions to support MLS.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  ss/policydb.c&lt;br /&gt;
| Defines the structure of the policy database. See the &amp;quot;[http://securityblog.org/brindle/2006/07/05/selinux-policy-module-primer/ SELinux Policy Module Primer]&amp;quot; article for details on the structure.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  ss/services.c&lt;br /&gt;
| This contains the supporting services for kernel hooks defined in hooks.c, the AVC and the Security Server. &lt;br /&gt;
&lt;br /&gt;
For example the &amp;lt;tt&amp;gt;security_transition_sid&amp;lt;/tt&amp;gt; that computes the SID for a new subject / object shown in the [http://taiga.selinuxproject.org/~rhaines/diagrams/12-lsm-selinux-arch.png The Main LSM / SELinux Modules] diagram.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  ss/sidtab.c&lt;br /&gt;
| The SID table contains the security context indexed by its SID value.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  ss/symtab.c&lt;br /&gt;
| Maintains associations between symbol strings and their values.&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
'''Table 3: The core SELinux source modules - '''''The &amp;lt;tt&amp;gt;.h&amp;lt;/tt&amp;gt; files and those in the &amp;lt;tt&amp;gt;include&amp;lt;/tt&amp;gt; directory have a number of useful comments.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Fork System Call Walk-thorough ===&lt;br /&gt;
This section walks through the the &amp;lt;tt&amp;gt;fork&amp;lt;/tt&amp;gt; system call shown in the [http://taiga.selinuxproject.org/~rhaines/diagrams/7-domain-transition.png Domain Transition] diagram starting at the kernel hooks that link to the SELinux services. The way the SELinux hooks are initialised into the LSM &amp;lt;tt&amp;gt;security_ops&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;secondary_ops&amp;lt;/tt&amp;gt; function tables are also described.&lt;br /&gt;
&lt;br /&gt;
Using the [http://taiga.selinuxproject.org/~rhaines/diagrams/10-Fork.png Hooks for the fork system call] diagram, the major steps to check whether the &amp;lt;tt&amp;gt;unconfined_t&amp;lt;/tt&amp;gt; process has permission to use the fork permission are:&lt;br /&gt;
&lt;br /&gt;
# The &amp;lt;tt&amp;gt;kernel/fork.c&amp;lt;/tt&amp;gt; has a hook that links it to the LSM function &amp;lt;tt&amp;gt;security_task_create()&amp;lt;/tt&amp;gt; that is called to check access permissions. &lt;br /&gt;
# Because the SELinux module has been initialised as the security module, the &amp;lt;tt&amp;gt;security_ops&amp;lt;/tt&amp;gt; table has been set to point to the SELinux &amp;lt;tt&amp;gt;selinux_task_create()&amp;lt;/tt&amp;gt; function in &amp;lt;tt&amp;gt;hooks.c&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# The &amp;lt;tt&amp;gt;selinux_task_create()&amp;lt;/tt&amp;gt; function will first call the capabilities code in &amp;lt;tt&amp;gt;capability.c&amp;lt;/tt&amp;gt; via the &amp;lt;tt&amp;gt;secondary_ops&amp;lt;/tt&amp;gt; function table to check the DAC permission. &lt;br /&gt;
# This is simply a &amp;lt;tt&amp;gt;return 0;&amp;lt;/tt&amp;gt;, therefore no error would be generated.&lt;br /&gt;
# The &amp;lt;tt&amp;gt;selinux_task_create()&amp;lt;/tt&amp;gt; function will then check whether the task has permission via the &amp;lt;tt&amp;gt;task_has_perm(current_process, current_process, PROCESS__FORK)&amp;lt;/tt&amp;gt; function. &lt;br /&gt;
# This will result in a call to the AVC via the &amp;lt;tt&amp;gt;avc_has_perm()&amp;lt;/tt&amp;gt; function in &amp;lt;tt&amp;gt;avc.c&amp;lt;/tt&amp;gt; that checks whether the permission has been granted or not. First (via &amp;lt;tt&amp;gt;avc_has_perm_noaudit()&amp;lt;/tt&amp;gt;) the cache is checked to for an entry. Assuming that there is no entry in the AVC, then the &amp;lt;tt&amp;gt;security_compute_av()&amp;lt;/tt&amp;gt; function in &amp;lt;tt&amp;gt;services.c&amp;lt;/tt&amp;gt; is called.&lt;br /&gt;
# The &amp;lt;tt&amp;gt;security_compute_av()&amp;lt;/tt&amp;gt; function will search the SID table for source and target entries, and if found will then call the &amp;lt;tt&amp;gt;context_struct_compute_av()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
: The &amp;lt;tt&amp;gt;context_struct_compute_av()&amp;lt;/tt&amp;gt; function carries out many check to validate whether access is allowed. The steps are (assuming the access is valid):&lt;br /&gt;
:: a) Initialise the AV structure so that it is clear.&lt;br /&gt;
:: b) Check the object class and permissions are correct. It also checks the status of the &amp;lt;tt&amp;gt;allow_unknown&amp;lt;/tt&amp;gt; flag (see the SELinux Filesystem section below,  [[GlobalConfigurationFiles | /etc/selinux/semanage.conf file]] and [[NB_RefPolicy | Reference Policy Build Options - build.conf]] sections).&lt;br /&gt;
:: c) Checks if there are any type enforcement rules (&amp;lt;tt&amp;gt;ALLOW&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;AUDIT_ALLOW&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;AUDIT_DENY&amp;lt;/tt&amp;gt;).&lt;br /&gt;
:: d) Check whether any conditional statements are involved via the &amp;lt;tt&amp;gt;cond_compute_av()&amp;lt;/tt&amp;gt; function in &amp;lt;tt&amp;gt;conditional.c&amp;lt;/tt&amp;gt;.&lt;br /&gt;
:: e) Remove permissions that are defined in any constraint via the &amp;lt;tt&amp;gt;constraint_expr_eval()&amp;lt;/tt&amp;gt; function call (in &amp;lt;tt&amp;gt;services.c&amp;lt;/tt&amp;gt;). This function will also check any MLS constraints.&lt;br /&gt;
:: f) Finally &amp;lt;tt&amp;gt;context_struct_compute_av()&amp;lt;/tt&amp;gt; checks if a process transition is being requested (it is not). If it were, then the &amp;lt;tt&amp;gt;TRANSITION&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;DYNTRANSITION&amp;lt;/tt&amp;gt; permissions are checked and whether the role is changing.&lt;br /&gt;
: 8) Once the result has been computed it is returned to the &amp;lt;tt&amp;gt;kernel/fork.c&amp;lt;/tt&amp;gt; system call via the initial &amp;lt;tt&amp;gt;selinux_task_create()&amp;lt;/tt&amp;gt; function. In this case the fork call is allowed. &lt;br /&gt;
: 9) The End.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Process Transition Walk-thorough ===&lt;br /&gt;
This section walks through the &amp;lt;tt&amp;gt;execve()&amp;lt;/tt&amp;gt; and checking whether a process transition to the &amp;lt;tt&amp;gt;ext_gateway_t&amp;lt;/tt&amp;gt; domain is allowed, and if so obtain a new SID for the context (&amp;lt;tt&amp;gt;user_u:message_filter_r:ext_gateway_t&amp;lt;/tt&amp;gt;) as shown in the [http://taiga.selinuxproject.org/~rhaines/diagrams/7-domain-transition.png Domain Transition] diagram.&lt;br /&gt;
&lt;br /&gt;
The process starts with the Linux operating system issuing a &amp;lt;tt&amp;gt;do_execve()&amp;lt;ref name=&amp;quot;ftn16&amp;quot;&amp;gt;&amp;lt;tt&amp;gt;This function call will pass over the file name to be run and its environment + arguments. Note that for loading shared libraries the exec_mmap function is used.&amp;lt;/tt&amp;gt;&amp;lt;/ref&amp;gt; call from the CPU specific architecture code to execute a new program (for example, from &amp;lt;tt&amp;gt;arch/ia64/kernel/process.c&amp;lt;/tt&amp;gt;). The &amp;lt;tt&amp;gt;do_execve()&amp;lt;/tt&amp;gt; function is located in the &amp;lt;tt&amp;gt;fs/exec.c&amp;lt;/tt&amp;gt; source code module and does the loading and final exec as described below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;do_execve()&amp;lt;/tt&amp;gt; has a number of calls to &amp;lt;tt&amp;gt;security_bprm_*&amp;lt;/tt&amp;gt; functions that are a part of the LSM (see &amp;lt;tt&amp;gt;security.h&amp;lt;/tt&amp;gt;), and are hooked by SELinux during the initialisation process (in &amp;lt;tt&amp;gt;hooks.c&amp;lt;/tt&amp;gt;). Table 4 briefly describes these &amp;lt;tt&amp;gt;security_bprm&amp;lt;/tt&amp;gt; functions that are hooks for validating program loading and execution (although see &amp;lt;tt&amp;gt;security.h&amp;lt;/tt&amp;gt; for greater detail).&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''LSM / SElinux Function Name'''&lt;br /&gt;
| '''Description'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  security_bprm_alloc-&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 selinux_bprm_alloc_security&lt;br /&gt;
| Allocates memory for the &amp;lt;tt&amp;gt;bprm&amp;lt;/tt&amp;gt; structure.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  security_bprm_free-&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 selinux_bprm_free_security&lt;br /&gt;
| Frees memory from the &amp;lt;tt&amp;gt;bprm&amp;lt;/tt&amp;gt; structure.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  security_bprm_apply_creds-&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 selinux_bprm_apply_creds&lt;br /&gt;
| Sets task lock and new security attributes for a transformed process on execve. Seems to be used for libraries, scripts etc. Called from various Linux OS areas via &amp;lt;tt&amp;gt;compute_creds()&amp;lt;/tt&amp;gt; located in &amp;lt;tt&amp;gt;fs/exec.c&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  security_bprm_post_apply_creds-&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 selinux_bprm_post_apply_creds&lt;br /&gt;
| Supports the &amp;lt;tt&amp;gt;security_bprm_apply_creds&amp;lt;/tt&amp;gt; function for areas that must not be locked.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  security_bprm_secureexec-&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 selinux_bprm_secureexec&lt;br /&gt;
| Called after the &amp;lt;tt&amp;gt;selinux_bprm_post_apply_creds&amp;lt;/tt&amp;gt; function to check &amp;lt;tt&amp;gt;AT_SECURE&amp;lt;/tt&amp;gt; flag for glibc secure mode support.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  security_bprm_set-&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 selinux_bprm_set_security&lt;br /&gt;
| Carries out the major checks to validate whether the process can transition to the target context, and obtain a new SID if required.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  security_bprm_check-&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 selinux_bprm_check_security&lt;br /&gt;
| This hook is not used by SELinux.&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
''Table 4: The LSM / SELinux Program Loading Hooks''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Therefore starting at the &amp;lt;tt&amp;gt;do_execve()&amp;lt;/tt&amp;gt; function and using the [http://taiga.selinuxproject.org/~rhaines/diagrams/11-Transition.png | Process Transition] diagram, the following major steps will be carried out to check whether the &amp;lt;tt&amp;gt;unconfined_t&amp;lt;/tt&amp;gt; process has permission to transition the &amp;lt;tt&amp;gt;secure_server&amp;lt;/tt&amp;gt; executable to the &amp;lt;tt&amp;gt;ext_gateway_t&amp;lt;/tt&amp;gt; domain:&lt;br /&gt;
&lt;br /&gt;
# The executable file is opened, a call issued to the &amp;lt;tt&amp;gt;sched_exec()&amp;lt;/tt&amp;gt; function and the &amp;lt;tt&amp;gt;bprm&amp;lt;/tt&amp;gt; structure is initialised with the file parameters (name, environment and arguments). &lt;br /&gt;
: The &amp;lt;tt&amp;gt;security_bprm_alloc()-&amp;gt;selinux_bprm_alloc_security()&amp;lt;/tt&amp;gt; function is then called (in &amp;lt;tt&amp;gt;hooks.c&amp;lt;/tt&amp;gt;) where SELinux will allocate memory for the &amp;lt;tt&amp;gt;bprm&amp;lt;/tt&amp;gt; security structure and set the &amp;lt;tt&amp;gt;bsec-&amp;gt;set&amp;lt;/tt&amp;gt; flag to &amp;lt;tt&amp;gt;0&amp;lt;/tt&amp;gt; indicating this is the first time through this process for this exec request.&lt;br /&gt;
# Via the &amp;lt;tt&amp;gt;prepare_binprm()&amp;lt;/tt&amp;gt; function call the UID and GIDs are checked and a call issued to &amp;lt;tt&amp;gt;security_bprm_set()&amp;lt;/tt&amp;gt; that will carry out the following:&lt;br /&gt;
: a) The &amp;lt;tt&amp;gt;selinux_bprm_set_security()&amp;lt;/tt&amp;gt; function will call the &amp;lt;tt&amp;gt;secondary_ops-&amp;gt;bprm_set_security&amp;lt;/tt&amp;gt; function in &amp;lt;tt&amp;gt;capability.c&amp;lt;/tt&amp;gt;, that is effectively a no-op.&lt;br /&gt;
: b) The &amp;lt;tt&amp;gt;bsec-&amp;gt;set&amp;lt;/tt&amp;gt; flag will be checked and if &amp;lt;tt&amp;gt;1&amp;lt;/tt&amp;gt; will return as this function can be called multiple times during the exec process.&lt;br /&gt;
: c) The target SID is checked to see whether a transition is required (in this case it is), therefore a call will be made to the &amp;lt;tt&amp;gt;security_transition_sid()&amp;lt;/tt&amp;gt; function in &amp;lt;tt&amp;gt;services.c&amp;lt;/tt&amp;gt;. This function will compute the SID for a new subject or object (subject in this case) via the &amp;lt;tt&amp;gt;security_compute_sid()&amp;lt;/tt&amp;gt; function that will (assuming there are no errors):&lt;br /&gt;
:: .i.   Search the SID table for the source and target SIDs.&lt;br /&gt;
:: .ii.  Sets the SELinux user identity.&lt;br /&gt;
:: .iii. Set the source role and type.&lt;br /&gt;
:: .iv.  Checks that a &amp;lt;tt&amp;gt;type_transition&amp;lt;/tt&amp;gt; rule exists in the AV table and / or the conditional AV table (see the [http://taiga.selinuxproject.org/~rhaines/diagrams/12-lsm-selinux-arch.png The Main LSM / SELinux Modules] diagram).&lt;br /&gt;
:: .v.   If a &amp;lt;tt&amp;gt;type_transition&amp;lt;/tt&amp;gt;, then also check for a &amp;lt;tt&amp;gt;role_transition&amp;lt;/tt&amp;gt; (there is a role change in the &amp;lt;tt&amp;gt;ext_gateway.conf&amp;lt;/tt&amp;gt; policy module), set the role.&lt;br /&gt;
:: .vi.  Check if any MLS attributes by calling &amp;lt;tt&amp;gt;mls_compute_sid()&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;mls.c&amp;lt;/tt&amp;gt;. It also checks whether MLS is enabled or not, if so sets up MLS contexts.&lt;br /&gt;
:: .vii. Check whether the contexts are valid by calling &amp;lt;tt&amp;gt;compute_sid_handle_invalid_context()&amp;lt;/tt&amp;gt; that will also log an audit message if the context is invalid.&lt;br /&gt;
:: .viii. Finally obtains a SID for the new context by calling &amp;lt;tt&amp;gt;sidtab_context_to_sid()&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;sidtab.c&amp;lt;/tt&amp;gt; that will search the SID table (see the [http://taiga.selinuxproject.org/~rhaines/diagrams/12-lsm-selinux-arch.png The Main LSM / SELinux Modules] diagram) and insert a new entry if okay or log a kernel event if invalid.&lt;br /&gt;
: d) The &amp;lt;tt&amp;gt;selinux_bprm_set_security()&amp;lt;/tt&amp;gt; function will then continue by checking via the &amp;lt;tt&amp;gt;avc_has_perm()&amp;lt;/tt&amp;gt; function (in &amp;lt;tt&amp;gt;avc.c&amp;lt;/tt&amp;gt;) whether the &amp;lt;tt&amp;gt;file_execute_no_trans&amp;lt;/tt&amp;gt; is set (in this case it is not), therefore the &amp;lt;tt&amp;gt;process_transition&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;file_entrypoint&amp;lt;/tt&amp;gt; permissions are checked (in this case they are), therefore the new SID is set, the &amp;lt;tt&amp;gt;bsec-&amp;gt;set&amp;lt;/tt&amp;gt; flag is set to &amp;lt;tt&amp;gt;1&amp;lt;/tt&amp;gt; so that this part of the function is not executed again for this &amp;lt;tt&amp;gt;exec&amp;lt;/tt&amp;gt;, finally control is passed back to the &amp;lt;tt&amp;gt;do_execve&amp;lt;/tt&amp;gt; function:&lt;br /&gt;
# Various strings are copied (args etc.) and a check is made to see if the exec succeeded or not (in this case it did), therefore the &amp;lt;tt&amp;gt;security_bprm_free()&amp;lt;/tt&amp;gt; function is called to free the &amp;lt;tt&amp;gt;bprm&amp;lt;/tt&amp;gt; security structure. &lt;br /&gt;
# The End.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== SELinux Filesystem ===&lt;br /&gt;
Table 5 shows the information contained in the pseudo file system /selinux where the SELinux kernel exports relevant information regarding its configuration and active policy for use by the [[LibselinuxAPISummary | libselinux API]] library (that is used by user-space object managers and SELinux-aware applications).&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! &amp;lt;center&amp;gt;Directory / File Name&amp;lt;/center&amp;gt;&lt;br /&gt;
! &amp;lt;center&amp;gt;Permissions&amp;lt;/center&amp;gt;&lt;br /&gt;
! &amp;lt;center&amp;gt;Comments&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| '''/selinux'''&lt;br /&gt;
| &amp;lt;center&amp;gt;'''Directory'''&amp;lt;/center&amp;gt;&lt;br /&gt;
| This is the root directory where the SELinux kernel exports relevant information regarding its configuration and active policy for use by the libselinux library (that is used by user space object managers and SELinux-aware applications).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div align=&amp;quot;right&amp;quot;&amp;gt;access&amp;lt;/div&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;-rw-rw-rw-&amp;lt;/center&amp;gt;&lt;br /&gt;
| Compute access decision interface.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div align=&amp;quot;right&amp;quot;&amp;gt;checkreqprot&amp;lt;/div&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;-rw-r--r--&amp;lt;/center&amp;gt;&lt;br /&gt;
| Check requested protection, not kernel-applied one.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div align=&amp;quot;right&amp;quot;&amp;gt;commit_pending_bools&amp;lt;/div&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;--w-------&amp;lt;/center&amp;gt;&lt;br /&gt;
| Commit new boolean values to the kernel policy.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div align=&amp;quot;right&amp;quot;&amp;gt;compat_net&amp;lt;/div&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;-rw-r--r--&amp;lt;/center&amp;gt;&lt;br /&gt;
| Whether SECMARK is enabled or not:&lt;br /&gt;
&lt;br /&gt;
0 = SECMARK enabled (F-12 default).&lt;br /&gt;
&lt;br /&gt;
1 = SECMARK disabled&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div align=&amp;quot;right&amp;quot;&amp;gt;context&amp;lt;/div&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;-rw-rw-rw-&amp;lt;/center&amp;gt;&lt;br /&gt;
| Validate context interface.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div align=&amp;quot;right&amp;quot;&amp;gt;create&amp;lt;/div&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;-rw-rw-rw-&amp;lt;/center&amp;gt;&lt;br /&gt;
| Compute create labeling decision interface.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div align=&amp;quot;right&amp;quot;&amp;gt;deny_unknown&amp;lt;/div&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;-r--r--r--&amp;lt;/center&amp;gt;&lt;br /&gt;
| These two files export unknown deny and reject handling status to user space. This is taken from the handle-unknown parameter set&amp;lt;ref name=&amp;quot;ftn17&amp;quot;&amp;gt;&amp;lt;sup&amp;gt;That is taken from the UNK_PERMS entry in the Reference Policy build.conf  file.&amp;lt;/sup&amp;gt;&amp;lt;/ref&amp;gt; in the /etc/selinux/semanage.conf file and are set as follows:&lt;br /&gt;
&lt;br /&gt;
0:0 = allow, 1:0 = deny and 1:1 = reject.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div align=&amp;quot;right&amp;quot;&amp;gt;reject_unknown&amp;lt;/div&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;-r--r--r--&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div align=&amp;quot;right&amp;quot;&amp;gt;disable&amp;lt;/div&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;--w-------&amp;lt;/center&amp;gt;&lt;br /&gt;
| Disable SELinux until next reboot.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div align=&amp;quot;right&amp;quot;&amp;gt;enforce&amp;lt;/div&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;-rw-r--r--&amp;lt;/center&amp;gt;&lt;br /&gt;
| Get or set enforcing status. Used by the setenforce(8) command.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div align=&amp;quot;right&amp;quot;&amp;gt;load&amp;lt;/div&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;-rw-------&amp;lt;/center&amp;gt;&lt;br /&gt;
| Load policy interface.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div align=&amp;quot;right&amp;quot;&amp;gt;member&amp;lt;/div&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;-rw-rw-rw-&amp;lt;/center&amp;gt;&lt;br /&gt;
| Compute polyinstantiation membership decision interface.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div align=&amp;quot;right&amp;quot;&amp;gt;mls&amp;lt;/div&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;-r--r--r--&amp;lt;/center&amp;gt;&lt;br /&gt;
| Returns 1 if MLS policy is enabled or 0 if not.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div align=&amp;quot;right&amp;quot;&amp;gt;null&amp;lt;/div&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;crw-rw-rw-&amp;lt;/center&amp;gt;&lt;br /&gt;
| &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div align=&amp;quot;right&amp;quot;&amp;gt;policyvers&amp;lt;/div&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;-r--r--r--&amp;lt;/center&amp;gt;&lt;br /&gt;
| Returns policy version for this kernel (F-12 = 24).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div align=&amp;quot;right&amp;quot;&amp;gt;relabel&amp;lt;/div&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;-rw-rw-rw-&amp;lt;/center&amp;gt;&lt;br /&gt;
| Compute relabeling decision interface.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div align=&amp;quot;right&amp;quot;&amp;gt;user&amp;lt;/div&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;-rw-rw-rw-&amp;lt;/center&amp;gt;&lt;br /&gt;
| Compute reachable user contexts interface.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| '''/selinux/avc'''&lt;br /&gt;
| &amp;lt;center&amp;gt;'''Directory'''&amp;lt;/center&amp;gt;&lt;br /&gt;
| This directory contains information regarding the kernel AVC that can be displayed by the avcstat command.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div align=&amp;quot;right&amp;quot;&amp;gt;cache_stats&amp;lt;/div&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;-r--r--r--&amp;lt;/center&amp;gt;&lt;br /&gt;
| Shows the AVC lookups, hits, misses etc.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div align=&amp;quot;right&amp;quot;&amp;gt;cache_threshold&amp;lt;/div&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;-rw-r--r--&amp;lt;/center&amp;gt;&lt;br /&gt;
| The default value is 512, however caching can be turned off (but performance suffers) by:&lt;br /&gt;
&lt;br /&gt;
 echo 0 &amp;gt; /selinux/avc/cache_threshold&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div align=&amp;quot;right&amp;quot;&amp;gt;hash_stats&amp;lt;/div&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;-r--r--r--&amp;lt;/center&amp;gt;&lt;br /&gt;
| Shows the number of AVC entries, longest chain etc.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| '''/selinux/booleans'''&lt;br /&gt;
| &amp;lt;center&amp;gt;'''Directory'''&amp;lt;/center&amp;gt;&lt;br /&gt;
| This directory contains one file for each boolean defined in the active policy.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div align=&amp;quot;right&amp;quot;&amp;gt;secmark_audit&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div align=&amp;quot;right&amp;quot;&amp;gt;......&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div align=&amp;quot;right&amp;quot;&amp;gt;......&amp;lt;/div&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;-rw-r--r--&amp;lt;/center&amp;gt;&lt;br /&gt;
| Each file contains the current status of the boolean (0 = false or 1 = true). The getsebool(8), setsebool(8) and sestatus -b commands use this information.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| '''/selinux/initial_contexts'''&lt;br /&gt;
| &amp;lt;center&amp;gt;'''Directory'''&amp;lt;/center&amp;gt;&lt;br /&gt;
| This directory contains one file for each initial SID defined in the active policy.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div align=&amp;quot;right&amp;quot;&amp;gt;any_socket&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div align=&amp;quot;right&amp;quot;&amp;gt;devnull&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div align=&amp;quot;right&amp;quot;&amp;gt;.....&amp;lt;/div&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;-r--r--r--&amp;lt;/center&amp;gt;&lt;br /&gt;
| Each file contains the initial context of the initial SID as defined in the active policy (e.g. any_socket was assigned system_u:object_r:unconfined_t).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| '''/selinux/policy_capabilities'''&lt;br /&gt;
| &amp;lt;center&amp;gt;'''Directory'''&amp;lt;/center&amp;gt;&lt;br /&gt;
| This directory contains the policy capabilities that have been configured by default in the kernel. They are generally new features that can be enabled for testing by using the policycap statement in a monolithic or base policy.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div align=&amp;quot;right&amp;quot;&amp;gt;network_peer_controls&amp;lt;/div&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;-r--r--r--&amp;lt;/center&amp;gt;&lt;br /&gt;
| For the F-12 kernel, this file contains &amp;quot;0&amp;quot; (false) which means that the following network_peer_controls are not enabled by default:&lt;br /&gt;
&lt;br /&gt;
node: sendto recvfrom&lt;br /&gt;
&lt;br /&gt;
netif: ingress egress&lt;br /&gt;
&lt;br /&gt;
peer: recv&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div align=&amp;quot;right&amp;quot;&amp;gt;open_perms&amp;lt;/div&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;-r--r--r--&amp;lt;/center&amp;gt;&lt;br /&gt;
| For the F-12 kernel, this file contains &amp;quot;0&amp;quot; (false) which means that open permissions are not enabled by default on the following objects: dir, file, fifo_file, chr_file, blk_file.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| '''/selinux/class'''&lt;br /&gt;
| &amp;lt;center&amp;gt;'''Directory'''&amp;lt;/center&amp;gt;&lt;br /&gt;
| This directory contains a list of classes and their permissions as defined within the policy.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| '''/selinux/class/appletalk_socket'''&lt;br /&gt;
| &amp;lt;center&amp;gt;'''Directory'''&amp;lt;/center&amp;gt;&lt;br /&gt;
| Each class has its own directory that contains the following: &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div align=&amp;quot;right&amp;quot;&amp;gt;index&amp;lt;/div&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;-r--r--r--&amp;lt;/center&amp;gt;&lt;br /&gt;
| This file contains the allocated class number (e.g. appletalk_socket is &amp;quot;56&amp;quot; in flask.h (linux-2.6.27/security/selinux/include/flask.h)).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| '''/selinux/class/appletalk_socket/'''&lt;br /&gt;
&lt;br /&gt;
'''perms'''&lt;br /&gt;
| &amp;lt;center&amp;gt;'''Directory'''&amp;lt;/center&amp;gt;&lt;br /&gt;
| This directory contains one file for each permission defined in the policy.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;div align=&amp;quot;right&amp;quot;&amp;gt;accept&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div align=&amp;quot;right&amp;quot;&amp;gt;append&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div align=&amp;quot;right&amp;quot;&amp;gt;bind&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div align=&amp;quot;right&amp;quot;&amp;gt;....&amp;lt;/div&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;-r--r--r--&amp;lt;/center&amp;gt;&lt;br /&gt;
| Each file contains a number but not sure what it represents.&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
''Table 5: /selinux File and Directory Information''&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
&lt;br /&gt;
# SIDs are not passed to userspace, only the security context string. The context can be read via the  [[LibselinuxAPISummary | libselinux API]] where a userspace object manager normally manages the relationship (see &amp;quot;SELinux Support for Userspace Object Managers&amp;quot; [Ref. 17]).&lt;br /&gt;
# The &amp;lt;tt&amp;gt;/proc&amp;lt;/tt&amp;gt; filesystem exports the process security context string to userspace via &amp;lt;tt&amp;gt;/proc/&amp;lt;pid&amp;gt;/attr&amp;lt;/tt&amp;gt; interface (where &amp;lt;tt&amp;gt;&amp;lt;pid&amp;gt;&amp;lt;/tt&amp;gt; is the process ID). These can also be managed via the the  [[LibselinuxAPISummary | libselinux API]].&lt;br /&gt;
&lt;br /&gt;
=== SELinux Boot Process ===&lt;br /&gt;
Figure 1 shows the boot process that has been limited to what is considered relevant for initialising SELinux&amp;lt;ref name=&amp;quot;ftn18&amp;quot;&amp;gt;There is a Linux overview at: [http://en.wikipedia.org/wiki/Linux_startup_process http://en.wikipedia.org/wiki/Linux_startup_process].&amp;lt;/ref&amp;gt;, loading the policy and checking whether re-labeling is required. The SELinux kernel initialisation areas are in red. The &amp;lt;tt&amp;gt;kernel&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;mkinitrd&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;upstart&amp;lt;/tt&amp;gt; source code rpms were used to find the sequence of events (all corrections welcome).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;'''Start Kernel Boot Process'''&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;|&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;./init/main.c start_kernel()&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;|&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;Load the initial RAM Disk (this is a temporary root filesystem). The source &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;code for this and &amp;lt;tt&amp;gt;nash(8)&amp;lt;/tt&amp;gt; is in the &amp;lt;tt&amp;gt;mkinitrd&amp;lt;/tt&amp;gt; source code.&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;| &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;Kernel calls &amp;lt;tt&amp;gt;security_init()&amp;lt;/tt&amp;gt; to initialise the LSM security framework. &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;For SELinux this results in a call to &amp;lt;tt&amp;gt;selinux_init()&amp;lt;/tt&amp;gt; that is in &amp;lt;tt&amp;gt;hooks.c&amp;lt;/tt&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;|&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;Set the kernel context to the initial SID value &amp;quot;&amp;lt;tt&amp;gt;1&amp;lt;/tt&amp;gt;&amp;quot; taken from&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;tt&amp;gt;include/flask.h&amp;lt;/tt&amp;gt; (&amp;lt;tt&amp;gt;SECINITSID_KERNEL&amp;lt;/tt&amp;gt;) &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;|&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;The AVC is initialised by a call to &amp;lt;tt&amp;gt;avc_init()&amp;lt;/tt&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;|&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;Other areas of SELinux get initialised such as the &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;tt&amp;gt;selinuxfs&amp;lt;/tt&amp;gt; (&amp;lt;tt&amp;gt;/selinux&amp;lt;/tt&amp;gt;) pseudo filesystem and netlink with their &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;objects set with the initial SIDs from &amp;lt;tt&amp;gt;flask.h&amp;lt;/tt&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;|&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;tt&amp;gt;'''/sbin/nash is run by the kernel&amp;lt;/tt&amp;gt;.'''&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;|&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;tt&amp;gt;/sbin/nash&amp;lt;/tt&amp;gt; initialises services such as drivers, loads the root filesystem&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;read-only and loads the SELinux policy using the &amp;lt;tt&amp;gt;loadPolicyCommand&amp;lt;/tt&amp;gt;. &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;This function will check various directories, then call the SELinux API&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;the  selinux_init_load_policy function to load the policy.&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;|&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;Loading the policy will now complete the SELinux initialisation &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;with a call to &amp;lt;tt&amp;gt;selinux_complete_init()&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;hooks.c&amp;lt;/tt&amp;gt;. &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;SELinux will now start enforcing policy or allow permissive access &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;depending on the value set in &amp;lt;tt&amp;gt;/etc/selinux/config SELINUX=&amp;lt;/tt&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;|&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;The kernel is now loaded, the RAM disk removed, SELinux is &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;initialised, the policy loaded and &amp;lt;tt&amp;gt;/sbin/init&amp;lt;/tt&amp;gt; is running &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;with the root filesystem in read only mode.&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;|&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;'''End Kernel Load and Initialisation'''&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;|&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;tt&amp;gt;'''/etc/rc.d/sysinit&amp;lt;/tt&amp;gt; is run by &amp;lt;tt&amp;gt;init &amp;lt;/tt&amp;gt;that will:'''&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;|&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;mount &amp;lt;tt&amp;gt;/proc&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sysfs&amp;lt;/tt&amp;gt; filesystems&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;|&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;Check that the &amp;lt;tt&amp;gt;selinuxfs&amp;lt;/tt&amp;gt; (&amp;lt;tt&amp;gt;/selinux&amp;lt;/tt&amp;gt;) pseudo filesystem&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;is present and whether the current process is labeled &amp;lt;tt&amp;gt;kernel_t&amp;lt;/tt&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;|&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;If the current SELinux state can be read (&amp;lt;tt&amp;gt;/selinux/enforce&amp;lt;/tt&amp;gt;), &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;then set to value. If cannot read, set to &amp;quot;1&amp;quot;.&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;|&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;Run r&amp;lt;tt&amp;gt;estorecon -R&amp;lt;/tt&amp;gt; on /&amp;lt;tt&amp;gt;dev&amp;lt;/tt&amp;gt; if needed.&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;|&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;Kill off &amp;lt;tt&amp;gt;/sbin/nash&amp;lt;/tt&amp;gt; if it is still running.&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;|&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;Run &amp;lt;tt&amp;gt;restorecon&amp;lt;/tt&amp;gt; on &amp;lt;tt&amp;gt;/dev/pts&amp;lt;/tt&amp;gt; if needed.&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;|&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;Set contexts on the files in &amp;lt;tt&amp;gt;/etc/rwtab&amp;lt;/tt&amp;gt; and /&amp;lt;tt&amp;gt;etc/statetab&amp;lt;/tt&amp;gt; &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;by running &amp;lt;tt&amp;gt;restorecon -R path&amp;lt;/tt&amp;gt;.&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;|&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;Check if relabeling required:&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;if &amp;lt;tt&amp;gt;./autorelabel&amp;lt;/tt&amp;gt; file + &amp;lt;tt&amp;gt;AUTORELABEL=0&amp;lt;/tt&amp;gt; (in &amp;lt;tt&amp;gt;/etc/selinux/config&amp;lt;/tt&amp;gt;):&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;then drop to shell for manual relabel, or &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;if only &amp;lt;tt&amp;gt;./autorelabel&amp;lt;/tt&amp;gt; file, then run &amp;lt;tt&amp;gt;fixfiles -F restore&amp;lt;/tt&amp;gt;.&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;|&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;remove &amp;lt;tt&amp;gt;./autorelabel&amp;lt;/tt&amp;gt; file.&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;|&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;If &amp;lt;tt&amp;gt;/sbin/init&amp;lt;/tt&amp;gt; has changed context after the relabel, &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;then ensure a reboot. ELSE carry on.&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;|&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;tt&amp;gt;/etc/rc.d/sysinit&amp;lt;/tt&amp;gt; will do other initialisation tasks, then exit.&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;|&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;'''Note:''' Some SELinux notes state that &amp;lt;tt&amp;gt;/sbin/init&amp;lt;/tt&amp;gt; is re-exec&amp;quot;ed &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;to allow it to run in the correct context. Could not find where this&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;happened as policy seems to be active before &amp;lt;tt&amp;gt;init&amp;lt;/tt&amp;gt; daemon is run ?? &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;|&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;'''Initialisation Complete'''&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''Figure 1: The Boot Sequence - This shows how SELinux is initialised and the policy loaded during the boot process.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</description>
			<pubDate>Mon, 17 May 2010 15:34:13 GMT</pubDate>			<dc:creator>RichardHaines</dc:creator>			<comments>http://selinuxproject.org/page/Talk:NB_LSM</comments>		</item>
	</channel>
</rss>