Skip to content

Commit

Permalink
ksmbd: not allow to open file if delete pending or delelete on close …
Browse files Browse the repository at this point in the history
…bit is set

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 <[email protected]>
  • Loading branch information
namjaejeon committed Sep 25, 2023
1 parent 332f4ca commit 7e2b571
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions vfs_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 7e2b571

Please sign in to comment.