ksmbd: not allow to open file if delelete on close bit is set
Subsystems (2)
Namjae Jeon
maintainerPATCH 1/1 ksmbd: not allow to open file if delelete on close 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
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_ON_CLS flags.
--- fs/smb/server/vfs_cache.c | 5 +++++ 1 file changed, 5 insertions(+)
fs/smb/server/vfs_cache.c +5 -0
@@ -577,6 +577,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_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);
Signature · 1 line
2.25.1
Tom Talpey
reviewerQuoted 13 lines · Namjae Jeon
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 ./nfs2y8Jm9data compare ok
nfsjunk files after close:
ls: cannot access './nfs2y8Jm9': No such file or directory
special tests failed
Quoted 5 lines
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_ON_CLSflags.Reported-by Tom Talpey <[email protected]>
I don't remember reporting this.
But more fundamentally, the Connectathon test is an NFS exerciser, and specific to NFS (and Posix) semantics. Delete-on-last-close is not one of them.
Won't failing a new open break Windows semantics if it's enforced by default? Normally Windows checks for FILE_SHARE_DELETE before deciding this. Maybe other checks as well...
Tom.
Quoted 21 lines
Signed-off-by Namjae Jeon <[email protected]>--- fs/smb/server/vfs_cache.c | 5 +++++ 1 file changed, 5 insertions(+)fs/smb/server/vfs_cache.c +5
-0@@ -577,6 +577,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_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);
Namjae Jeon
maintainer2023-09-29 0:23 GMT+09:00, Tom Talpey <[email protected]>:
Quoted 14 lines · Namjae Jeon
Quoted 13 lines
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 ./nfs2y8Jm9data compare ok
nfsjunk files after close:
ls: cannot access './nfs2y8Jm9': No such file or directory
special tests failed
Quoted 7 lines
Quoted 5 lines
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_ON_CLSflags.Reported-by Tom Talpey <[email protected]>I don't remember reporting this.
You told me basic test of cthon run fine but special test fail.
Quoted 35 lines
But more fundamentally, the Connectathon test is an NFS exerciser, and specific to NFS (and Posix) semantics. Delete-on-last-close is not one of them.
Won't failing a new open break Windows semantics if it's enforced by default? Normally Windows checks for
FILE_SHARE_DELETEbefore deciding this. Maybe other checks as well...Tom.
Quoted 23 lines
Signed-off-by Namjae Jeon <[email protected]>--- fs/smb/server/vfs_cache.c | 5 +++++ 1 file changed, 5 insertions(+)fs/smb/server/vfs_cache.c +5
-0@@ -577,6 +577,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_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);
Tom Talpey
reviewerQuoted 15 lines · Namjae Jeon
2023-09-29 0:23 GMT+09:00, Tom Talpey <[email protected]>:
Quoted 14 lines · Namjae Jeon
Quoted 13 lines
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 ./nfs2y8Jm9data compare ok
nfsjunk files after close:
ls: cannot access './nfs2y8Jm9': No such file or directory
special tests failed
Quoted 8 lines
Quoted 7 lines
Quoted 5 lines
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_ON_CLSflags.Reported-by Tom Talpey <[email protected]>I don't remember reporting this.
You told me basic test of cthon run fine but special test fail.
Well yes but I didn't say the failure was incorrect. Connectathon is a useful test, but it's not a protocol test. What makes it handy for me is that it's easy to deploy and run, and it is not a synthetic client, that is, it makes ordinary syscalls and exercices the local in-kernel client code.
The "special" tests in particular are about NFS client quirks, and specifically quirks that were interesting in, like, 1999. They need to be taken with a huge lump of salt, and an even larger lump today.
It's ok, I'm not concerned that you added my Reported-by. But it needs a lot more research before pushing this upstream.
Tom.
Quoted 35 lines
Quoted 34 lines
But more fundamentally, the Connectathon test is an NFS exerciser, and specific to NFS (and Posix) semantics. Delete-on-last-close is not one of them.
Won't failing a new open break Windows semantics if it's enforced by default? Normally Windows checks for
FILE_SHARE_DELETEbefore deciding this. Maybe other checks as well...Tom.
Quoted 23 lines
Signed-off-by Namjae Jeon <[email protected]>--- fs/smb/server/vfs_cache.c | 5 +++++ 1 file changed, 5 insertions(+)fs/smb/server/vfs_cache.c +5
-0@@ -577,6 +577,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_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);
Namjae Jeon
maintainer2023-09-29 1:38 GMT+09:00, Tom Talpey <[email protected]>:
Quoted 31 lines · Namjae Jeon
Quoted 15 lines
2023-09-29 0:23 GMT+09:00, Tom Talpey <[email protected]>:
Quoted 14 lines · Namjae Jeon
Quoted 13 lines
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 ./nfs2y8Jm9data compare ok
nfsjunk files after close:
ls: cannot access './nfs2y8Jm9': No such file or directory
special tests failedQuoted 8 lines
Quoted 7 lines
Quoted 5 lines
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_ON_CLSflags.Reported-by Tom Talpey <[email protected]>I don't remember reporting this.
You told me basic test of cthon run fine but special test fail.
Well yes but I didn't say the failure was incorrect. Connectathon is a useful test, but it's not a protocol test. What makes it handy for me is that it's easy to deploy and run, and it is not a synthetic client, that is, it makes ordinary syscalls and exercices the local in-kernel client code.
Quoted 6 lines
The "special" tests in particular are about NFS client quirks, and specifically quirks that were interesting in, like, 1999. They need to be taken with a huge lump of salt, and an even larger lump today.
It's ok, I'm not concerned that you added my Reported-by. But it needs a lot more research before pushing this upstream.
I started looking into this problem because you described it as if ksmbd was having problems even on TCP when running a special test. And the op_unk test, one of the special tests in cthon, passed against samba but failed against ksmbd, so I was trying to figure out the cause. The cthon test does not appear to be test for only NFS. Because these tests exclude NFS (and Posix) semantics depending on the WIN32 and CIFS configure.
Quoted 39 lines
Tom.
Quoted 35 lines
Quoted 34 lines
But more fundamentally, the Connectathon test is an NFS exerciser, and specific to NFS (and Posix) semantics. Delete-on-last-close is not one of them.
Won't failing a new open break Windows semantics if it's enforced by default? Normally Windows checks for
FILE_SHARE_DELETEbefore deciding this. Maybe other checks as well...Tom.
Quoted 23 lines
Signed-off-by Namjae Jeon <[email protected]>--- fs/smb/server/vfs_cache.c | 5 +++++ 1 file changed, 5 insertions(+)fs/smb/server/vfs_cache.c +5
-0@@ -577,6 +577,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_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);
Namjae Jeon
maintainer2023-09-29 0:23 GMT+09:00, Tom Talpey <[email protected]>:
Quoted 22 lines · Namjae Jeon
Quoted 13 lines
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 ./nfs2y8Jm9data compare ok
nfsjunk files after close:
ls: cannot access './nfs2y8Jm9': No such file or directory
special tests failedQuoted 5 lines
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_ON_CLSflags.Reported-by Tom Talpey <[email protected]>I don't remember reporting this.
Quoted 7 lines
But more fundamentally, the Connectathon test is an NFS exerciser, and specific to NFS (and Posix) semantics. Delete-on-last-close is not one of them.
Won't failing a new open break Windows semantics if it's enforced by default? Normally Windows checks for
FILE_SHARE_DELETEbefore deciding this. Maybe other checks as well...
cifs.ko send smb2 create with FILE_SHARE_DELETE to ksmbd.
If sent without it, ksmbd return STATUS_SHARING_VIOLATION error to client. I have tested it against samba. ssamba handle it as STATUS_DELETE_PENDING error.
Quoted 27 lines
Tom.
Quoted 23 lines
Signed-off-by Namjae Jeon <[email protected]>--- fs/smb/server/vfs_cache.c | 5 +++++ 1 file changed, 5 insertions(+)fs/smb/server/vfs_cache.c +5
-0@@ -577,6 +577,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_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);
ronnie sahlberg
reviewerQuoted 29 lines · Namjae Jeon
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
nfsjunk files after close:
ls: cannot access './nfs2y8Jm9': No such file or directory
special tests failedCthon 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_ON_CLSflags.Reported-by Tom Talpey <[email protected]>Signed-off-by Namjae Jeon <[email protected]>--- fs/smb/server/vfs_cache.c | 5 +++++ 1 file changed, 5 insertions(+)fs/smb/server/vfs_cache.c +0
-0
fs/smb/server/vfs_cache.c struct ksmbd_file *ksmbd_open_fd(struct ksmbd_work *work, struct file *filp) · line 584
Quoted 8 lines
fs/smb/server/vfs_cache.c +5
-0@@ -577,6 +577,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_ON_CLS ) { + ret = -ENOENT ; + goto err_out; + } +
Is enoent the right error here? I assume that the file will still show in a directory listing so maybe eacces would be better?
Quoted 6 lines
fs/smb/server/vfs_cache.c +0
-1ret =__open_id (&work->sess->file_table, fp,OPEN_ID_TYPE_VOLATILE_ID );if (ret) {ksmbd_inode_put (fp->f_ci); --2.25.1
Namjae Jeon
maintainer2023-09-29 10:13 GMT+09:00, ronnie sahlberg <[email protected]>:
Quoted 34 lines · Namjae Jeon
Quoted 33 lines
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
nfsjunk files after close:
ls: cannot access './nfs2y8Jm9': No such file or directory
special tests failedCthon 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_ON_CLSflags.Reported-by Tom Talpey <[email protected]>Signed-off-by Namjae Jeon <[email protected]>--- fs/smb/server/vfs_cache.c | 5 +++++ 1 file changed, 5 insertions(+)fs/smb/server/vfs_cache.c +0
-0@@ -577,6 +577,11 @@ struct ksmbd_file *ksmbd_open_fd(struct ksmbd_work *work, struct file *filp) goto err_out; }
Quoted 7 lines
fs/smb/server/vfs_cache.c struct ksmbd_file *ksmbd_open_fd(struct ksmbd_work *work, struct file *filp) · line 584
Quoted 5 lines
fs/smb/server/vfs_cache.c +5
-0+if (fp->f_ci->m_flags &S_DEL_ON_CLS ) { + ret = -ENOENT ; + goto err_out; + } +Is enoent the right error here? I assume that the file will still show
No, It should be STATUS_DELETE_PENDING error.
Quoted 1 line
in a directory listing so maybe eacces would be better?
Right. but it should not be STATUS_ACCESS_DENIED error. So I will change the patch to return STATUS_DELETE_PENDING error to client on v2.
Thanks for your review!
Quoted 10 lines
Quoted 9 lines
fs/smb/server/vfs_cache.c +0
-0ret =__open_id (&work->sess->file_table, fp,OPEN_ID_TYPE_VOLATILE_ID );if (ret) { ksmbd_inode_put(fp->f_ci);--
2.25.1