SELinux: per-command whitelisting of ioctls
authorJeff Vander Stoep <jeffv@google.com>
Wed, 8 Apr 2015 18:27:46 +0000 (11:27 -0700)
committerMark Salyzyn <salyzyn@google.com>
Mon, 13 Apr 2015 19:55:59 +0000 (19:55 +0000)
commit8daca972e410f42a4fc1fe2de804c50013b24a28
treebd3745ec36e276801d3730461aac49c67142496e
parentc8c3cd48e44fe12a41cd20e46d36fcfe5a759fd7
SELinux: per-command whitelisting of ioctls

Extend the generic ioctl permission check with support for per-command
filtering. Source/target/class sets including the ioctl permission may
additionally include a set of commands. Example:

allow <source> <target>:<class> { 0x8910-0x8926 0x892A-0x8935 }
auditallow <source> <target>:<class> 0x892A

When ioctl commands are omitted only the permissions are checked. This
feature is intended to provide finer granularity for the ioctl
permission which may be too imprecise in some circumstances. For
example, the same driver may use ioctls to provide important and
benign functionality such as driver version or socket type as well as
dangerous capabilities such as debugging features, read/write/execute
to physical memory or access to sensitive data. Per-command filtering
provides a mechanism to reduce the attack surface of the kernel, and
limit applications to the subset of commands required.

The format of the policy binary has been modified to include ioctl
commands, and the policy version number has been incremented to
POLICYDB_VERSION_IOCTL_OPERATIONS=30 to account for the format change.

Bug: 18087110
Change-Id: Ibf0e36728f6f3f0d5af56ccdeddee40800af689d
Signed-off-by: Jeff Vander Stoep <jeffv@google.com>
security/selinux/avc.c
security/selinux/hooks.c
security/selinux/include/avc.h
security/selinux/include/security.h
security/selinux/ss/avtab.c
security/selinux/ss/avtab.h
security/selinux/ss/conditional.c
security/selinux/ss/conditional.h
security/selinux/ss/policydb.c
security/selinux/ss/services.c
security/selinux/ss/services.h