Linux FSCRYPT development
 help / color / mirror / Atom feed
* [PATCH 6.1] fscrypt: use the mount idmap for the owner check in fscrypt_ioctl_set_policy()
@ 2026-08-18 18:38 Eric Biggers
  2026-08-20  4:19 ` Sasha Levin
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Biggers @ 2026-08-18 18:38 UTC (permalink / raw)
  To: stable; +Cc: linux-fscrypt, Zhan Xusheng, Eric Biggers

From: Zhan Xusheng <zhanxusheng@xiaomi.com>

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.

Fixes: 14f3db5542e6 ("ext4: support idmapped mounts")
Cc: stable@vger.kernel.org
Signed-off-by: Zhan Xusheng <zhanxusheng@xiaomi.com>
Link: https://patch.msgid.link/20260725080004.929328-1-zhanxusheng1024@gmail.com
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
---
 fs/crypto/policy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c
index 46757c3052ef9..d0f97caa20211 100644
--- a/fs/crypto/policy.c
+++ b/fs/crypto/policy.c
@@ -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
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 6.1] fscrypt: use the mount idmap for the owner check in fscrypt_ioctl_set_policy()
  2026-08-18 18:38 [PATCH 6.1] fscrypt: use the mount idmap for the owner check in fscrypt_ioctl_set_policy() Eric Biggers
@ 2026-08-20  4:19 ` Sasha Levin
  0 siblings, 0 replies; 2+ messages in thread
From: Sasha Levin @ 2026-08-20  4:19 UTC (permalink / raw)
  To: stable; +Cc: Sasha Levin, linux-fscrypt, Zhan Xusheng, Eric Biggers

On Tue, Aug 18, 2026 at 11:38:21AM -0700, Eric Biggers wrote:
> commit cf6c993c0feca7984797e634deba3c80342e199a upstream.

Queued for 6.1, thanks.

-- 
Thanks,
Sasha

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-08-20  4:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-18 18:38 [PATCH 6.1] fscrypt: use the mount idmap for the owner check in fscrypt_ioctl_set_policy() Eric Biggers
2026-08-20  4:19 ` Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox