]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
security: keys: perform capable check only on privileged operations
authorChristian Göttsche <cgzones@googlemail.com>
Thu, 11 May 2023 12:32:52 +0000 (14:32 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 23 Sep 2023 08:46:53 +0000 (10:46 +0200)
commit9121d71c0150e86af93ea4f3910944326cc713cd
treecbaf4aaf6f2d915727e8fb9b4b4642ab9a31cbe8
parenta7be3507bc8bfb18daddd91c0fcbe1e4860eb3a6
security: keys: perform capable check only on privileged operations

[ Upstream commit 2d7f105edbb3b2be5ffa4d833abbf9b6965e9ce7 ]

If the current task fails the check for the queried capability via
`capable(CAP_SYS_ADMIN)` LSMs like SELinux generate a denial message.
Issuing such denial messages unnecessarily can lead to a policy author
granting more privileges to a subject than needed to silence them.

Reorder CAP_SYS_ADMIN checks after the check whether the operation is
actually privileged.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
security/keys/keyctl.c