Linux kernel file replacement in overlayfs copy-up of removed files
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: do not copy up a dentry that was removed
A change to a removed file through an open descriptor replaces whatever has its old name in the upper layer.
Copy up must only create a name in the upper directory, never replace one. After an unlink, an rmdir or a rename over a lower dentry, a dentry that an open file keeps alive still has its old parent and name, but in the upper directory that name is now a whiteout or a new object. ovl_copy_up_workdir() renames the copy over it, which brings back the removed object and destroys whatever took its name.
An unprivileged user opened a lower FIFO and unlinked it, root created a file at that name, and fchmod on the old descriptor replaced the file of root with the FIFO.
Fix this by looking up the target name of the rename in ovl_copy_up_workdir() with LOOKUP_EXCL, so that copy up fails with -EEXIST if the name is taken, as copy up with O_TMPFILE already does when it links the copy to the name.
[amir: use LOOKUP_EXCL instead of relying on d_unhashed()]
From the CVE record · Linux
Overlayfs can copy up a removed lower-layer object over a new object at the same name. A local unprivileged user with an open descriptor to the removed object can trigger this through a change to that descriptor, potentially replacing a file created by root at that name. This requires local access and no further user interaction is described.
Anyone running the Linux kernel with overlayfs should check their kernel version; affected versions are not specified.