Linux kernel stale data exposure in overlayfs file-handle lookup
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: look up the index by the decoded origin
A file opened by file handle on an overlay with nfs_export=on can show the stale lower data of a file that was copied up to the upper layer. While the file opened this way stays in the inode cache, a lookup of the copied up file by path fails with ESTALE for all users. The open can also succeed for a file that was removed, where it has to fail with ESTALE. This happens with a handle that has one byte changed. The handle comes from an NFS client, or from a process that calls open_by_handle_at() with CAP_DAC_READ_SEARCH in the initial user namespace.
When a file in a lower layer is about to be modified, overlayfs first copies it to the upper layer (copy up). With nfs_export=on, each copy up also creates an entry in the index directory, a directory that overlayfs keeps for itself on the upper filesystem.
The handle of an overlay file that comes from a lower layer wraps the handle of its lower inode. Overlayfs calls this lower inode the origin. The overlay handle stays valid after a copy up.
To decode such a handle, ovl_lower_fh_to_d() first decodes the wrapped handle to the origin. If no overlay inode is cached for the origin, it looks in the index directory:
- An index entry there leads to the upper file. - A whiteout, the marker that overlayfs uses for a removed file, means that the overlay file was removed.
The name of an index entry is the handle that copy up encoded for the origin, as a hex string.
From the CVE record · Linux
On a Linux overlay with nfs_export=on, a modified file handle can resolve to a lower-layer file while missing the index entry for its copied-up or removed version. An NFS client, or a local process with CAP_DAC_READ_SEARCH in the initial user namespace, can use such a handle to read stale data; while the resulting inode is cached, path lookups of a copied-up file fail with ESTALE for all users. A handle for a removed file can also open when it should fail with ESTALE.
Engineers running Linux kernel overlayfs mounts with nfs_export=on should check their kernel versions against the vendor advisory.