All of lore.kernel.org
 help / color / mirror / Atom feed
* automatic type transitions for pts in devfs
@ 2002-03-06 12:45 Russell Coker
  2002-03-06 13:41 ` Stephen Smalley
  0 siblings, 1 reply; 16+ messages in thread
From: Russell Coker @ 2002-03-06 12:45 UTC (permalink / raw)
  To: SE Linux

It seems that the automatic type transitions for /dev/pts don't work on 
devfs.  When the sshd (in sshd_t domain) opens /dev/pts/1 it does not get 
changed to sshd_devpts_t domain.

When I put the following in my devfs_contexts file it all works as desired 
(so my only problem is the sshd_t causing a transition of the /dev/pts/1 
device node to sshd_devpts_t.
/pts                    system_u:object_r:sshd_devpts_t

I'm using the default sshd configuration.

-- 
If you send email to me or to a mailing list that I use which has >4 lines
of legalistic junk at the end then you are specifically authorizing me to do
whatever I wish with the message and all other messages from your domain, by
posting the message you agree that your long legalistic sig is void.

--
You have received this message because you are subscribed to the selinux 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] 16+ messages in thread

* Re: automatic type transitions for pts in devfs
  2002-03-06 12:45 Russell Coker
@ 2002-03-06 13:41 ` Stephen Smalley
  2002-03-09 13:04   ` Russell Coker
  0 siblings, 1 reply; 16+ messages in thread
From: Stephen Smalley @ 2002-03-06 13:41 UTC (permalink / raw)
  To: Russell Coker; +Cc: SE Linux



On Wed, 6 Mar 2002, Russell Coker wrote:

> It seems that the automatic type transitions for /dev/pts don't work on
> devfs.  When the sshd (in sshd_t domain) opens /dev/pts/1 it does not get
> changed to sshd_devpts_t domain.

Right.  The initial labeling of pty nodes based on the allocating process
domain is only implemented for the devpts filesystem at present, not the
devfs filesystem.  The SELinux kernel module performs special processing
for the devpts filesystem type to ensure that new nodes are initially
labeled with the type specified by a type transition rule between the
domain that initially allocated the pty and the base devpts_t type.  When
sshd or rlogind allocate a pty in a devpts filesystem, it is initially
labeled by the kernel with a sshd_devpts_t or rlogind_devpts_t type and is
subsequently relabeled by sshd or login to the appropriate user_devpts_t or
sysadm_devpts_t type.  When a user runs X, his ptys are initially
allocated from the user_t or sysadm_t domain, so they are immediately
labeled with user_devpts_t or sysadm_devpts_t by the kernel.

At present, we don't use devfs on our systems, so it hasn't (yet) been a
priority to provide identical functionality in devfs.

--
Stephen D. Smalley, NAI Labs
ssmalley@nai.com





--
You have received this message because you are subscribed to the selinux 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] 16+ messages in thread

* Re: automatic type transitions for pts in devfs
  2002-03-06 13:41 ` Stephen Smalley
@ 2002-03-09 13:04   ` Russell Coker
  0 siblings, 0 replies; 16+ messages in thread
From: Russell Coker @ 2002-03-09 13:04 UTC (permalink / raw)
  To: Stephen Smalley; +Cc: SE Linux

On Wed, 6 Mar 2002 14:41, Stephen Smalley wrote:
> On Wed, 6 Mar 2002, Russell Coker wrote:
> > It seems that the automatic type transitions for /dev/pts don't work on
> > devfs.  When the sshd (in sshd_t domain) opens /dev/pts/1 it does not get
> > changed to sshd_devpts_t domain.
>
> Right.  The initial labeling of pty nodes based on the allocating process
> domain is only implemented for the devpts filesystem at present, not the
[...]
> At present, we don't use devfs on our systems, so it hasn't (yet) been a
> priority to provide identical functionality in devfs.

I've tried patching that myself, but it seems that my skills are not up to it.

It seems that the filp->f_owner.pid is being set in the devfs initialisation 
code somehow at an earlier stage than in devpts, therefore by the time 
tty_fasync() is called it's already done and the set_fowner() call is skipped.

Could you give me a clue as to where I should look next?  Or would you 
recommend that I give up?

-- 
If you send email to me or to a mailing list that I use which has >4 lines
of legalistic junk at the end then you are specifically authorizing me to do
whatever I wish with the message and all other messages from your domain, by
posting the message you agree that your long legalistic sig is void.

--
You have received this message because you are subscribed to the selinux 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] 16+ messages in thread

* automatic type transitions for pts in devfs
@ 2002-07-09 12:49 Debian User
  2002-07-09 13:26 ` Stephen Smalley
  0 siblings, 1 reply; 16+ messages in thread
From: Debian User @ 2002-07-09 12:49 UTC (permalink / raw)
  To: selinux

Whats best way to go about this? Where do i look first? I will try 
fixing this with some help.

Russell?

Is there a work around for this?


--
You have received this message because you are subscribed to the selinux 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] 16+ messages in thread

* Re: automatic type transitions for pts in devfs
  2002-07-09 12:49 automatic type transitions for pts in devfs Debian User
@ 2002-07-09 13:26 ` Stephen Smalley
  2002-07-09 13:41   ` Debian User
  2002-07-09 14:02   ` Debian User
  0 siblings, 2 replies; 16+ messages in thread
From: Stephen Smalley @ 2002-07-09 13:26 UTC (permalink / raw)
  To: Debian User; +Cc: selinux


On Tue, 9 Jul 2002, Debian User wrote:

> Whats best way to go about this? Where do i look first? I will try
> fixing this with some help.

You can look at how we provide labeling for the devpts filesystem.  The
devpts filesystem uses transition SIDs to label its inodes.  Look at the
sbsec->uses_trans case of inode_precondition in
lsm-2.4/security/selinux/hooks.c.  The devfs filesystem uses
genfs_contexts to label its inodes (the sbsec->uses_genfs case).  You want
devfs to actually be a hybrid of the two methods, with /pts entries
in devfs using transition SIDs like devpts and other entries using
genfs_contexts.

--
Stephen D. Smalley, NAI Labs
ssmalley@nai.com




--
You have received this message because you are subscribed to the selinux 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] 16+ messages in thread

* Re: automatic type transitions for pts in devfs
  2002-07-09 13:26 ` Stephen Smalley
@ 2002-07-09 13:41   ` Debian User
  2002-07-09 14:07     ` Stephen Smalley
  2002-07-09 14:02   ` Debian User
  1 sibling, 1 reply; 16+ messages in thread
From: Debian User @ 2002-07-09 13:41 UTC (permalink / raw)
  To: Stephen Smalley; +Cc: selinux

Stephen Smalley wrote:

>On Tue, 9 Jul 2002, Debian User wrote:
>
>  
>
>>Whats best way to go about this? Where do i look first? I will try
>>fixing this with some help.
>>    
>>
>
>You can look at how we provide labeling for the devpts filesystem.  The
>devpts filesystem uses transition SIDs to label its inodes.  Look at the
>sbsec->uses_trans case of inode_precondition in
>lsm-2.4/security/selinux/hooks.c.  The devfs filesystem uses
>genfs_contexts to label its inodes (the sbsec->uses_genfs case).  You want
>devfs to actually be a hybrid of the two methods, with /pts entries
>in devfs using transition SIDs like devpts and other entries using
>genfs_contexts.
>  
>
I see im beginning to see things clearly.  Are all the stuff involved in 
this restricted to hooks.c? Im afraid im not familiar with lsm. I have 
to look for an introduction somewhere.

>--
>Stephen D. Smalley, NAI Labs
>ssmalley@nai.com
>
>
>  
>




--
You have received this message because you are subscribed to the selinux 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] 16+ messages in thread

* Re: automatic type transitions for pts in devfs
  2002-07-09 13:26 ` Stephen Smalley
  2002-07-09 13:41   ` Debian User
@ 2002-07-09 14:02   ` Debian User
  2002-07-09 14:16     ` Stephen Smalley
  1 sibling, 1 reply; 16+ messages in thread
From: Debian User @ 2002-07-09 14:02 UTC (permalink / raw)
  To: Stephen Smalley; +Cc: selinux

Stephen Smalley wrote:

>On Tue, 9 Jul 2002, Debian User wrote:
>
>  
>
>>Whats best way to go about this? Where do i look first? I will try
>>fixing this with some help.
>>    
>>
>
>You can look at how we provide labeling for the devpts filesystem.  The
>devpts filesystem uses transition SIDs to label its inodes.  Look at the
>sbsec->uses_trans case of inode_precondition in
>lsm-2.4/security/selinux/hooks.c.  The devfs filesystem uses
>genfs_contexts to label its inodes (the sbsec->uses_genfs case).  You want
>devfs to actually be a hybrid of the two methods, with /pts entries
>in devfs using transition SIDs like devpts and other entries using
>genfs_contexts.
>  
>
Ok I just read through the technical paper.
So I focus on hooks.c. This is basically getting the inodes labelled 
correctly.
Either we add some new fields(?) in the inode structure or we insert a 
condition that would make the inode get the proper label. Is that correct?

I hope someone can beat me to the answer.

>--
>Stephen D. Smalley, NAI Labs
>ssmalley@nai.com
>
>
>  
>




--
You have received this message because you are subscribed to the selinux 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] 16+ messages in thread

* Re: automatic type transitions for pts in devfs
  2002-07-09 13:41   ` Debian User
@ 2002-07-09 14:07     ` Stephen Smalley
  2002-07-09 14:17       ` Debian User
  0 siblings, 1 reply; 16+ messages in thread
From: Stephen Smalley @ 2002-07-09 14:07 UTC (permalink / raw)
  To: Debian User; +Cc: selinux


On Tue, 9 Jul 2002, Debian User wrote:

> Are all the stuff involved in this restricted to hooks.c?

You can implement a quick-and-dirty solution entirely by modifying
hooks.c.  A more general solution will require changes to the security
server and the policy configuration to support such hybrid schemes.

> Im afraid im not familiar with lsm. I have
> to look for an introduction somewhere.

lsm.immunix.org has some documentation about LSM.  The NSA SELinux site
has a technical report describing the implementation of the LSM-based
SELinux module, although it is not entirely up-to-date.

--
Stephen D. Smalley, NAI Labs
ssmalley@nai.com




--
You have received this message because you are subscribed to the selinux 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] 16+ messages in thread

* Re: automatic type transitions for pts in devfs
  2002-07-09 14:02   ` Debian User
@ 2002-07-09 14:16     ` Stephen Smalley
  2002-07-09 14:19       ` Debian User
  2002-07-09 14:33       ` Debian User
  0 siblings, 2 replies; 16+ messages in thread
From: Stephen Smalley @ 2002-07-09 14:16 UTC (permalink / raw)
  To: Debian User; +Cc: selinux


On Tue, 9 Jul 2002, Debian User wrote:

> So I focus on hooks.c. This is basically getting the inodes labelled
> correctly.
> Either we add some new fields(?) in the inode structure or we insert a
> condition that would make the inode get the proper label. Is that correct?

You could add a test within the sbsec->uses_genfs case to see whether the
filesystem type is devfs and whether the inode corresponds to a /pts node.
If so, then you want to use a transition SID as with the sbsec->uses_trans
case.  Otherwise, you would use genfs_contexts as usual.

--
Stephen D. Smalley, NAI Labs
ssmalley@nai.com




--
You have received this message because you are subscribed to the selinux 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] 16+ messages in thread

* Re: automatic type transitions for pts in devfs
  2002-07-09 14:07     ` Stephen Smalley
@ 2002-07-09 14:17       ` Debian User
  0 siblings, 0 replies; 16+ messages in thread
From: Debian User @ 2002-07-09 14:17 UTC (permalink / raw)
  To: Stephen Smalley; +Cc: selinux

Stephen Smalley wrote:

>On Tue, 9 Jul 2002, Debian User wrote:
>
>  
>
>>Are all the stuff involved in this restricted to hooks.c?
>>    
>>
>
>You can implement a quick-and-dirty solution entirely by modifying
>hooks.c.  A more general solution will require changes to the security
>server and the policy configuration to support such hybrid schemes.
>  
>
I will try the quick and dirty solution. I have an idea where to look. I 
just read some papers and its very enlightening. It looks  like i need 
to wrap the present set of nested ifs with another that tests some 
variables to get inode properly labeled.

>  
>
>>Im afraid im not familiar with lsm. I have
>>to look for an introduction somewhere.
>>    
>>
>
>lsm.immunix.org has some documentation about LSM.  The NSA SELinux site
>has a technical report describing the implementation of the LSM-based
>SELinux module, although it is not entirely up-to-date.
>
>--
>Stephen D. Smalley, NAI Labs
>ssmalley@nai.com
>
>
>  
>




--
You have received this message because you are subscribed to the selinux 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] 16+ messages in thread

* Re: automatic type transitions for pts in devfs
  2002-07-09 14:16     ` Stephen Smalley
@ 2002-07-09 14:19       ` Debian User
  2002-07-09 14:33       ` Debian User
  1 sibling, 0 replies; 16+ messages in thread
From: Debian User @ 2002-07-09 14:19 UTC (permalink / raw)
  To: Stephen Smalley; +Cc: selinux

Stephen Smalley wrote:

>On Tue, 9 Jul 2002, Debian User wrote:
>
>  
>
>>So I focus on hooks.c. This is basically getting the inodes labelled
>>correctly.
>>Either we add some new fields(?) in the inode structure or we insert a
>>condition that would make the inode get the proper label. Is that correct?
>>    
>>
>
>You could add a test within the sbsec->uses_genfs case to see whether the
>filesystem type is devfs and whether the inode corresponds to a /pts node.
>If so, then you want to use a transition SID as with the sbsec->uses_trans
>case.  Otherwise, you would use genfs_contexts as usual.
>  
>
cool! i see it now. this is great. this is the first time i hacked devfs 
and selinux!
Thanks!

>--
>Stephen D. Smalley, NAI Labs
>ssmalley@nai.com
>
>
>  
>




--
You have received this message because you are subscribed to the selinux 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] 16+ messages in thread

* Re: automatic type transitions for pts in devfs
  2002-07-09 14:16     ` Stephen Smalley
  2002-07-09 14:19       ` Debian User
@ 2002-07-09 14:33       ` Debian User
  1 sibling, 0 replies; 16+ messages in thread
From: Debian User @ 2002-07-09 14:33 UTC (permalink / raw)
  To: Stephen Smalley; +Cc: selinux

Stephen Smalley wrote:

>On Tue, 9 Jul 2002, Debian User wrote:
>
>  
>
>>So I focus on hooks.c. This is basically getting the inodes labelled
>>correctly.
>>Either we add some new fields(?) in the inode structure or we insert a
>>condition that would make the inode get the proper label. Is that correct?
>>    
>>
>
>You could add a test within the sbsec->uses_genfs case to see whether the
>filesystem type is devfs and whether the inode corresponds to a /pts node.
>If so, then you want to use a transition SID as with the sbsec->uses_trans
>case.  Otherwise, you would use genfs_contexts as usual.
>  
>
That would mean checking if the inode's super block magic number is DEVPTS.
Is that going to be enough?

>--
>Stephen D. Smalley, NAI Labs
>ssmalley@nai.com
>
>
>  
>




--
You have received this message because you are subscribed to the selinux 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] 16+ messages in thread

* automatic type transitions for pts in devfs
@ 2002-07-11  3:26 Debian User
  2002-07-11 12:20 ` Stephen Smalley
  0 siblings, 1 reply; 16+ messages in thread
From: Debian User @ 2002-07-11  3:26 UTC (permalink / raw)
  To: selinux; +Cc: sds

my patch works with russell's devfsd-se.so disabled. just remove any selinux* 
file in /etc/devfs/conf.d. i will see if removing only the pts entry in the selinux 
conf.d file will work. 

--
You have received this message because you are subscribed to the selinux 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] 16+ messages in thread

* Re: automatic type transitions for pts in devfs
  2002-07-11  3:26 Debian User
@ 2002-07-11 12:20 ` Stephen Smalley
  2002-07-11 12:35   ` Debian User
  0 siblings, 1 reply; 16+ messages in thread
From: Stephen Smalley @ 2002-07-11 12:20 UTC (permalink / raw)
  To: Debian User; +Cc: selinux


On Thu, 11 Jul 2002, Debian User wrote:

> my patch works with russell's devfsd-se.so disabled. just remove any selinux*
> file in /etc/devfs/conf.d. i will see if removing only the pts entry in the selinux
> conf.d file will work.

This makes sense.  As long as devfsd does not intercept the registration
of pts nodes and perform a lookup at that time, your patch should work for
labeling pts nodes with transition SIDs.

This is good, as it removes the immediate need to patch devfsd.  However,
it will still be necessary to patch the kernel devfs code to preserve SIDs
on devfs entries when they are evicted from the dcache.

--
Stephen D. Smalley, NAI Labs
ssmalley@nai.com




--
You have received this message because you are subscribed to the selinux 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] 16+ messages in thread

* Re: automatic type transitions for pts in devfs
  2002-07-11 12:20 ` Stephen Smalley
@ 2002-07-11 12:35   ` Debian User
  2002-07-11 13:03     ` Stephen Smalley
  0 siblings, 1 reply; 16+ messages in thread
From: Debian User @ 2002-07-11 12:35 UTC (permalink / raw)
  To: Stephen Smalley; +Cc: selinux

Stephen Smalley wrote:

>On Thu, 11 Jul 2002, Debian User wrote:
>
>  
>
>>my patch works with russell's devfsd-se.so disabled. just remove any selinux*
>>file in /etc/devfs/conf.d. i will see if removing only the pts entry in the selinux
>>conf.d file will work.
>>    
>>
>
>This makes sense.  As long as devfsd does not intercept the registration
>of pts nodes and perform a lookup at that time, your patch should work for
>labeling pts nodes with transition SIDs.
>
>This is good, as it removes the immediate need to patch devfsd.  However,
>it will still be necessary to patch the kernel devfs code to preserve SIDs
>on devfs entries when they are evicted from the dcache.
>
The system im building from scratch is working perfectly booting in 
enforcing mode without devfsd. I am fine tuning the policy now.

Im having a problem with my X Window devpts entries.  The task sid when 
X Window creates a pty is xdm_t. What should the proper type be? Ssh 
works perfectly now in enforcing mode. X stops when I switch to 
enforcing mode. What are the type transitions when gdm starts X window?

>--
>Stephen D. Smalley, NAI Labs
>ssmalley@nai.com
>
>
>  
>




--
You have received this message because you are subscribed to the selinux 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] 16+ messages in thread

* Re: automatic type transitions for pts in devfs
  2002-07-11 12:35   ` Debian User
@ 2002-07-11 13:03     ` Stephen Smalley
  0 siblings, 0 replies; 16+ messages in thread
From: Stephen Smalley @ 2002-07-11 13:03 UTC (permalink / raw)
  To: Debian User; +Cc: selinux


On Thu, 11 Jul 2002, Debian User wrote:

> Im having a problem with my X Window devpts entries.  The task sid when
> X Window creates a pty is xdm_t. What should the proper type be? Ssh
> works perfectly now in enforcing mode. X stops when I switch to
> enforcing mode. What are the type transitions when gdm starts X window?

To use an X Display Manager, you need a patched [xgk]dm to set the
security context for the user session, as noted in selinux/README.  We do
not provide a patched [xgk]dm, but I think Russell Coker has a patched kdm
and Mark Westerman has a patched gdm.  If you are using a patched [xgk]dm,
then the pty should be created by a process in the user's domain, not
xdm_t, so it should pick up the proper user_devpts_t or sysadm_devpts_t
type automatically.  At least, that has been my experience.

--
Stephen D. Smalley, NAI Labs
ssmalley@nai.com




--
You have received this message because you are subscribed to the selinux 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] 16+ messages in thread

end of thread, other threads:[~2002-07-11 13:03 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-07-09 12:49 automatic type transitions for pts in devfs Debian User
2002-07-09 13:26 ` Stephen Smalley
2002-07-09 13:41   ` Debian User
2002-07-09 14:07     ` Stephen Smalley
2002-07-09 14:17       ` Debian User
2002-07-09 14:02   ` Debian User
2002-07-09 14:16     ` Stephen Smalley
2002-07-09 14:19       ` Debian User
2002-07-09 14:33       ` Debian User
  -- strict thread matches above, loose matches on Subject: below --
2002-07-11  3:26 Debian User
2002-07-11 12:20 ` Stephen Smalley
2002-07-11 12:35   ` Debian User
2002-07-11 13:03     ` Stephen Smalley
2002-03-06 12:45 Russell Coker
2002-03-06 13:41 ` Stephen Smalley
2002-03-09 13:04   ` Russell Coker

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.