diff options
| author | Chris Mason <mason@kernel.org> | 2026-10-16 21:17:21 +0000 |
|---|---|---|
| committer | Amir Goldstein <amir73il@gmail.com> | 2026-11-03 22:17:23 +0100 |
| commit | c782fc8ada811569811c0fdea5c3412511be95d0 (patch) | |
| tree | 18bd5c38032c3246376121e0ca04723d2c021f1d /tools/perf/scripts/python | |
| parent | 51628610f9187c1c1cfe499d92e066bc22ad9693 (diff) | |
ovl: fail the mount if the casefold flag has changed
An unprivileged user in a user namespace can repeatedly trigger a kernel
warning with their own overlay mounts. They do so by changing the
casefold flag of the topmost layer's empty root, the top directory of
that layer, after the layers are set and before the mount is created.
The casefold flag of a directory makes name lookups in that directory
case-insensitive. All layers of an overlay must agree on casefolding.
ovl_mount_dir_check() reads the casefold flag of a layer root when
fsconfig() sets that layer, and saves the result in ofs->casefold. The
mount is created later, by another fsconfig() call with
FSCONFIG_CMD_CREATE.
The casefold flag of an empty directory can be changed.
The casefold flag of the overlay root must match ofs->casefold.
ovl_get_root() copies the flag from the topmost layer root, as it is
when the mount is created. On a mismatch, ovl_get_root() only does a
WARN_ON(), and the mount continues. The check is not a WARN_ON_ONCE(),
so each such mount warns again.
An unprivileged user needs CONFIG_UNICODE, and a tmpfs mounted with the
casefold option in their namespace.
Reproduced by changing the casefold flag of the empty upper directory
after the layers were set and before FSCONFIG_CMD_CREATE, with tmpfs and
ext4 layers, and as uid 1000 in a user namespace.
Fix this by replacing the WARN_ON() with a check that fails the mount
with -EINVAL.
Fixes: f9377faaeae0 ("ovl: Add S_CASEFOLD as part of the inode flag to be copied")
Cc: stable@vger.kernel.org
Signed-off-by: Chris Mason <mason@kernel.org>
Tested-by: Hungyu Lin <dennylin0707@gmail.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Diffstat (limited to 'tools/perf/scripts/python')
0 files changed, 0 insertions, 0 deletions
