* [v2 PATCH] ksmbd: not allow to open file if delelete on close bit is set
@ 2023-10-09 15:11 Namjae Jeon
2023-10-09 15:11 ` [PATCH] ksmbd: reorganize ksmbd_iov_pin_rsp() Namjae Jeon
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Namjae Jeon @ 2023-10-09 15:11 UTC (permalink / raw)
To: linux-cifs
Cc: smfrench, senozhatsky, tom, hyc.lee, atteh.mailbox, 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 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.
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
---
v2:
return STATUS_DELETE_PENDING error response instead of STATUS_OBJECT_NAME_INVALID.
fs/smb/server/vfs_cache.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/smb/server/vfs_cache.c b/fs/smb/server/vfs_cache.c
index c4b80ab7df74..1c5c39733652 100644
--- a/fs/smb/server/vfs_cache.c
+++ b/fs/smb/server/vfs_cache.c
@@ -106,7 +106,7 @@ int ksmbd_query_inode_status(struct inode *inode)
ci = __ksmbd_inode_lookup(inode);
if (ci) {
ret = KSMBD_INODE_STATUS_OK;
- if (ci->m_flags & S_DEL_PENDING)
+ if (ci->m_flags & (S_DEL_PENDING | S_DEL_ON_CLS))
ret = KSMBD_INODE_STATUS_PENDING_DELETE;
atomic_dec(&ci->m_count);
}
@@ -116,7 +116,7 @@ int ksmbd_query_inode_status(struct inode *inode)
bool ksmbd_inode_pending_delete(struct ksmbd_file *fp)
{
- return (fp->f_ci->m_flags & S_DEL_PENDING);
+ return (fp->f_ci->m_flags & (S_DEL_PENDING | S_DEL_ON_CLS));
}
void ksmbd_set_inode_pending_delete(struct ksmbd_file *fp)
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] ksmbd: reorganize ksmbd_iov_pin_rsp()
2023-10-09 15:11 [v2 PATCH] ksmbd: not allow to open file if delelete on close bit is set Namjae Jeon
@ 2023-10-09 15:11 ` Namjae Jeon
2023-10-09 15:11 ` [PATCH] ksmbd: fix wrong error response status by using set_smb2_rsp_status() Namjae Jeon
2023-10-09 15:11 ` [PATCH] ksmbd: fix kernel-doc comment of ksmbd_vfs_setxattr() Namjae Jeon
2 siblings, 0 replies; 4+ messages in thread
From: Namjae Jeon @ 2023-10-09 15:11 UTC (permalink / raw)
To: linux-cifs
Cc: smfrench, senozhatsky, tom, hyc.lee, atteh.mailbox, Namjae Jeon
If ksmbd_iov_pin_rsp fail, io vertor should be rollback.
This patch moves memory allocations to before setting the io vector
to avoid rollbacks.
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
---
fs/smb/server/ksmbd_work.c | 43 +++++++++++++++++++-------------------
1 file changed, 22 insertions(+), 21 deletions(-)
diff --git a/fs/smb/server/ksmbd_work.c b/fs/smb/server/ksmbd_work.c
index 51def3ca74c0..a2ed441e837a 100644
--- a/fs/smb/server/ksmbd_work.c
+++ b/fs/smb/server/ksmbd_work.c
@@ -95,11 +95,28 @@ bool ksmbd_queue_work(struct ksmbd_work *work)
return queue_work(ksmbd_wq, &work->work);
}
-static int ksmbd_realloc_iov_pin(struct ksmbd_work *work, void *ib,
- unsigned int ib_len)
+static inline void __ksmbd_iov_pin(struct ksmbd_work *work, void *ib,
+ unsigned int ib_len)
{
+ work->iov[++work->iov_idx].iov_base = ib;
+ work->iov[work->iov_idx].iov_len = ib_len;
+ work->iov_cnt++;
+}
+
+static int __ksmbd_iov_pin_rsp(struct ksmbd_work *work, void *ib, int len,
+ void *aux_buf, unsigned int aux_size)
+{
+ struct aux_read *ar;
+ int need_iov_cnt = 1;
- if (work->iov_alloc_cnt <= work->iov_cnt) {
+ if (aux_size) {
+ need_iov_cnt++;
+ ar = kmalloc(sizeof(struct aux_read), GFP_KERNEL);
+ if (!ar)
+ return -ENOMEM;
+ }
+
+ if (work->iov_alloc_cnt < work->iov_cnt + need_iov_cnt) {
struct kvec *new;
work->iov_alloc_cnt += 4;
@@ -111,16 +128,6 @@ static int ksmbd_realloc_iov_pin(struct ksmbd_work *work, void *ib,
work->iov = new;
}
- work->iov[++work->iov_idx].iov_base = ib;
- work->iov[work->iov_idx].iov_len = ib_len;
- work->iov_cnt++;
-
- return 0;
-}
-
-static int __ksmbd_iov_pin_rsp(struct ksmbd_work *work, void *ib, int len,
- void *aux_buf, unsigned int aux_size)
-{
/* Plus rfc_length size on first iov */
if (!work->iov_idx) {
work->iov[work->iov_idx].iov_base = work->response_buf;
@@ -129,19 +136,13 @@ static int __ksmbd_iov_pin_rsp(struct ksmbd_work *work, void *ib, int len,
work->iov_cnt++;
}
- ksmbd_realloc_iov_pin(work, ib, len);
+ __ksmbd_iov_pin(work, ib, len);
inc_rfc1001_len(work->iov[0].iov_base, len);
if (aux_size) {
- struct aux_read *ar;
-
- ksmbd_realloc_iov_pin(work, aux_buf, aux_size);
+ __ksmbd_iov_pin(work, aux_buf, aux_size);
inc_rfc1001_len(work->iov[0].iov_base, aux_size);
- ar = kmalloc(sizeof(struct aux_read), GFP_KERNEL);
- if (!ar)
- return -ENOMEM;
-
ar->buf = aux_buf;
list_add(&ar->entry, &work->aux_read_list);
}
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] ksmbd: fix wrong error response status by using set_smb2_rsp_status()
2023-10-09 15:11 [v2 PATCH] ksmbd: not allow to open file if delelete on close bit is set Namjae Jeon
2023-10-09 15:11 ` [PATCH] ksmbd: reorganize ksmbd_iov_pin_rsp() Namjae Jeon
@ 2023-10-09 15:11 ` Namjae Jeon
2023-10-09 15:11 ` [PATCH] ksmbd: fix kernel-doc comment of ksmbd_vfs_setxattr() Namjae Jeon
2 siblings, 0 replies; 4+ messages in thread
From: Namjae Jeon @ 2023-10-09 15:11 UTC (permalink / raw)
To: linux-cifs
Cc: smfrench, senozhatsky, tom, hyc.lee, atteh.mailbox, Namjae Jeon
set_smb2_rsp_status() after __process_request() sets the wrong error
status. This patch resets all iov vectors and sets the error status
on clean one.
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
---
fs/smb/server/smb2pdu.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index 898860adf929..87c6401a6007 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -231,11 +231,12 @@ void set_smb2_rsp_status(struct ksmbd_work *work, __le32 err)
{
struct smb2_hdr *rsp_hdr;
- if (work->next_smb2_rcv_hdr_off)
- rsp_hdr = ksmbd_resp_buf_next(work);
- else
- rsp_hdr = smb2_get_msg(work->response_buf);
+ rsp_hdr = smb2_get_msg(work->response_buf);
rsp_hdr->Status = err;
+
+ work->iov_idx = 0;
+ work->iov_cnt = 0;
+ work->next_smb2_rcv_hdr_off = 0;
smb2_set_err_rsp(work);
}
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] ksmbd: fix kernel-doc comment of ksmbd_vfs_setxattr()
2023-10-09 15:11 [v2 PATCH] ksmbd: not allow to open file if delelete on close bit is set Namjae Jeon
2023-10-09 15:11 ` [PATCH] ksmbd: reorganize ksmbd_iov_pin_rsp() Namjae Jeon
2023-10-09 15:11 ` [PATCH] ksmbd: fix wrong error response status by using set_smb2_rsp_status() Namjae Jeon
@ 2023-10-09 15:11 ` Namjae Jeon
2 siblings, 0 replies; 4+ messages in thread
From: Namjae Jeon @ 2023-10-09 15:11 UTC (permalink / raw)
To: linux-cifs
Cc: smfrench, senozhatsky, tom, hyc.lee, atteh.mailbox, Namjae Jeon,
kernel test robot
Fix argument list that the kdoc format and script verified in
ksmbd_vfs_setxattr().
fs/smb/server/vfs.c:929: warning: Function parameter or member 'path'
not described in 'ksmbd_vfs_setxattr'
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
---
fs/smb/server/vfs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/smb/server/vfs.c b/fs/smb/server/vfs.c
index b5a5e50fc9ca..2e37939a8ba0 100644
--- a/fs/smb/server/vfs.c
+++ b/fs/smb/server/vfs.c
@@ -919,7 +919,7 @@ ssize_t ksmbd_vfs_getxattr(struct mnt_idmap *idmap,
/**
* ksmbd_vfs_setxattr() - vfs helper for smb set extended attributes value
* @idmap: idmap of the relevant mount
- * @dentry: dentry to set XATTR at
+ * @path: path of dentry to set XATTR at
* @attr_name: xattr name for setxattr
* @attr_value: xattr value to set
* @attr_size: size of xattr value
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-10-09 15:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-09 15:11 [v2 PATCH] ksmbd: not allow to open file if delelete on close bit is set Namjae Jeon
2023-10-09 15:11 ` [PATCH] ksmbd: reorganize ksmbd_iov_pin_rsp() Namjae Jeon
2023-10-09 15:11 ` [PATCH] ksmbd: fix wrong error response status by using set_smb2_rsp_status() Namjae Jeon
2023-10-09 15:11 ` [PATCH] ksmbd: fix kernel-doc comment of ksmbd_vfs_setxattr() Namjae Jeon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).