CVE-2026-139391: ocfs2: retain all security xattrs during inode creation
In the Linux kernel, the following vulnerability has been resolved:
ocfs2: retain all security xattrs during inode creation
When creating a new inode, ocfs2initsecurityget() stores the security xattr returned by the LSM framework in ocfs2securityxattrinfo so that it can be written later within the same transaction. But ocfs2initxattrs() only ever looks at the first element of the xattr array, and it keeps the name as a bare pointer into memory owned by the security layer instead of copying it. The value, by contrast, is already duplicated with kmemdup().
With stacked LSMs, securityinodeinitsecurity() provides one xattr per LSM, so all labels but the first are silently dropped and never written to disk, leaving newly created files without the security xattrs the other LSMs rely on.
The borrowed name is not an outright bug with the LSMs in tree today: securityinodeinitsecurity() frees only ->value once the callback returns, and documents ->name as the attribute name suffix, so the pointer stays valid for as long as ocfs2 uses it. It is fragile though, as an LSM that allocates the name together with the value would turn it into a use-after-free, so the rework below copies the names as well.
Fix this by storing copies of all the security xattrs: allocate an array in ocfs2initxattrs(), copy the names and values, account for all of them in the credit calculations, and write each one in ocfs2initsecurityset().
While at it, switch the allocations from GFPKERNEL to GFPNOFS. The callback runs in the inode creation path with the parent directory locked, and the security layer allocates the very same xattr array with GFPNOFS, so direct reclaim must not be allowed to recurse into the filesystem from here.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Compensating control
In ocfs2, update inode security-xattr handling to copy the names and values of all xattrs, account for all of them in credit calculations, and write each one within the transaction. Use GFP_NOFS for the allocations.