From 7e2b5710d9c69a88b096e4640e22f1f638efbdef Mon Sep 17 00:00:00 2001 From: Namjae Jeon Date: Mon, 25 Sep 2023 11:28:09 +0900 Subject: [PATCH] ksmbd: not allow to open file if delete pending or delelete on close bit is set MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cthon test fail with the following error. check for proper open/unlink operation nfsjunk files before unlink: -rwxr-xr-x 1 root root 0 9월 25 11:03 ./nfs2y8Jm9 ./nfs2y8Jm9 open; unlink ret = 0 nfsjunk files after unlink: -rwxr-xr-x 1 root root 0 9월 25 11:03 ./nfs2y8Jm9 data compare ok Error: second unlink succeeded!?? nfsjunk files after close: ls: cannot access './nfs2y8Jm9': No such file or directory special tests failed Cthon expect to second unlink failure when file is already unlinked. ksmbd can not allow to open file if flags of ksmbd inode is set with S_DEL_PENDING or S_DEL_ON_CLS. Signed-off-by: Namjae Jeon --- vfs_cache.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vfs_cache.c b/vfs_cache.c index 81cbb202a..fe044a5e1 100644 --- a/vfs_cache.c +++ b/vfs_cache.c @@ -637,6 +637,11 @@ struct ksmbd_file *ksmbd_open_fd(struct ksmbd_work *work, struct file *filp) goto err_out; } + if (fp->f_ci->m_flags & (S_DEL_PENDING | S_DEL_ON_CLS)) { + ret = -ENOENT; + goto err_out; + } + ret = __open_id(&work->sess->file_table, fp, OPEN_ID_TYPE_VOLATILE_ID); if (ret) { ksmbd_inode_put(fp->f_ci);