]> git.baikalelectronics.ru Git - kernel.git/commit
apparmor: fix aa_xattrs_match() may sleep while holding a RCU lock
authorJohn Johansen <john.johansen@canonical.com>
Thu, 2 Jan 2020 13:31:22 +0000 (05:31 -0800)
committerJohn Johansen <john.johansen@canonical.com>
Sat, 4 Jan 2020 23:56:44 +0000 (15:56 -0800)
commite032a5f940ad829d11debadf4376e740eb16a07d
tree7bbe5954a3d15944b17e1cc732eb0f479276ffda
parent4d4a850f4baee7f55e672e4d1c1b54fee0afc73c
apparmor: fix aa_xattrs_match() may sleep while holding a RCU lock

aa_xattrs_match() is unfortunately calling vfs_getxattr_alloc() from a
context protected by an rcu_read_lock. This can not be done as
vfs_getxattr_alloc() may sleep regardles of the gfp_t value being
passed to it.

Fix this by breaking the rcu_read_lock on the policy search when the
xattr match feature is requested and restarting the search if a policy
changes occur.

Fixes: 7631873e5f4a ("apparmor: Add support for attaching profiles via xattr, presence and value")
Reported-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Reported-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: John Johansen <john.johansen@canonical.com>
security/apparmor/apparmorfs.c
security/apparmor/domain.c
security/apparmor/policy.c