selinux: fix misuse of mutex_is_locked()
authorOndrej Mosnacek <omosnace@redhat.com>
Mon, 21 Feb 2022 14:06:49 +0000 (15:06 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 2 Mar 2022 10:47:48 +0000 (11:47 +0100)
commitaf091cc27e3766455e121e4f03a8057dec3c73c7
tree93389b5ec34bf8301aa51678516169d7c61a3077
parent0d773aaf5a90e2856301bd30781bf107db917a66
selinux: fix misuse of mutex_is_locked()

commit ce2fc710c9d2b25afc710f49bb2065b4439a62bc upstream.

mutex_is_locked() tests whether the mutex is locked *by any task*, while
here we want to test if it is held *by the current task*. To avoid
false/missed WARNINGs, use lockdep_assert_is_held() and
lockdep_assert_is_not_held() instead, which do the right thing (though
they are a no-op if CONFIG_LOCKDEP=n).

Cc: stable@vger.kernel.org
Fixes: 2554a48f4437 ("selinux: measure state and policy capabilities")
Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
security/selinux/ima.c