Skip to contentSkip to conversation

security_context_to_sid failed - mounting from /etc/rc.d

DISCUSSION M Macnair 2 participants 3 messages Jul 25, 2006 SELinux security module

lore
Share & tools
lore

M Macnair

author
#0 lore raw

I discovered this whilst trying to mount removable devices on boot. There is the following line in /etc/rc.d/rc.local (FC5):
mount -a -t nonfs,nfs4,smbfs,ncpfs,cifs,gfs -O no_netdev,context=system_u:object_r:removable_t

When executed, this fails with the error:
mount: wrong fs type, bad option, bad superblock on /dev/store/music,
missing codepage or other error
In some cases useful info is found in syslog - try dmesg | tail or so

/var/log/messages says:
kernel: SELinux:
security_context_to_sid(system_u:object_r:removable_t) failed for (dev dm-3, type ext2) errno=-22

/dev/store/music is an unmounted lvm ext2 formatted logical volume, with fstab entry:
/dev/store/music /mnt/music ext2 defaults,user,context=system_u:object_r:removable_t

This error is dependent on the context of the script that is executing it - cp rc.local into /etc/ (from /etc/rc.d) and execute it there, and it works perfectly. Executing the mount command from a terminal also works.

# ls -Z /etc/rc.d/rc.local /etc/rc.local.cp
-rwxr-xr-x  root root system_u:object_r:initrc_exec_t  /etc/rc.d/rc.local
-rwxr-xr-x  root root user_u:object_r:etc_t            /etc/rc.local.cp

Any ideas on what's going on / how to work around it?

Thanks,
Mike

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#1 lore raw
Quoted 4 lines · M Macnair

I discovered this whilst trying to mount removable devices on boot. There is the following line in /etc/rc.d/rc.local (FC5):
mount -a -t nonfs,nfs4,smbfs,ncpfs,cifs,gfs -O no_netdev,context=system_u:object_r:removable_t

Add :s0 to the end of that context. IIRC, the problem is that mount just directly passes the context to the kernel without going through libselinux, so it never undergoes "label translation".

Quoted 27 lines

When executed, this fails with the error:
mount: wrong fs type, bad option, bad superblock on /dev/store/music,
missing codepage or other error
In some cases useful info is found in syslog - try dmesg | tail or so

/var/log/messages says:
kernel: SELinux:
security_context_to_sid(system_u:object_r:removable_t) failed for (dev dm-3, type ext2) errno=-22

/dev/store/music is an unmounted lvm ext2 formatted logical volume, with fstab entry:
/dev/store/music /mnt/music ext2 defaults,user,context=system_u:object_r:removable_t

This error is dependent on the context of the script that is executing it - cp rc.local into /etc/ (from /etc/rc.d) and execute it there, and it works perfectly. Executing the mount command from a terminal also works.

# ls -Z /etc/rc.d/rc.local /etc/rc.local.cp
(quoted diff) +0 -2
-rwxr-xr-x  root root system_u:object_r:initrc_exec_t  /etc/rc.d/rc.local
-rwxr-xr-x  root root user_u:object_r:etc_t            /etc/rc.local.cp
Quoted 1 line

Any ideas on what's going on / how to work around it?

I don't understand why that would make a difference; the error has to do with validity of the context, not a permission denial.

Signature · 8 lines
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 [email protected] with
the words "unsubscribe selinux" without quotes as the message.
author
#2 lore raw
Quoted 37 lines · Stephen Smalley
Quoted 4 lines · M Macnair

I discovered this whilst trying to mount removable devices on boot. There is the following line in /etc/rc.d/rc.local (FC5):
mount -a -t nonfs,nfs4,smbfs,ncpfs,cifs,gfs -O no_netdev,context=system_u:object_r:removable_t

Add :s0 to the end of that context. IIRC, the problem is that mount just directly passes the context to the kernel without going through libselinux, so it never undergoes "label translation".

Quoted 27 lines

When executed, this fails with the error:
mount: wrong fs type, bad option, bad superblock on /dev/store/music,
missing codepage or other error
In some cases useful info is found in syslog - try dmesg | tail or so

/var/log/messages says:
kernel: SELinux:
security_context_to_sid(system_u:object_r:removable_t) failed for (dev dm-3, type ext2) errno=-22

/dev/store/music is an unmounted lvm ext2 formatted logical volume, with fstab entry:
/dev/store/music /mnt/music ext2 defaults,user,context=system_u:object_r:removable_t

This error is dependent on the context of the script that is executing it - cp rc.local into /etc/ (from /etc/rc.d) and execute it there, and it works perfectly. Executing the mount command from a terminal also works.

# ls -Z /etc/rc.d/rc.local /etc/rc.local.cp
(quoted diff) +0 -2
-rwxr-xr-x  root root system_u:object_r:initrc_exec_t  /etc/rc.d/rc.local
-rwxr-xr-x  root root user_u:object_r:etc_t            /etc/rc.local.cp
Quoted 10 lines
Quoted 1 line

Any ideas on what's going on / how to work around it?

I don't understand why that would make a difference; the error has to do with validity of the context, not a permission denial.

--
Stephen Smalley
National Security Agency

Thanks, adding :s0 to the context in the script and fstab entry fixed it.

Mike

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.