diff options
author | Seth Forshee <sforshee@digitalocean.com> | 2022-06-24 09:07:51 -0500 |
---|---|---|
committer | Seth Forshee <sforshee@digitalocean.com> | 2022-06-24 09:07:51 -0500 |
commit | fb9ea59b896e3054b9652ea40d5dae8969b21638 (patch) | |
tree | c35964d099750f5de8ef6695f41081a79cfb7db2 | |
parent | 65066a95c60d7f5df37e3d65e99ffd9bab544e18 (diff) | |
download | linux-kuid-equality.tar.gz |
uidgid: Do not consider two invalid ids to be equalkuid-equality
INVALID_{U,G}ID do not represent actual ids; rather, the represent the
absence of a valid id. Two different invalid ids may represent different
things -- for example, one may represent an unitialized id while another
might represent an id from a filesystem with no mapping in a particular
user namespace, or they may represent different on-disk ids which both
fail to map into a user namespace. Treating two arbitrary invalid ids as
equal may lead to errors.
Change {u,g}id_eq() to return false when both ids are invalid. This will
harden the kernel against accidental comparison between invalid ids.
There are legitimate reasons for checking whether an id is invalid, but
code which needs to do this can use {u,g}id_valid(). All code which was
using {u,g}id_eq() to check for invalid ids were updated in the previous
patch.
Signed-off-by: Seth Forshee <sforshee@digitalocean.com>
-rw-r--r-- | include/linux/uidgid.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h index b0542cd11aeb09..3616e14ebe5608 100644 --- a/include/linux/uidgid.h +++ b/include/linux/uidgid.h @@ -60,12 +60,12 @@ static inline gid_t __kgid_val(kgid_t gid) static inline bool uid_eq(kuid_t left, kuid_t right) { - return __kuid_val(left) == __kuid_val(right); + return uid_valid(left) && __kuid_val(left) == __kuid_val(right); } static inline bool gid_eq(kgid_t left, kgid_t right) { - return __kgid_val(left) == __kgid_val(right); + return gid_valid(left) && __kgid_val(left) == __kgid_val(right); } static inline bool uid_gt(kuid_t left, kuid_t right) |