Linux kernel file removal failure in overlayfs casefolded directories
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
| No fix yet |
| Linux Linux |
|
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
ovl: fix whiteout creation in casefolded directories
unlink and rmdir fail with EINVAL on an overlay with casefolded (case-insensitive) layers, if the name exists in a lower layer. Casefolded layers need CONFIG_UNICODE. Root can mount such an overlay, and so can an unprivileged user in a user namespace, with tmpfs layers.
Overlayfs does not change a lower layer. To remove a name that exists there, it hides the name with a marker file, a whiteout. It creates the whiteout in the work directory, a scratch directory on the upper filesystem, and renames it over the name in the upper directory:
- ovl_whiteout() creates the whiteout with mknod, or as a hard link to an earlier whiteout. - ovl_cleanup_and_whiteout() then prepares the rename with start_renaming_two_dentries(), which returns -EINVAL if the source or the target dentry is unhashed, that is, not in the dentry hash table.
With casefolded directories, both dentries can be unhashed:
- The target. Lookup in a casefolded directory leaves a negative dentry unhashed, so the rename target is unhashed if the name does not exist in the upper directory. - The source, which is the new whiteout. tmpfs hashes a dentry when mknod or link makes it positive, but ext4 does not, so on ext4 the source is unhashed as well.
The cleanup after the failure also refuses an unhashed dentry, so on ext4 the whiteout is left behind in the work directory.
From the CVE record · Linux
On overlayfs mounts with casefolded layers, unlink and rmdir can fail when the name exists in a lower layer. A local user can trigger this on a mount created by root, or as an unprivileged user in a user namespace with tmpfs layers; casefolded layers require CONFIG_UNICODE. On ext4, a failed operation can also leave a whiteout in the work directory.
Engineers running Linux kernels with overlayfs mounts over casefolded layers should check their systems; affected versions were not specified.