attr: add in_group_or_capable()
authorChristian Brauner <brauner@kernel.org>
Mon, 17 Oct 2022 15:06:34 +0000 (17:06 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 3 Mar 2023 10:52:24 +0000 (11:52 +0100)
commit18c2750856dc907ccff05c747e079495f75ea35c
tree237e771ee2830d84b5d814332f0ac68f821c822d
parent118ad80d27d938868299ef184f7483b21f011f0b
attr: add in_group_or_capable()

commit 11c2a8700cdcabf9b639b7204a1e38e2a0b6798e upstream.

In setattr_{copy,prepare}() we need to perform the same permission
checks to determine whether we need to drop the setgid bit or not.
Instead of open-coding it twice add a simple helper the encapsulates the
logic. We will reuse this helpers to make dropping the setgid bit during
write operations more consistent in a follow up patch.

Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/attr.c
fs/inode.c
fs/internal.h