All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] repost: new sockcreate interface to specify context of socket when they are created
@ 2006-06-21 15:08 Eric Paris
  2006-06-21 15:37 ` James Morris
  2006-06-21 16:03 ` Stephen Smalley
  0 siblings, 2 replies; 13+ messages in thread
From: Eric Paris @ 2006-06-21 15:08 UTC (permalink / raw)
  To: selinux; +Cc: kmacmillan, sds, jmorris

Updated to fix the style problems James pointed out.  Retested to make
sure it was still working.

Below is a patch to add a new /proc/self/attr/sockcreate   A process may
write a context into this interface and all subsequent sockets created
will be labeled with that context.  This is the same idea as the
fscreate interface where a process can specify the label of a file about
to be created.  At this time one envisioned user of this will be xinetd.
It will be able to better label sockets for the actual services.  At
this time all sockets take the label of the creating process, so all
xinitd sockets would just be labeled the same.

I tested this by creating a tcp sender and listener.  The sender was
able to write to this new proc file and then create sockets with the
specified label.  I am able to be sure the new label was used since the
avc denial messages kicked out by the kernel included both the new
security permission setsockcreate and all the socket denials were for
the new label, not the label of the running process.

I would like to propose this for 2.6.18

Signed-off-by: Eric Paris <eparis@redhat.com>

 fs/proc/base.c                               |    6 ++++++
 security/selinux/hooks.c                     |   20 ++++++++++++++++----
 security/selinux/include/av_perm_to_string.h |    1 +
 security/selinux/include/av_permissions.h    |    1 +
 security/selinux/include/objsec.h            |    1 +
 5 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/fs/proc/base.c b/fs/proc/base.c
index 6cc77dc..4f9bf8f 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -121,6 +121,7 @@ #ifdef CONFIG_SECURITY
 	PROC_TGID_ATTR_PREV,
 	PROC_TGID_ATTR_EXEC,
 	PROC_TGID_ATTR_FSCREATE,
+	PROC_TGID_ATTR_SOCKCREATE,
 #endif
 #ifdef CONFIG_AUDITSYSCALL
 	PROC_TGID_LOGINUID,
@@ -162,6 +163,7 @@ #ifdef CONFIG_SECURITY
 	PROC_TID_ATTR_PREV,
 	PROC_TID_ATTR_EXEC,
 	PROC_TID_ATTR_FSCREATE,
+	PROC_TID_ATTR_SOCKCREATE,
 #endif
 #ifdef CONFIG_AUDITSYSCALL
 	PROC_TID_LOGINUID,
@@ -275,6 +277,7 @@ static struct pid_entry tgid_attr_stuff[
 	E(PROC_TGID_ATTR_PREV,     "prev",     S_IFREG|S_IRUGO),
 	E(PROC_TGID_ATTR_EXEC,     "exec",     S_IFREG|S_IRUGO|S_IWUGO),
 	E(PROC_TGID_ATTR_FSCREATE, "fscreate", S_IFREG|S_IRUGO|S_IWUGO),
+	E(PROC_TGID_ATTR_SOCKCREATE, "sockcreate", S_IFREG|S_IRUGO|S_IWUGO),
 	{0,0,NULL,0}
 };
 static struct pid_entry tid_attr_stuff[] = {
@@ -282,6 +285,7 @@ static struct pid_entry tid_attr_stuff[]
 	E(PROC_TID_ATTR_PREV,      "prev",     S_IFREG|S_IRUGO),
 	E(PROC_TID_ATTR_EXEC,      "exec",     S_IFREG|S_IRUGO|S_IWUGO),
 	E(PROC_TID_ATTR_FSCREATE,  "fscreate", S_IFREG|S_IRUGO|S_IWUGO),
+	E(PROC_TID_ATTR_SOCKCREATE, "sockcreate", S_IFREG|S_IRUGO|S_IWUGO),
 	{0,0,NULL,0}
 };
 #endif
@@ -1800,6 +1804,8 @@ #ifdef CONFIG_SECURITY
 		case PROC_TGID_ATTR_EXEC:
 		case PROC_TID_ATTR_FSCREATE:
 		case PROC_TGID_ATTR_FSCREATE:
+		case PROC_TID_ATTR_SOCKCREATE:
+		case PROC_TGID_ATTR_SOCKCREATE:
 			inode->i_fop = &proc_pid_attr_operations;
 			break;
 #endif
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 90b4cdc..33e035c 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -1518,8 +1518,9 @@ static int selinux_bprm_set_security(str
 	/* Default to the current task SID. */
 	bsec->sid = tsec->sid;
 
-	/* Reset create SID on execve. */
+	/* Reset create and sockcreate SID on execve. */
 	tsec->create_sid = 0;
+	tsec->sockcreate_sid = 0;
 
 	if (tsec->exec_sid) {
 		newsid = tsec->exec_sid;
@@ -2571,9 +2572,10 @@ static int selinux_task_alloc_security(s
 	tsec2->osid = tsec1->osid;
 	tsec2->sid = tsec1->sid;
 
-	/* Retain the exec and create SIDs across fork */
+	/* Retain the exec, create, and sock SIDs across fork */
 	tsec2->exec_sid = tsec1->exec_sid;
 	tsec2->create_sid = tsec1->create_sid;
+	tsec2->sockcreate_sid = tsec1->sockcreate_sid;
 
 	/* Retain ptracer SID across fork, if any.
 	   This will be reset by the ptrace hook upon any
@@ -2913,12 +2915,14 @@ static int selinux_socket_create(int fam
 {
 	int err = 0;
 	struct task_security_struct *tsec;
+	u32 newsid;
 
 	if (kern)
 		goto out;
 
 	tsec = current->security;
-	err = avc_has_perm(tsec->sid, tsec->sid,
+	newsid = tsec->sockcreate_sid ? : tsec->sid;
+	err = avc_has_perm(tsec->sid, newsid,
 			   socket_type_to_security_class(family, type,
 			   protocol), SOCKET__CREATE, NULL);
 
@@ -2931,12 +2935,14 @@ static void selinux_socket_post_create(s
 {
 	struct inode_security_struct *isec;
 	struct task_security_struct *tsec;
+	u32 newsid;
 
 	isec = SOCK_INODE(sock)->i_security;
 
 	tsec = current->security;
+	newsid = tsec->sockcreate_sid ? : tsec->sid;
 	isec->sclass = socket_type_to_security_class(family, type, protocol);
-	isec->sid = kern ? SECINITSID_KERNEL : tsec->sid;
+	isec->sid = kern ? SECINITSID_KERNEL : newsid;
 	isec->initialized = 1;
 
 	return;
@@ -4114,6 +4120,8 @@ static int selinux_getprocattr(struct ta
 		sid = tsec->exec_sid;
 	else if (!strcmp(name, "fscreate"))
 		sid = tsec->create_sid;
+	else if (!strcmp(name, "sockcreate"))
+		sid = tsec->sockcreate_sid;
 	else
 		return -EINVAL;
 
@@ -4146,6 +4154,8 @@ static int selinux_setprocattr(struct ta
 		error = task_has_perm(current, p, PROCESS__SETEXEC);
 	else if (!strcmp(name, "fscreate"))
 		error = task_has_perm(current, p, PROCESS__SETFSCREATE);
+	else if (!strcmp(name, "sockcreate"))
+		error = task_has_perm(current, p, PROCESS__SETSOCKCREATE);
 	else if (!strcmp(name, "current"))
 		error = task_has_perm(current, p, PROCESS__SETCURRENT);
 	else
@@ -4175,6 +4185,8 @@ static int selinux_setprocattr(struct ta
 		tsec->exec_sid = sid;
 	else if (!strcmp(name, "fscreate"))
 		tsec->create_sid = sid;
+	else if (!strcmp(name, "sockcreate"))
+		tsec->sockcreate_sid = sid;
 	else if (!strcmp(name, "current")) {
 		struct av_decision avd;
 
diff --git a/security/selinux/include/av_perm_to_string.h b/security/selinux/include/av_perm_to_string.h
index 591e98d..ce3a55d 100644
--- a/security/selinux/include/av_perm_to_string.h
+++ b/security/selinux/include/av_perm_to_string.h
@@ -63,6 +63,7 @@
    S_(SECCLASS_PROCESS, PROCESS__GETATTR, "getattr")
    S_(SECCLASS_PROCESS, PROCESS__SETEXEC, "setexec")
    S_(SECCLASS_PROCESS, PROCESS__SETFSCREATE, "setfscreate")
+   S_(SECCLASS_PROCESS, PROCESS__SETSOCKCREATE, "setsockcreate")
    S_(SECCLASS_PROCESS, PROCESS__NOATSECURE, "noatsecure")
    S_(SECCLASS_PROCESS, PROCESS__SIGINH, "siginh")
    S_(SECCLASS_PROCESS, PROCESS__SETRLIMIT, "setrlimit")
diff --git a/security/selinux/include/av_permissions.h b/security/selinux/include/av_permissions.h
index d7f02ed..2a9a9b3 100644
--- a/security/selinux/include/av_permissions.h
+++ b/security/selinux/include/av_permissions.h
@@ -467,6 +467,7 @@ #define PROCESS__SETCURRENT             
 #define PROCESS__EXECMEM                          0x02000000UL
 #define PROCESS__EXECSTACK                        0x04000000UL
 #define PROCESS__EXECHEAP                         0x08000000UL
+#define PROCESS__SETSOCKCREATE                    0x10000000UL
 
 #define IPC__CREATE                               0x00000001UL
 #define IPC__DESTROY                              0x00000002UL
diff --git a/security/selinux/include/objsec.h b/security/selinux/include/objsec.h
index 54c0307..1873451 100644
--- a/security/selinux/include/objsec.h
+++ b/security/selinux/include/objsec.h
@@ -32,6 +32,7 @@ struct task_security_struct {
 	u32 sid;             /* current SID */
 	u32 exec_sid;        /* exec SID */
 	u32 create_sid;      /* fscreate SID */
+	u32 sockcreate_sid;  /* fscreate SID */
 	u32 ptrace_sid;      /* SID of ptrace parent */
 };
 



--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH] repost: new sockcreate interface to specify context of socket when they are created
  2006-06-21 15:08 [PATCH] repost: new sockcreate interface to specify context of socket when they are created Eric Paris
@ 2006-06-21 15:37 ` James Morris
  2006-06-21 15:54   ` Eric Paris
  2006-06-21 16:03 ` Stephen Smalley
  1 sibling, 1 reply; 13+ messages in thread
From: James Morris @ 2006-06-21 15:37 UTC (permalink / raw)
  To: Eric Paris; +Cc: selinux, kmacmillan, sds

On Wed, 21 Jun 2006, Eric Paris wrote:

>     S_(SECCLASS_PROCESS, PROCESS__SETEXEC, "setexec")
>     S_(SECCLASS_PROCESS, PROCESS__SETFSCREATE, "setfscreate")
> +   S_(SECCLASS_PROCESS, PROCESS__SETSOCKCREATE, "setsockcreate")

Did you manually place this here, or was it done by mkaccess_vector.sh in 
the policy package?


-- 
James Morris
<jmorris@namei.org>

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] repost: new sockcreate interface to specify context of socket when they are created
  2006-06-21 15:37 ` James Morris
@ 2006-06-21 15:54   ` Eric Paris
  2006-06-21 16:08     ` Stephen Smalley
  0 siblings, 1 reply; 13+ messages in thread
From: Eric Paris @ 2006-06-21 15:54 UTC (permalink / raw)
  To: James Morris; +Cc: selinux, kmacmillan, sds

On Wed, 2006-06-21 at 11:37 -0400, James Morris wrote:
> On Wed, 21 Jun 2006, Eric Paris wrote:
> 
> >     S_(SECCLASS_PROCESS, PROCESS__SETEXEC, "setexec")
> >     S_(SECCLASS_PROCESS, PROCESS__SETFSCREATE, "setfscreate")
> > +   S_(SECCLASS_PROCESS, PROCESS__SETSOCKCREATE, "setsockcreate")
> 
> Did you manually place this here, or was it done by mkaccess_vector.sh in 
> the policy package?
> 
> 
Manually.   /me goes to look at mkaccess_vector.sh

-Eric


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] repost: new sockcreate interface to specify context of socket when they are created
  2006-06-21 15:08 [PATCH] repost: new sockcreate interface to specify context of socket when they are created Eric Paris
  2006-06-21 15:37 ` James Morris
@ 2006-06-21 16:03 ` Stephen Smalley
  2006-06-21 16:22   ` James Morris
  2006-06-21 19:46   ` Christopher J. PeBenito
  1 sibling, 2 replies; 13+ messages in thread
From: Stephen Smalley @ 2006-06-21 16:03 UTC (permalink / raw)
  To: Eric Paris; +Cc: selinux, kmacmillan, jmorris

On Wed, 2006-06-21 at 11:08 -0400, Eric Paris wrote:
> Updated to fix the style problems James pointed out.  Retested to make
> sure it was still working.
> 
> Below is a patch to add a new /proc/self/attr/sockcreate   A process may
> write a context into this interface and all subsequent sockets created
> will be labeled with that context.  This is the same idea as the
> fscreate interface where a process can specify the label of a file about
> to be created.  At this time one envisioned user of this will be xinetd.
> It will be able to better label sockets for the actual services.  At
> this time all sockets take the label of the creating process, so all
> xinitd sockets would just be labeled the same.
> 
> I tested this by creating a tcp sender and listener.  The sender was
> able to write to this new proc file and then create sockets with the
> specified label.  I am able to be sure the new label was used since the
> avc denial messages kicked out by the kernel included both the new
> security permission setsockcreate and all the socket denials were for
> the new label, not the label of the running process.
> 
> I would like to propose this for 2.6.18

/proc/self/attr/keycreate is in -mm, so this patch won't apply relative
to it.  Permission definition also has to be regenerated relative to the
keycreate refpolicy patch, as that took the same permission slot.

> 
> Signed-off-by: Eric Paris <eparis@redhat.com>
> 
>  fs/proc/base.c                               |    6 ++++++
>  security/selinux/hooks.c                     |   20 ++++++++++++++++----
>  security/selinux/include/av_perm_to_string.h |    1 +
>  security/selinux/include/av_permissions.h    |    1 +
>  security/selinux/include/objsec.h            |    1 +
>  5 files changed, 25 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/proc/base.c b/fs/proc/base.c
> index 6cc77dc..4f9bf8f 100644
> --- a/fs/proc/base.c
> +++ b/fs/proc/base.c
> @@ -121,6 +121,7 @@ #ifdef CONFIG_SECURITY
>  	PROC_TGID_ATTR_PREV,
>  	PROC_TGID_ATTR_EXEC,
>  	PROC_TGID_ATTR_FSCREATE,
> +	PROC_TGID_ATTR_SOCKCREATE,
>  #endif
>  #ifdef CONFIG_AUDITSYSCALL
>  	PROC_TGID_LOGINUID,
> @@ -162,6 +163,7 @@ #ifdef CONFIG_SECURITY
>  	PROC_TID_ATTR_PREV,
>  	PROC_TID_ATTR_EXEC,
>  	PROC_TID_ATTR_FSCREATE,
> +	PROC_TID_ATTR_SOCKCREATE,
>  #endif
>  #ifdef CONFIG_AUDITSYSCALL
>  	PROC_TID_LOGINUID,
> @@ -275,6 +277,7 @@ static struct pid_entry tgid_attr_stuff[
>  	E(PROC_TGID_ATTR_PREV,     "prev",     S_IFREG|S_IRUGO),
>  	E(PROC_TGID_ATTR_EXEC,     "exec",     S_IFREG|S_IRUGO|S_IWUGO),
>  	E(PROC_TGID_ATTR_FSCREATE, "fscreate", S_IFREG|S_IRUGO|S_IWUGO),
> +	E(PROC_TGID_ATTR_SOCKCREATE, "sockcreate", S_IFREG|S_IRUGO|S_IWUGO),
>  	{0,0,NULL,0}
>  };
>  static struct pid_entry tid_attr_stuff[] = {
> @@ -282,6 +285,7 @@ static struct pid_entry tid_attr_stuff[]
>  	E(PROC_TID_ATTR_PREV,      "prev",     S_IFREG|S_IRUGO),
>  	E(PROC_TID_ATTR_EXEC,      "exec",     S_IFREG|S_IRUGO|S_IWUGO),
>  	E(PROC_TID_ATTR_FSCREATE,  "fscreate", S_IFREG|S_IRUGO|S_IWUGO),
> +	E(PROC_TID_ATTR_SOCKCREATE, "sockcreate", S_IFREG|S_IRUGO|S_IWUGO),
>  	{0,0,NULL,0}
>  };
>  #endif
> @@ -1800,6 +1804,8 @@ #ifdef CONFIG_SECURITY
>  		case PROC_TGID_ATTR_EXEC:
>  		case PROC_TID_ATTR_FSCREATE:
>  		case PROC_TGID_ATTR_FSCREATE:
> +		case PROC_TID_ATTR_SOCKCREATE:
> +		case PROC_TGID_ATTR_SOCKCREATE:
>  			inode->i_fop = &proc_pid_attr_operations;
>  			break;
>  #endif
> diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
> index 90b4cdc..33e035c 100644
> --- a/security/selinux/hooks.c
> +++ b/security/selinux/hooks.c
> @@ -1518,8 +1518,9 @@ static int selinux_bprm_set_security(str
>  	/* Default to the current task SID. */
>  	bsec->sid = tsec->sid;
>  
> -	/* Reset create SID on execve. */
> +	/* Reset create and sockcreate SID on execve. */
>  	tsec->create_sid = 0;
> +	tsec->sockcreate_sid = 0;
>  
>  	if (tsec->exec_sid) {
>  		newsid = tsec->exec_sid;
> @@ -2571,9 +2572,10 @@ static int selinux_task_alloc_security(s
>  	tsec2->osid = tsec1->osid;
>  	tsec2->sid = tsec1->sid;
>  
> -	/* Retain the exec and create SIDs across fork */
> +	/* Retain the exec, create, and sock SIDs across fork */
>  	tsec2->exec_sid = tsec1->exec_sid;
>  	tsec2->create_sid = tsec1->create_sid;
> +	tsec2->sockcreate_sid = tsec1->sockcreate_sid;
>  
>  	/* Retain ptracer SID across fork, if any.
>  	   This will be reset by the ptrace hook upon any
> @@ -2913,12 +2915,14 @@ static int selinux_socket_create(int fam
>  {
>  	int err = 0;
>  	struct task_security_struct *tsec;
> +	u32 newsid;
>  
>  	if (kern)
>  		goto out;
>  
>  	tsec = current->security;
> -	err = avc_has_perm(tsec->sid, tsec->sid,
> +	newsid = tsec->sockcreate_sid ? : tsec->sid;
> +	err = avc_has_perm(tsec->sid, newsid,
>  			   socket_type_to_security_class(family, type,
>  			   protocol), SOCKET__CREATE, NULL);
>  
> @@ -2931,12 +2935,14 @@ static void selinux_socket_post_create(s
>  {
>  	struct inode_security_struct *isec;
>  	struct task_security_struct *tsec;
> +	u32 newsid;
>  
>  	isec = SOCK_INODE(sock)->i_security;
>  
>  	tsec = current->security;
> +	newsid = tsec->sockcreate_sid ? : tsec->sid;
>  	isec->sclass = socket_type_to_security_class(family, type, protocol);
> -	isec->sid = kern ? SECINITSID_KERNEL : tsec->sid;
> +	isec->sid = kern ? SECINITSID_KERNEL : newsid;
>  	isec->initialized = 1;
>  
>  	return;
> @@ -4114,6 +4120,8 @@ static int selinux_getprocattr(struct ta
>  		sid = tsec->exec_sid;
>  	else if (!strcmp(name, "fscreate"))
>  		sid = tsec->create_sid;
> +	else if (!strcmp(name, "sockcreate"))
> +		sid = tsec->sockcreate_sid;
>  	else
>  		return -EINVAL;
>  
> @@ -4146,6 +4154,8 @@ static int selinux_setprocattr(struct ta
>  		error = task_has_perm(current, p, PROCESS__SETEXEC);
>  	else if (!strcmp(name, "fscreate"))
>  		error = task_has_perm(current, p, PROCESS__SETFSCREATE);
> +	else if (!strcmp(name, "sockcreate"))
> +		error = task_has_perm(current, p, PROCESS__SETSOCKCREATE);
>  	else if (!strcmp(name, "current"))
>  		error = task_has_perm(current, p, PROCESS__SETCURRENT);
>  	else
> @@ -4175,6 +4185,8 @@ static int selinux_setprocattr(struct ta
>  		tsec->exec_sid = sid;
>  	else if (!strcmp(name, "fscreate"))
>  		tsec->create_sid = sid;
> +	else if (!strcmp(name, "sockcreate"))
> +		tsec->sockcreate_sid = sid;
>  	else if (!strcmp(name, "current")) {
>  		struct av_decision avd;
>  
> diff --git a/security/selinux/include/av_perm_to_string.h b/security/selinux/include/av_perm_to_string.h
> index 591e98d..ce3a55d 100644
> --- a/security/selinux/include/av_perm_to_string.h
> +++ b/security/selinux/include/av_perm_to_string.h
> @@ -63,6 +63,7 @@
>     S_(SECCLASS_PROCESS, PROCESS__GETATTR, "getattr")
>     S_(SECCLASS_PROCESS, PROCESS__SETEXEC, "setexec")
>     S_(SECCLASS_PROCESS, PROCESS__SETFSCREATE, "setfscreate")
> +   S_(SECCLASS_PROCESS, PROCESS__SETSOCKCREATE, "setsockcreate")
>     S_(SECCLASS_PROCESS, PROCESS__NOATSECURE, "noatsecure")
>     S_(SECCLASS_PROCESS, PROCESS__SIGINH, "siginh")
>     S_(SECCLASS_PROCESS, PROCESS__SETRLIMIT, "setrlimit")
> diff --git a/security/selinux/include/av_permissions.h b/security/selinux/include/av_permissions.h
> index d7f02ed..2a9a9b3 100644
> --- a/security/selinux/include/av_permissions.h
> +++ b/security/selinux/include/av_permissions.h
> @@ -467,6 +467,7 @@ #define PROCESS__SETCURRENT             
>  #define PROCESS__EXECMEM                          0x02000000UL
>  #define PROCESS__EXECSTACK                        0x04000000UL
>  #define PROCESS__EXECHEAP                         0x08000000UL
> +#define PROCESS__SETSOCKCREATE                    0x10000000UL
>  
>  #define IPC__CREATE                               0x00000001UL
>  #define IPC__DESTROY                              0x00000002UL
> diff --git a/security/selinux/include/objsec.h b/security/selinux/include/objsec.h
> index 54c0307..1873451 100644
> --- a/security/selinux/include/objsec.h
> +++ b/security/selinux/include/objsec.h
> @@ -32,6 +32,7 @@ struct task_security_struct {
>  	u32 sid;             /* current SID */
>  	u32 exec_sid;        /* exec SID */
>  	u32 create_sid;      /* fscreate SID */
> +	u32 sockcreate_sid;  /* fscreate SID */
>  	u32 ptrace_sid;      /* SID of ptrace parent */
>  };
>  
> 
> 
> 
> --
> This message was distributed to subscribers of the selinux mailing list.
> If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
> the words "unsubscribe selinux" without quotes as the message.
-- 
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] repost: new sockcreate interface to specify context of socket when they are created
  2006-06-21 15:54   ` Eric Paris
@ 2006-06-21 16:08     ` Stephen Smalley
  0 siblings, 0 replies; 13+ messages in thread
From: Stephen Smalley @ 2006-06-21 16:08 UTC (permalink / raw)
  To: Eric Paris; +Cc: James Morris, selinux, kmacmillan

On Wed, 2006-06-21 at 11:54 -0400, Eric Paris wrote:
> On Wed, 2006-06-21 at 11:37 -0400, James Morris wrote:
> > On Wed, 21 Jun 2006, Eric Paris wrote:
> > 
> > >     S_(SECCLASS_PROCESS, PROCESS__SETEXEC, "setexec")
> > >     S_(SECCLASS_PROCESS, PROCESS__SETFSCREATE, "setfscreate")
> > > +   S_(SECCLASS_PROCESS, PROCESS__SETSOCKCREATE, "setsockcreate")
> > 
> > Did you manually place this here, or was it done by mkaccess_vector.sh in 
> > the policy package?
> > 
> > 
> Manually.   /me goes to look at mkaccess_vector.sh

/* This file is automatically generated.  Do not edit. */

What you need to do is patch the refpolicy/policy/flask/access_vectors
file (with keycreate patch applied first), then run make in that
subdirectory to regenerate the headers, then copy them over to your
linux-2.6.x/security/selinux/include tree by hand or by running make
LINUXDIR=/path/to/linux-2.6.x tokern.  You can also update the
libselinux ones if you like (make LIBSEL=/path/to/libselinux tolib), but
that is only necessary if the permission definition is being used by
some application (userspace object manager, like dbus or X).  

-- 
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] repost: new sockcreate interface to specify context of socket when they are created
  2006-06-21 16:03 ` Stephen Smalley
@ 2006-06-21 16:22   ` James Morris
  2006-06-21 16:57     ` James Morris
  2006-06-21 19:46   ` Christopher J. PeBenito
  1 sibling, 1 reply; 13+ messages in thread
From: James Morris @ 2006-06-21 16:22 UTC (permalink / raw)
  To: Stephen Smalley; +Cc: Eric Paris, selinux, kmacmillan

On Wed, 21 Jun 2006, Stephen Smalley wrote:
> 
> /proc/self/attr/keycreate is in -mm, so this patch won't apply relative
> to it.  Permission definition also has to be regenerated relative to the
> keycreate refpolicy patch, as that took the same permission slot.

I'm manually merging with -mm now.


- James
-- 
James Morris
<jmorris@namei.org>

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] repost: new sockcreate interface to specify context of socket when they are created
  2006-06-21 16:22   ` James Morris
@ 2006-06-21 16:57     ` James Morris
  0 siblings, 0 replies; 13+ messages in thread
From: James Morris @ 2006-06-21 16:57 UTC (permalink / raw)
  To: Stephen Smalley; +Cc: Eric Paris, selinux, kmacmillan

Btw, we only have room for two permissions now in the process class:

#define PROCESS__SETSOCKCREATE                    0x20000000UL



-- 
James Morris
<jmorris@namei.org>

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] repost: new sockcreate interface to specify context of socket when they are created
  2006-06-21 16:03 ` Stephen Smalley
  2006-06-21 16:22   ` James Morris
@ 2006-06-21 19:46   ` Christopher J. PeBenito
  2006-06-21 19:50     ` Stephen Smalley
  1 sibling, 1 reply; 13+ messages in thread
From: Christopher J. PeBenito @ 2006-06-21 19:46 UTC (permalink / raw)
  To: Stephen Smalley; +Cc: Eric Paris, selinux, kmacmillan, jmorris, Michael LeMay

On Wed, 2006-06-21 at 12:03 -0400, Stephen Smalley wrote:
> On Wed, 2006-06-21 at 11:08 -0400, Eric Paris wrote:
> > Below is a patch to add a new /proc/self/attr/sockcreate
[cut]
> /proc/self/attr/keycreate is in -mm, so this patch won't apply relative
> to it.  Permission definition also has to be regenerated relative to the
> keycreate refpolicy patch, as that took the same permission slot.

I'm going to need a patch for refpolicy that has the the final ordering
of permissions with key and sockcreate patches.  I haven't added the key
class at all yet since I have been waiting for the perm set to finalize.

-- 
Chris PeBenito
Tresys Technology, LLC
(410) 290-1411 x150



--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] repost: new sockcreate interface to specify context of socket when they are created
  2006-06-21 19:46   ` Christopher J. PeBenito
@ 2006-06-21 19:50     ` Stephen Smalley
  2006-06-21 20:23       ` Christopher J. PeBenito
  0 siblings, 1 reply; 13+ messages in thread
From: Stephen Smalley @ 2006-06-21 19:50 UTC (permalink / raw)
  To: Christopher J. PeBenito
  Cc: Eric Paris, selinux, kmacmillan, jmorris, Michael LeMay

On Wed, 2006-06-21 at 15:46 -0400, Christopher J. PeBenito wrote:
> On Wed, 2006-06-21 at 12:03 -0400, Stephen Smalley wrote:
> > On Wed, 2006-06-21 at 11:08 -0400, Eric Paris wrote:
> > > Below is a patch to add a new /proc/self/attr/sockcreate
> [cut]
> > /proc/self/attr/keycreate is in -mm, so this patch won't apply relative
> > to it.  Permission definition also has to be regenerated relative to the
> > keycreate refpolicy patch, as that took the same permission slot.
> 
> I'm going to need a patch for refpolicy that has the the final ordering
> of permissions with key and sockcreate patches.  I haven't added the key
> class at all yet since I have been waiting for the perm set to finalize.

Apply the key+keycreate patch first.  sockcreate refpolicy patch has to
be re-based and re-submitted, but the kernel patch has already been
re-based and submitted.

-- 
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] repost: new sockcreate interface to specify context of socket when they are created
  2006-06-21 19:50     ` Stephen Smalley
@ 2006-06-21 20:23       ` Christopher J. PeBenito
  2006-06-21 20:25         ` Michael LeMay
  0 siblings, 1 reply; 13+ messages in thread
From: Christopher J. PeBenito @ 2006-06-21 20:23 UTC (permalink / raw)
  To: Stephen Smalley; +Cc: Eric Paris, selinux, kmacmillan, jmorris, Michael LeMay

On Wed, 2006-06-21 at 15:50 -0400, Stephen Smalley wrote:
> On Wed, 2006-06-21 at 15:46 -0400, Christopher J. PeBenito wrote:
> > On Wed, 2006-06-21 at 12:03 -0400, Stephen Smalley wrote:
> > > On Wed, 2006-06-21 at 11:08 -0400, Eric Paris wrote:
> > > > Below is a patch to add a new /proc/self/attr/sockcreate
> > [cut]
> > > /proc/self/attr/keycreate is in -mm, so this patch won't apply relative
> > > to it.  Permission definition also has to be regenerated relative to the
> > > keycreate refpolicy patch, as that took the same permission slot.
> > 
> > I'm going to need a patch for refpolicy that has the the final ordering
> > of permissions with key and sockcreate patches.  I haven't added the key
> > class at all yet since I have been waiting for the perm set to finalize.
> 
> Apply the key+keycreate patch first.  sockcreate refpolicy patch has to
> be re-based and re-submitted, but the kernel patch has already been
> re-based and submitted.

Is the one from June 2nd the right one ([PATCH] refpolicy: Kernel access
key retention policy support) to start, and then the one from yesterday
that has setkeycreate?

-- 
Chris PeBenito
Tresys Technology, LLC
(410) 290-1411 x150



--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] repost: new sockcreate interface to specify context of socket when they are created
  2006-06-21 20:23       ` Christopher J. PeBenito
@ 2006-06-21 20:25         ` Michael LeMay
  2006-06-21 21:07           ` Christopher J. PeBenito
  0 siblings, 1 reply; 13+ messages in thread
From: Michael LeMay @ 2006-06-21 20:25 UTC (permalink / raw)
  To: Christopher J. PeBenito
  Cc: Stephen Smalley, Eric Paris, selinux, kmacmillan, jmorris

Yes, but make sure you use the one from June 2nd that has the class
"key", not "retained_key".  Thanks!

On Wed, 2006-06-21 at 16:23 -0400, Christopher J. PeBenito wrote:
> On Wed, 2006-06-21 at 15:50 -0400, Stephen Smalley wrote:
> > On Wed, 2006-06-21 at 15:46 -0400, Christopher J. PeBenito wrote:
> > > On Wed, 2006-06-21 at 12:03 -0400, Stephen Smalley wrote:
> > > > On Wed, 2006-06-21 at 11:08 -0400, Eric Paris wrote:
> > > > > Below is a patch to add a new /proc/self/attr/sockcreate
> > > [cut]
> > > > /proc/self/attr/keycreate is in -mm, so this patch won't apply relative
> > > > to it.  Permission definition also has to be regenerated relative to the
> > > > keycreate refpolicy patch, as that took the same permission slot.
> > > 
> > > I'm going to need a patch for refpolicy that has the the final ordering
> > > of permissions with key and sockcreate patches.  I haven't added the key
> > > class at all yet since I have been waiting for the perm set to finalize.
> > 
> > Apply the key+keycreate patch first.  sockcreate refpolicy patch has to
> > be re-based and re-submitted, but the kernel patch has already been
> > re-based and submitted.
> 
> Is the one from June 2nd the right one ([PATCH] refpolicy: Kernel access
> key retention policy support) to start, and then the one from yesterday
> that has setkeycreate?
> 


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] repost: new sockcreate interface to specify context of socket when they are created
  2006-06-21 20:25         ` Michael LeMay
@ 2006-06-21 21:07           ` Christopher J. PeBenito
  2006-06-21 21:24             ` Michael LeMay
  0 siblings, 1 reply; 13+ messages in thread
From: Christopher J. PeBenito @ 2006-06-21 21:07 UTC (permalink / raw)
  To: Michael LeMay; +Cc: Stephen Smalley, Eric Paris, selinux, kmacmillan, jmorris

[-- Attachment #1: Type: text/plain, Size: 1661 bytes --]

On Wed, 2006-06-21 at 16:25 -0400, Michael LeMay wrote:
> Yes, but make sure you use the one from June 2nd that has the class
> "key", not "retained_key".  Thanks!

I have committed the attached patch for keys to refpolicy, please
doublecheck that this is correct.  I changed the raw rules to interfaces
too.

> On Wed, 2006-06-21 at 16:23 -0400, Christopher J. PeBenito wrote:
> > On Wed, 2006-06-21 at 15:50 -0400, Stephen Smalley wrote:
> > > On Wed, 2006-06-21 at 15:46 -0400, Christopher J. PeBenito wrote:
> > > > On Wed, 2006-06-21 at 12:03 -0400, Stephen Smalley wrote:
> > > > > On Wed, 2006-06-21 at 11:08 -0400, Eric Paris wrote:
> > > > > > Below is a patch to add a new /proc/self/attr/sockcreate
> > > > [cut]
> > > > > /proc/self/attr/keycreate is in -mm, so this patch won't apply relative
> > > > > to it.  Permission definition also has to be regenerated relative to the
> > > > > keycreate refpolicy patch, as that took the same permission slot.
> > > > 
> > > > I'm going to need a patch for refpolicy that has the the final ordering
> > > > of permissions with key and sockcreate patches.  I haven't added the key
> > > > class at all yet since I have been waiting for the perm set to finalize.
> > > 
> > > Apply the key+keycreate patch first.  sockcreate refpolicy patch has to
> > > be re-based and re-submitted, but the kernel patch has already been
> > > re-based and submitted.
> > 
> > Is the one from June 2nd the right one ([PATCH] refpolicy: Kernel access
> > key retention policy support) to start, and then the one from yesterday
> > that has setkeycreate?
> > 
> 
-- 
Chris PeBenito
Tresys Technology, LLC
(410) 290-1411 x150


[-- Attachment #2: refpolicy-key.diff --]
[-- Type: text/x-patch, Size: 3835 bytes --]

Index: policy/flask/security_classes
===================================================================
--- policy/flask/security_classes	(revision 1890)
+++ policy/flask/security_classes	(working copy)
@@ -90,4 +90,7 @@
 
 class packet
 
+# Kernel access key retention
+class key
+
 # FLASK
Index: policy/flask/access_vectors
===================================================================
--- policy/flask/access_vectors	(revision 1890)
+++ policy/flask/access_vectors	(working copy)
@@ -252,6 +252,7 @@
 	execmem
 	execstack
 	execheap
+	setkeycreate
 }
 
 
@@ -617,3 +618,14 @@
 	recv
 	relabelto
 }
+
+class key
+{
+	view
+	read
+	write
+	search
+	link
+	setattr
+	create
+}
Index: policy/modules/services/xserver.te
===================================================================
--- policy/modules/services/xserver.te	(revision 1890)
+++ policy/modules/services/xserver.te	(working copy)
@@ -80,7 +80,7 @@
 #
 
 allow xdm_t self:capability { setgid setuid sys_resource kill sys_tty_config mknod chown dac_override dac_read_search fowner fsetid ipc_owner sys_nice sys_rawio net_bind_service };
-allow xdm_t self:process { setexec setpgid setsched setrlimit signal_perms };
+allow xdm_t self:process { setexec setpgid setsched setrlimit signal_perms setkeycreate };
 allow xdm_t self:fifo_file rw_file_perms;
 allow xdm_t self:shm create_shm_perms;
 allow xdm_t self:sem create_sem_perms;
@@ -214,6 +214,7 @@
 
 userdom_dontaudit_use_unpriv_user_fds(xdm_t)
 userdom_dontaudit_search_sysadm_home_dirs(xdm_t)
+userdom_create_all_users_keys(xdm_t)
 # for .dmrc
 userdom_read_unpriv_users_home_content_files(xdm_t)
 # Search /proc for any user domain processes.
Index: policy/modules/system/locallogin.te
===================================================================
--- policy/modules/system/locallogin.te	(revision 1890)
+++ policy/modules/system/locallogin.te	(working copy)
@@ -169,6 +169,7 @@
 userdom_search_all_users_home_content(local_login_t)
 userdom_use_unpriv_users_fds(local_login_t)
 userdom_sigchld_all_users(local_login_t)
+userdom_create_all_users_keys(local_login_t)
 
 # Search for mail spool file.
 mta_getattr_spool(local_login_t)
Index: policy/modules/system/userdomain.if
===================================================================
--- policy/modules/system/userdomain.if	(revision 1890)
+++ policy/modules/system/userdomain.if	(working copy)
@@ -4732,6 +4732,28 @@
 
 ########################################
 ## <summary>
+##	Create keys for all user domains.
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.
+##	</summary>
+## </param>
+#
+interface(`userdom_create_all_users_keys',`
+	ifdef(`strict_policy',`
+		gen_require(`
+			attribute userdomain;
+		')
+
+		allow $1 userdomain:key create;
+	',`
+		unconfined_create_keys($1)
+	')
+')
+
+########################################
+## <summary>
 ##	Send a dbus message to all user domains.
 ## </summary>
 ## <param name="domain">
Index: policy/modules/system/unconfined.if
===================================================================
--- policy/modules/system/unconfined.if	(revision 1890)
+++ policy/modules/system/unconfined.if	(working copy)
@@ -360,6 +360,24 @@
 
 ########################################
 ## <summary>
+##	Create keys for the unconfined domain.
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.
+##	</summary>
+## </param>
+#
+interface(`unconfined_create_keys',`
+	gen_require(`
+		type unconfined_t;
+	')
+
+	allow $1 unconfined_t:key create;
+')
+
+########################################
+## <summary>
 ##	Send messages to the unconfined domain over dbus.
 ## </summary>
 ## <param name="domain">

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] repost: new sockcreate interface to specify context of socket when they are created
  2006-06-21 21:07           ` Christopher J. PeBenito
@ 2006-06-21 21:24             ` Michael LeMay
  0 siblings, 0 replies; 13+ messages in thread
From: Michael LeMay @ 2006-06-21 21:24 UTC (permalink / raw)
  To: Christopher J. PeBenito
  Cc: Stephen Smalley, Eric Paris, selinux, kmacmillan, jmorris

That looks great, thanks for creating the interfaces.

On Wed, 2006-06-21 at 17:07 -0400, Christopher J. PeBenito wrote:
> On Wed, 2006-06-21 at 16:25 -0400, Michael LeMay wrote:
> > Yes, but make sure you use the one from June 2nd that has the class
> > "key", not "retained_key".  Thanks!
> 
> I have committed the attached patch for keys to refpolicy, please
> doublecheck that this is correct.  I changed the raw rules to interfaces
> too.
> 
> > On Wed, 2006-06-21 at 16:23 -0400, Christopher J. PeBenito wrote:
> > > On Wed, 2006-06-21 at 15:50 -0400, Stephen Smalley wrote:
> > > > On Wed, 2006-06-21 at 15:46 -0400, Christopher J. PeBenito wrote:
> > > > > On Wed, 2006-06-21 at 12:03 -0400, Stephen Smalley wrote:
> > > > > > On Wed, 2006-06-21 at 11:08 -0400, Eric Paris wrote:
> > > > > > > Below is a patch to add a new /proc/self/attr/sockcreate
> > > > > [cut]
> > > > > > /proc/self/attr/keycreate is in -mm, so this patch won't apply relative
> > > > > > to it.  Permission definition also has to be regenerated relative to the
> > > > > > keycreate refpolicy patch, as that took the same permission slot.
> > > > > 
> > > > > I'm going to need a patch for refpolicy that has the the final ordering
> > > > > of permissions with key and sockcreate patches.  I haven't added the key
> > > > > class at all yet since I have been waiting for the perm set to finalize.
> > > > 
> > > > Apply the key+keycreate patch first.  sockcreate refpolicy patch has to
> > > > be re-based and re-submitted, but the kernel patch has already been
> > > > re-based and submitted.
> > > 
> > > Is the one from June 2nd the right one ([PATCH] refpolicy: Kernel access
> > > key retention policy support) to start, and then the one from yesterday
> > > that has setkeycreate?
> > > 
> > 


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2006-06-21 21:24 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-21 15:08 [PATCH] repost: new sockcreate interface to specify context of socket when they are created Eric Paris
2006-06-21 15:37 ` James Morris
2006-06-21 15:54   ` Eric Paris
2006-06-21 16:08     ` Stephen Smalley
2006-06-21 16:03 ` Stephen Smalley
2006-06-21 16:22   ` James Morris
2006-06-21 16:57     ` James Morris
2006-06-21 19:46   ` Christopher J. PeBenito
2006-06-21 19:50     ` Stephen Smalley
2006-06-21 20:23       ` Christopher J. PeBenito
2006-06-21 20:25         ` Michael LeMay
2006-06-21 21:07           ` Christopher J. PeBenito
2006-06-21 21:24             ` Michael LeMay

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.