public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ceph: make sure directories aren't complete after setting crypt context
@ 2022-11-16 15:37 Luís Henriques
  2022-11-17  8:03 ` Xiubo Li
  0 siblings, 1 reply; 8+ messages in thread
From: Luís Henriques @ 2022-11-16 15:37 UTC (permalink / raw)
  To: Xiubo Li, Ilya Dryomov, Jeff Layton
  Cc: ceph-devel, linux-kernel, Luís Henriques

When setting a directory's crypt context, __ceph_dir_clear_complete() needs
to be used otherwise, if it was complete before, any old dentry that's still
around will be valid.

Signed-off-by: Luís Henriques <lhenriques@suse.de>
---
Hi!

Here's a simple way to trigger the bug this patch is fixing:

# cd /cephfs
# ls mydir
nKRhofOAVNsAwVLvDw7a0c9ypsjbZfK3n0Npnmni6j0
# ls mydir/nKRhofOAVNsAwVLvDw7a0c9ypsjbZfK3n0Npnmni6j0/
Cyuer5xT+kBlEPgtwAqSj0WK2taEljP5vHZ,D8VXCJ8  u+46b2XVCt7Obpz0gznZyNLRj79Q2l4KmkwbKOzdQKw
# fscrypt unlock mydir
# touch /mnt/test/mydir/mysubdir/file
touch: cannot touch '/mnt/test/mydir/mysubdir/file': No such file or directory

 fs/ceph/crypto.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/ceph/crypto.c b/fs/ceph/crypto.c
index 35a2ccfe6899..dc1557967032 100644
--- a/fs/ceph/crypto.c
+++ b/fs/ceph/crypto.c
@@ -87,6 +87,10 @@ static int ceph_crypt_get_context(struct inode *inode, void *ctx, size_t len)
 		return -ERANGE;
 
 	memcpy(ctx, cfa->cfa_blob, ctxlen);
+
+	/* Directory isn't complete anymore */
+	if (S_ISDIR(inode->i_mode) && __ceph_dir_is_complete(ci))
+		__ceph_dir_clear_complete(ci);
 	return ctxlen;
 }
 

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

end of thread, other threads:[~2022-11-21 13:51 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-16 15:37 [PATCH] ceph: make sure directories aren't complete after setting crypt context Luís Henriques
2022-11-17  8:03 ` Xiubo Li
2022-11-17 11:08   ` Xiubo Li
2022-11-17 18:02     ` Luís Henriques
2022-11-18  5:24       ` Xiubo Li
2022-11-18 11:12         ` Luís Henriques
2022-11-21  0:53           ` Xiubo Li
2022-11-21 13:52             ` Luís Henriques

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