]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
ovl: check type and offset of struct vfsmount in ovl_entry
authorChristian Brauner <brauner@kernel.org>
Tue, 13 Jun 2023 08:13:37 +0000 (10:13 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 26 Aug 2023 12:23:23 +0000 (14:23 +0200)
commita3f252436e5701ae8a974869b7fe075a97e13472
tree262fd9010986214bb9e56f238d36effe6edd5617
parent1a650d3ccd79cdd5796edd864683a6b8dd0bf576
ovl: check type and offset of struct vfsmount in ovl_entry

[ Upstream commit f723edb8a532cd26e1ff0a2b271d73762d48f762 ]

Porting overlayfs to the new amount api I started experiencing random
crashes that couldn't be explained easily. So after much debugging and
reasoning it became clear that struct ovl_entry requires the point to
struct vfsmount to be the first member and of type struct vfsmount.

During the port I added a new member at the beginning of struct
ovl_entry which broke all over the place in the form of random crashes
and cache corruptions. While there's a comment in ovl_free_fs() to the
effect of "Hack! Reuse ofs->layers as a vfsmount array before freeing
it" there's no such comment on struct ovl_entry which makes this easy to
trip over.

Add a comment and two static asserts for both the offset and the type of
pointer in struct ovl_entry.

Signed-off-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/overlayfs/ovl_entry.h