CVE-2024-46695: selinux,smack: don't bypass permissions check in inode_setsecctx hook
In the Linux kernel, the following vulnerability has been resolved:
selinux,smack: don't bypass permissions check in inodesetsecctx hook
Marek Gresko reports that the root user on an NFS client is able to change the security labels on files on an NFS filesystem that is exported with root squashing enabled.
The end of the kerneldoc comment for vfssetxattrnoperm() states:
This function requires the caller to lock the inode's imutex before it is executed. It also assumes that the caller will make the appropriate permission checks.
nfsdsetattr() does do permissions checking via fhverify() and nfsdpermission(), but those don't do all the same permissions checks that are done by securityinodesetxattr() and its related LSM hooks do.
Since nfsdsetattr() is the only consumer of securityinodesetsecctx(), simplest solution appears to be to replace the call to vfssetxattrnoperm() with a call to vfssetxattrlocked(). This fixes the above issue and has the added benefit of causing nfsd to recall conflicting delegations on a file when a client tries to change its security label.
Other sources
selinuxsmack: don't bypass permissions check in inodesetsecctx hook
— Microsoft
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
debian/linuxto a version that resolves this vulnerability.Fixed in 5.10.234-1Fixed in 6.1.129-1Fixed in 6.1.135-1Fixed in 6.12.25-1Fixed in 6.12.27-1 - Upgrade
Upgrade
debian/linux-6.1to a version that resolves this vulnerability.Fixed in 6.1.129-1~deb11u1 - Configuration
Update the Linux kernel code so the inode_setsecctx hook uses __vfs_setxattr_locked() instead of __vfs_setxattr_noperm(), ensuring i_mutex is held and permission checks are not bypassed.
Linux kernel (NFS security label change path) Replace __vfs_setxattr_noperm() call with __vfs_setxattr_locked() in the security_inode_setsecctx (inode_setsecctx) hook consumer path = __vfs_setxattr_locked()
Event History
Frequently Asked Questions
What is the severity of CVE-2024-46695?
CVE-2024-46695 has a medium severity rating due to its potential impact on file security in NFS environments.
How do I fix CVE-2024-46695?
To fix CVE-2024-46695, update the Linux kernel to version 6.1.123-1 or later.
Which Linux kernel versions are affected by CVE-2024-46695?
CVE-2024-46695 affects Linux kernel versions from 6.7 up to 6.6.49 as well as certain release candidates.
Can a root user exploit CVE-2024-46695?
Yes, a root user on an NFS client can change security labels on exported files, which constitutes an exploitation of CVE-2024-46695.
What is the importance of fixing CVE-2024-46695?
Fixing CVE-2024-46695 is important to prevent unauthorized changes to file security labels that could compromise system integrity.