android_kernel_google_msm/security/selinux
Stephen Smalley e8ab53a5d6 selinux: fix inode security list corruption
commit 923190d32d upstream.

sb_finish_set_opts() can race with inode_free_security()
when initializing inode security structures for inodes
created prior to initial policy load or by the filesystem
during ->mount().   This appears to have always been
a possible race, but commit 3dc91d4 ("SELinux:  Fix possible
NULL pointer dereference in selinux_inode_permission()")
made it more evident by immediately reusing the unioned
list/rcu element  of the inode security structure for call_rcu()
upon an inode_free_security().  But the underlying issue
was already present before that commit as a possible use-after-free
of isec.

Shivnandan Kumar reported the list corruption and proposed
a patch to split the list and rcu elements out of the union
as separate fields of the inode_security_struct so that setting
the rcu element would not affect the list element.  However,
this would merely hide the issue and not truly fix the code.

This patch instead moves up the deletion of the list entry
prior to dropping the sbsec->isec_lock initially.  Then,
if the inode is dropped subsequently, there will be no further
references to the isec.

Reported-by: Shivnandan Kumar <shivnandan.k@samsung.com>
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
Signed-off-by: Paul Moore <pmoore@redhat.com>
Signed-off-by: Zefan Li <lizefan@huawei.com>
2015-02-02 17:04:50 +08:00
..
include SELinux: Fix possible NULL pointer dereference in selinux_inode_permission() 2014-01-29 05:10:42 -08:00
ss SELinux: bigendian problems with filename trans rules 2014-03-11 16:10:02 -07:00
.gitignore SELinux: add .gitignore files for dynamic classes 2009-10-24 09:42:27 +08:00
avc.c lsm_audit: don't specify the audit pre/post callbacks in 'struct common_audit_data' 2012-04-03 09:49:59 -07:00
exports.c selinux: sparse fix: include selinux.h in exports.c 2011-09-09 16:56:32 -07:00
hooks.c selinux: fix inode security list corruption 2015-02-02 17:04:50 +08:00
Kconfig selinux: Deprecate and schedule the removal of the the compat_net functionality 2008-12-31 12:54:11 -05:00
Makefile selinux: change to new flag variable 2010-10-21 10:12:40 +11:00
netif.c doc: Update the email address for Paul Moore in various source files 2011-08-01 17:58:33 -07:00
netlabel.c selinux: correct locking in selinux_netlbl_socket_connect) 2013-12-04 10:50:32 -08:00
netlink.c selinux: sparse fix: fix warnings in netlink code 2012-01-05 18:52:51 -05:00
netnode.c selinux: fix sel_netnode_insert() suspicious rcu dereference 2012-11-26 11:38:02 -08:00
netport.c SELinux: Fix RCU deref check warning in sel_netport_insert() 2011-12-21 11:28:56 +11:00
nlmsgtab.c selinux: sparse fix: fix warnings in netlink code 2012-01-05 18:52:51 -05:00
selinuxfs.c SELinux: if sel_make_bools errors don't leave inconsistent state 2012-06-01 15:18:16 +08:00
xfrm.c selinux: look for IPsec labels on both inbound and outbound packets 2014-01-08 09:42:12 -08:00