sysfs: Add labeling support for sysfs
authorDavid P. Quigley <dpquigl@tycho.nsa.gov>
Wed, 9 Sep 2009 18:25:37 +0000 (14:25 -0400)
committerJames Morris <jmorris@namei.org>
Thu, 10 Sep 2009 00:11:29 +0000 (10:11 +1000)
commitddd29ec6597125c830f7badb608a86c98b936b64
treee6df1ef9a635179de78650d006ecb4cd1453ebb1
parent1ee65e37e904b959c24404139f5752edc66319d5
sysfs: Add labeling support for sysfs

This patch adds a setxattr handler to the file, directory, and symlink
inode_operations structures for sysfs. The patch uses hooks introduced in the
previous patch to handle the getting and setting of security information for
the sysfs inodes. As was suggested by Eric Biederman the struct iattr in the
sysfs_dirent structure has been replaced by a structure which contains the
iattr, secdata and secdata length to allow the changes to persist in the event
that the inode representing the sysfs_dirent is evicted. Because sysfs only
stores this information when a change is made all the optional data is moved
into one dynamically allocated field.

This patch addresses an issue where SELinux was denying virtd access to the PCI
configuration entries in sysfs. The lack of setxattr handlers for sysfs
required that a single label be assigned to all entries in sysfs. Granting virtd
access to every entry in sysfs is not an acceptable solution so fine grained
labeling of sysfs is required such that individual entries can be labeled
appropriately.

[sds:  Fixed compile-time warnings, coding style, and setting of inode security init flags.]

Signed-off-by: David P. Quigley <dpquigl@tycho.nsa.gov>
Signed-off-by: Stephen D. Smalley <sds@tycho.nsa.gov>
Signed-off-by: James Morris <jmorris@namei.org>
fs/sysfs/dir.c
fs/sysfs/inode.c
fs/sysfs/symlink.c
fs/sysfs/sysfs.h
security/selinux/hooks.c
security/smack/smack_lsm.c