Skip to content

Commit e127e03

Browse files
Luís Henriquesidryomov
authored andcommitted
ceph: allow encrypting a directory while not having Ax caps
If a client doesn't have Fx caps on a directory, it will get errors while trying encrypt it: ceph: handle_cap_grant: cap grant attempt to change fscrypt_auth on non-I_NEW inode (old len 0 new len 48) fscrypt (ceph, inode 1099511627812): Error -105 getting encryption context A simple way to reproduce this is to use two clients: client1 # mkdir /mnt/mydir client2 # ls /mnt/mydir client1 # fscrypt encrypt /mnt/mydir client1 # echo hello > /mnt/mydir/world This happens because, in __ceph_setattr(), we only initialize ci->fscrypt_auth if we have Ax and ceph_fill_inode() won't use the fscrypt_auth received if the inode state isn't I_NEW. Fix it by allowing ceph_fill_inode() to also set ci->fscrypt_auth if the inode doesn't have it set already. Signed-off-by: Luís Henriques <lhenriques@suse.de> Reviewed-by: Xiubo Li <xiubli@redhat.com> Reviewed-by: Milind Changire <mchangir@redhat.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
1 parent 94af047 commit e127e03

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

fs/ceph/inode.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -975,7 +975,8 @@ int ceph_fill_inode(struct inode *inode, struct page *locked_page,
975975
__ceph_update_quota(ci, iinfo->max_bytes, iinfo->max_files);
976976

977977
#ifdef CONFIG_FS_ENCRYPTION
978-
if (iinfo->fscrypt_auth_len && (inode->i_state & I_NEW)) {
978+
if (iinfo->fscrypt_auth_len &&
979+
((inode->i_state & I_NEW) || (ci->fscrypt_auth_len == 0))) {
979980
kfree(ci->fscrypt_auth);
980981
ci->fscrypt_auth_len = iinfo->fscrypt_auth_len;
981982
ci->fscrypt_auth = iinfo->fscrypt_auth;

0 commit comments

Comments
 (0)