]> git.baikalelectronics.ru Git - kernel.git/commit
mnt_idmapping: return false when comparing two invalid ids
authorSeth Forshee <sforshee@digitalocean.com>
Mon, 27 Jun 2022 13:01:58 +0000 (08:01 -0500)
committerChristian Brauner (Microsoft) <brauner@kernel.org>
Mon, 27 Jun 2022 14:09:56 +0000 (16:09 +0200)
commit4f85bdcdbf8c09a1963856a14334743c53504c63
tree1ba90503e32eac54f1c04758bc12b0a31f6ff8f9
parent0d140b8e20a61f2d34e5b72f70407c2690cca8d4
mnt_idmapping: return false when comparing two invalid ids

INVALID_VFS{U,G}ID represent ids which have no mapping in the target
mnt_usersns. This can happen for a couple of different reasons -- the
source id might be valid but has no mapping in mnt_userns, or the source
id might have been invalid (either due to a failed mapping or because it
was set to invalid to indicate it is uninitialized).

This means that two arbitrary vfs{u,g}ids which are both invalid could
represent two different underlying ids, or they could represent a failed
mapping and an uninitialized value. In these situation the vfs{u,g}id
equality functions evaluate these ids as equal, and care must be taken
when comparing ids to avoid problems. It would be less error prone to
always evaluate two invalid ids as not equal to each other, and to check
explicitly for vfs{u,g}id validity when that is needed.

Change all vfs{u,g}id equality functions to return false when both ids
are invalid. Functions for checking whether an id is valid exist and are
already being used by code which needs to check this.

Link: https://lore.kernel.org/linux-fsdevel/YrIMZirGoE0VIO45@do-x1extreme
Signed-off-by: Seth Forshee <sforshee@digitalocean.com>
Reviewed-by: Christian Brauner (Microsoft) <brauner@kernel.org>
Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>
include/linux/mnt_idmapping.h