Skip to contentSkip to conversation

fscrypt: use the mount idmap for the owner check in fscrypt_ioctl_set_policy()

PATCH Applied Eric Biggers 2 participants 2 messages Aug 18 – Aug 20

Subsystems (2)
lore
Share & tools
lore

Eric Biggers

author maintainer
#0 lore raw

PATCH 1/1 fscrypt: use the mount idmap for the owner check in fscrypt_ioctl_set_policy()

From: Zhan Xusheng <[email protected]>

commit cf6c993c0feca7984797e634deba3c80342e199a upstream.

fscrypt_ioctl_set_policy() calls inode_owner_or_capable() with &nop_mnt_idmap before allowing an encryption policy to be set, instead of the idmap of the mount the ioctl was issued on.

fscrypt is used by filesystems that support idmapped mounts (e.g. ext4, f2fs), so on such a mount this compares the caller's fsuid against the unmapped on-disk owner rather than the mapped owner: the actual owner can be wrongly denied with -EACCES and an unrelated caller wrongly allowed. Use file_mnt_idmap(filp) instead.

---
 fs/crypto/policy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/crypto/policy.c +1 -1
index 46757c3052ef9..d0f97caa20211 100644
@@ -494,7 +494,7 @@ int fscrypt_ioctl_set_policy(struct file *filp, const void __user *arg)
 		return -EFAULT;
 	policy.version = version;
 
-	if (!inode_owner_or_capable(&init_user_ns, inode))
+	if (!inode_owner_or_capable(file_mnt_user_ns(filp), inode))
 		return -EACCES;
 
 	ret = mnt_want_write_file(filp);

base-commit: e4f7d8be268ecf717f94ee2e242afa79ddeacaed

Signature · 1 line
2.55.0
maintainer Applied
#1 lore raw
Quoted 1 line · Eric Biggers

commit cf6c993c0feca7984797e634deba3c80342e199a upstream.

Queued for 6.1, thanks.

Signature · 2 lines
Thanks,
Sasha