Linux CIFS filesystem development
 help / color / mirror / Atom feed
* [PATCH v2 0/3] smb: fix xfstests generic/035
@ 2026-08-04 12:32 ChenXiaoSong
  2026-08-04 12:32 ` [PATCH v2 1/3] smb/server: rename to ksmbd_has_nonposix_open_child() ChenXiaoSong
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: ChenXiaoSong @ 2026-08-04 12:32 UTC (permalink / raw)
  To: smfrench, linkinjeon, pc, ronniesahlberg, sprasad, tom, bharathsm,
	senozhatsky, dhowells, metze, slow
  Cc: linux-cifs, ChenXiaoSong

From: ChenXiaoSong <chenxiaosong@kylinos.cn>

v1->v2:
  - Add patch #01 #03.
  - Patch #02: introduce helper ksmbd_has_other_nonposix_open().

v1: https://lore.kernel.org/linux-cifs/20260611085847.653284-1-chenxiaosong@chenxiaosong.com/

ChenXiaoSong (3):
  smb/server: rename to ksmbd_has_nonposix_open_child()
  smb/server: deny overwriting targets with non-POSIX opens
  smb/client: fix nlink of an overwritten open file

 fs/smb/client/inode.c     | 11 ++++++-----
 fs/smb/server/vfs.c       | 15 ++++++++++++++-
 fs/smb/server/vfs_cache.c | 34 +++++++++++++++++++++++++++++++++-
 fs/smb/server/vfs_cache.h |  3 ++-
 4 files changed, 55 insertions(+), 8 deletions(-)

-- 
2.54.0


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

* [PATCH v2 1/3] smb/server: rename to ksmbd_has_nonposix_open_child()
  2026-08-04 12:32 [PATCH v2 0/3] smb: fix xfstests generic/035 ChenXiaoSong
@ 2026-08-04 12:32 ` ChenXiaoSong
  2026-08-04 12:33 ` [PATCH v2 2/3] smb/server: deny overwriting targets with non-POSIX opens ChenXiaoSong
  2026-08-04 12:33 ` [PATCH v2 3/3] smb/client: fix nlink of an overwritten open file ChenXiaoSong
  2 siblings, 0 replies; 11+ messages in thread
From: ChenXiaoSong @ 2026-08-04 12:32 UTC (permalink / raw)
  To: smfrench, linkinjeon, pc, ronniesahlberg, sprasad, tom, bharathsm,
	senozhatsky, dhowells, metze, slow
  Cc: linux-cifs, ChenXiaoSong

From: ChenXiaoSong <chenxiaosong@kylinos.cn>

The original function name `ksmbd_has_open_files()` could be confused with
the function name introduced in the next patch, and it does not accurately
describe what this function does.

Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
 fs/smb/server/vfs.c       | 2 +-
 fs/smb/server/vfs_cache.c | 2 +-
 fs/smb/server/vfs_cache.h | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/smb/server/vfs.c b/fs/smb/server/vfs.c
index 28940c7b5f83..16ef8d051b18 100644
--- a/fs/smb/server/vfs.c
+++ b/fs/smb/server/vfs.c
@@ -721,7 +721,7 @@ int ksmbd_vfs_rename(struct ksmbd_work *work, struct ksmbd_file *old_fp,
 	if (err)
 		goto out_drop_write;
 
-	if (d_is_dir(old_child) && ksmbd_has_open_files(old_fp)) {
+	if (d_is_dir(old_child) && ksmbd_has_nonposix_open_child(old_fp)) {
 		err = -EACCES;
 		goto out3;
 	}
diff --git a/fs/smb/server/vfs_cache.c b/fs/smb/server/vfs_cache.c
index eac9886eb6e3..028bc1b0f652 100644
--- a/fs/smb/server/vfs_cache.c
+++ b/fs/smb/server/vfs_cache.c
@@ -1137,7 +1137,7 @@ struct ksmbd_file *ksmbd_lookup_fd_inode(struct dentry *dentry)
 	return NULL;
 }
 
-bool ksmbd_has_open_files(struct ksmbd_file *old_fp)
+bool ksmbd_has_nonposix_open_child(struct ksmbd_file *old_fp)
 {
 	struct dentry *dentry = old_fp->filp->f_path.dentry;
 	struct ksmbd_file *fp;
diff --git a/fs/smb/server/vfs_cache.h b/fs/smb/server/vfs_cache.h
index 127ea4987e3f..9dca617bc429 100644
--- a/fs/smb/server/vfs_cache.h
+++ b/fs/smb/server/vfs_cache.h
@@ -212,7 +212,7 @@ bool ksmbd_has_stream_without_delete_share(struct ksmbd_file *fp);
 int ksmbd_close_fd_app_instance_id(char *app_instance_id);
 struct ksmbd_file *ksmbd_lookup_fd_cguid(char *cguid);
 struct ksmbd_file *ksmbd_lookup_fd_inode(struct dentry *dentry);
-bool ksmbd_has_open_files(struct ksmbd_file *old_fp);
+bool ksmbd_has_nonposix_open_child(struct ksmbd_file *old_fp);
 unsigned int ksmbd_open_durable_fd(struct ksmbd_file *fp);
 struct ksmbd_file *ksmbd_open_fd(struct ksmbd_work *work, struct file *filp);
 void ksmbd_launch_ksmbd_durable_scavenger(void);
-- 
2.54.0


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

* [PATCH v2 2/3] smb/server: deny overwriting targets with non-POSIX opens
  2026-08-04 12:32 [PATCH v2 0/3] smb: fix xfstests generic/035 ChenXiaoSong
  2026-08-04 12:32 ` [PATCH v2 1/3] smb/server: rename to ksmbd_has_nonposix_open_child() ChenXiaoSong
@ 2026-08-04 12:33 ` ChenXiaoSong
  2026-08-05  2:17   ` Namjae Jeon
  2026-08-04 12:33 ` [PATCH v2 3/3] smb/client: fix nlink of an overwritten open file ChenXiaoSong
  2 siblings, 1 reply; 11+ messages in thread
From: ChenXiaoSong @ 2026-08-04 12:33 UTC (permalink / raw)
  To: smfrench, linkinjeon, pc, ronniesahlberg, sprasad, tom, bharathsm,
	senozhatsky, dhowells, metze, slow
  Cc: linux-cifs, ChenXiaoSong

From: ChenXiaoSong <chenxiaosong@kylinos.cn>

Reproducer:

  1. server: systemctl start ksmbd
  2. client: mount without `posix` option
     mount -t cifs //${server_ip}/export /mnt
  3. client: touch /mnt/file1 /mnt/file2
  4. client: C program: int fd = open("/mnt/file2", O_RDONLY);
  5. client: C program: rename("/mnt/file1", "/mnt/file2");
  6. client: C program: struct stat stbuf; fstat(fd, &stbuf);
                        stbuf.st_nlink is 1, should be 0

This patch fixes xfstests generic/035 when mounted without `posix` option.

Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
 fs/smb/server/vfs.c       | 13 +++++++++++++
 fs/smb/server/vfs_cache.c | 32 ++++++++++++++++++++++++++++++++
 fs/smb/server/vfs_cache.h |  1 +
 3 files changed, 46 insertions(+)

diff --git a/fs/smb/server/vfs.c b/fs/smb/server/vfs.c
index 16ef8d051b18..9102ab47a3aa 100644
--- a/fs/smb/server/vfs.c
+++ b/fs/smb/server/vfs.c
@@ -726,6 +726,19 @@ int ksmbd_vfs_rename(struct ksmbd_work *work, struct ksmbd_file *old_fp,
 		goto out3;
 	}
 
+	/*
+	 * See MS-FSA 2.1.5.15.12.
+	 * An overwrite rename must fail with STATUS_ACCESS_DENIED if the
+	 * existing target still has a non-POSIX open.
+	 */
+	if (!(flags & (RENAME_NOREPLACE | RENAME_EXCHANGE)) &&
+	    d_inode(rd.new_dentry) &&
+	    d_inode(rd.new_dentry) != d_inode(old_child) &&
+	    ksmbd_has_other_nonposix_open(rd.new_dentry)) {
+		err = -EACCES;
+		goto out3;
+	}
+
 	err = ksmbd_vfs_check_rename_share(work, old_path);
 	if (err)
 		goto out3;
diff --git a/fs/smb/server/vfs_cache.c b/fs/smb/server/vfs_cache.c
index 028bc1b0f652..94b2b5e48d3d 100644
--- a/fs/smb/server/vfs_cache.c
+++ b/fs/smb/server/vfs_cache.c
@@ -1137,6 +1137,38 @@ struct ksmbd_file *ksmbd_lookup_fd_inode(struct dentry *dentry)
 	return NULL;
 }
 
+bool ksmbd_has_other_nonposix_open(struct dentry *dentry)
+{
+	struct ksmbd_file *fp;
+	struct ksmbd_inode *ci;
+	struct inode *inode = d_inode(dentry);
+	bool ret = false;
+
+	if (!inode)
+		return false;
+
+	ci = ksmbd_inode_lookup_lock(dentry);
+	if (!ci)
+		return false;
+
+	down_read(&ci->m_lock);
+	list_for_each_entry(fp, &ci->m_fp_list, node) {
+		if (READ_ONCE(fp->f_state) != FP_INITED)
+			continue;
+		if (inode != file_inode(fp->filp))
+			continue;
+		if (fp->is_posix_ctxt)
+			continue;
+
+		ret = true;
+		break;
+	}
+	up_read(&ci->m_lock);
+	ksmbd_inode_put(ci);
+
+	return ret;
+}
+
 bool ksmbd_has_nonposix_open_child(struct ksmbd_file *old_fp)
 {
 	struct dentry *dentry = old_fp->filp->f_path.dentry;
diff --git a/fs/smb/server/vfs_cache.h b/fs/smb/server/vfs_cache.h
index 9dca617bc429..5cac022b540b 100644
--- a/fs/smb/server/vfs_cache.h
+++ b/fs/smb/server/vfs_cache.h
@@ -212,6 +212,7 @@ bool ksmbd_has_stream_without_delete_share(struct ksmbd_file *fp);
 int ksmbd_close_fd_app_instance_id(char *app_instance_id);
 struct ksmbd_file *ksmbd_lookup_fd_cguid(char *cguid);
 struct ksmbd_file *ksmbd_lookup_fd_inode(struct dentry *dentry);
+bool ksmbd_has_other_nonposix_open(struct dentry *dentry);
 bool ksmbd_has_nonposix_open_child(struct ksmbd_file *old_fp);
 unsigned int ksmbd_open_durable_fd(struct ksmbd_file *fp);
 struct ksmbd_file *ksmbd_open_fd(struct ksmbd_work *work, struct file *filp);
-- 
2.54.0


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

* [PATCH v2 3/3] smb/client: fix nlink of an overwritten open file
  2026-08-04 12:32 [PATCH v2 0/3] smb: fix xfstests generic/035 ChenXiaoSong
  2026-08-04 12:32 ` [PATCH v2 1/3] smb/server: rename to ksmbd_has_nonposix_open_child() ChenXiaoSong
  2026-08-04 12:33 ` [PATCH v2 2/3] smb/server: deny overwriting targets with non-POSIX opens ChenXiaoSong
@ 2026-08-04 12:33 ` ChenXiaoSong
  2026-08-04 17:08   ` Steve French
  2 siblings, 1 reply; 11+ messages in thread
From: ChenXiaoSong @ 2026-08-04 12:33 UTC (permalink / raw)
  To: smfrench, linkinjeon, pc, ronniesahlberg, sprasad, tom, bharathsm,
	senozhatsky, dhowells, metze, slow
  Cc: linux-cifs, ChenXiaoSong

From: ChenXiaoSong <chenxiaosong@kylinos.cn>

Reproducer:

  1. server: systemctl start ksmbd
  2. client: mount with `posix` option
     mount -t cifs -o posix //${server_ip}/export /mnt
  3. client: touch /mnt/file1 /mnt/file2
  4. client: C program: int fd = open("/mnt/file2", O_RDONLY);
  5. client: C program: rename("/mnt/file1", "/mnt/file2");
  6. client: C program: struct stat stbuf; fstat(fd, &stbuf);
                        stbuf.st_nlink is 1, should be 0

This patch fixes xfstests generic/035 when mounted with `posix` option.

Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
 fs/smb/client/inode.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c
index 0afff761aab9..0b6273ce01a8 100644
--- a/fs/smb/client/inode.c
+++ b/fs/smb/client/inode.c
@@ -2648,11 +2648,8 @@ cifs_rename2(struct mnt_idmap *idmap, struct inode *source_dir,
 	if (d_really_is_positive(target_dentry)) {
 		if (!rc) {
 			struct inode *inode = d_inode(target_dentry);
-			/*
-			 * Samba and ksmbd servers allow renaming a target
-			 * directory that is open, so make sure to update
-			 * ->i_nlink and then mark it as delete pending.
-			 */
+
+			/* Update the target link count after rename. */
 			if (S_ISDIR(inode->i_mode)) {
 				drop_cached_dir_by_name(xid, tcon, to_name, cifs_sb);
 				spin_lock(&inode->i_lock);
@@ -2663,6 +2660,10 @@ cifs_rename2(struct mnt_idmap *idmap, struct inode *source_dir,
 				CIFS_I(inode)->time = 0; /* force reval */
 				inode_set_ctime_current(inode);
 				inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
+			} else {
+				cifs_mark_open_handles_for_deleted_file(inode, to_name);
+				cifs_drop_nlink(inode);
+				inode_set_ctime_current(inode);
 			}
 		} else if (rc == -EACCES || rc == -EEXIST) {
 			/*
-- 
2.54.0


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

* Re: [PATCH v2 3/3] smb/client: fix nlink of an overwritten open file
  2026-08-04 12:33 ` [PATCH v2 3/3] smb/client: fix nlink of an overwritten open file ChenXiaoSong
@ 2026-08-04 17:08   ` Steve French
  2026-08-04 18:53     ` ChenXiaoSong
  0 siblings, 1 reply; 11+ messages in thread
From: Steve French @ 2026-08-04 17:08 UTC (permalink / raw)
  To: ChenXiaoSong
  Cc: linkinjeon, pc, ronniesahlberg, sprasad, tom, bharathsm,
	senozhatsky, dhowells, metze, slow, linux-cifs, ChenXiaoSong

> This patch fixes xfstests generic/035 when mounted with `posix` option.

generic/035 passes to Samba with posix mount option without the patch.
Any idea why this patch was needed for ksmbd but not for Samba

On Tue, Aug 4, 2026 at 7:34 AM ChenXiaoSong
<chenxiaosong@chenxiaosong.com> wrote:
>
> From: ChenXiaoSong <chenxiaosong@kylinos.cn>
>
> Reproducer:
>
>   1. server: systemctl start ksmbd
>   2. client: mount with `posix` option
>      mount -t cifs -o posix //${server_ip}/export /mnt
>   3. client: touch /mnt/file1 /mnt/file2
>   4. client: C program: int fd = open("/mnt/file2", O_RDONLY);
>   5. client: C program: rename("/mnt/file1", "/mnt/file2");
>   6. client: C program: struct stat stbuf; fstat(fd, &stbuf);
>                         stbuf.st_nlink is 1, should be 0
>
> This patch fixes xfstests generic/035 when mounted with `posix` option.
>
> Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
> ---
>  fs/smb/client/inode.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c
> index 0afff761aab9..0b6273ce01a8 100644
> --- a/fs/smb/client/inode.c
> +++ b/fs/smb/client/inode.c
> @@ -2648,11 +2648,8 @@ cifs_rename2(struct mnt_idmap *idmap, struct inode *source_dir,
>         if (d_really_is_positive(target_dentry)) {
>                 if (!rc) {
>                         struct inode *inode = d_inode(target_dentry);
> -                       /*
> -                        * Samba and ksmbd servers allow renaming a target
> -                        * directory that is open, so make sure to update
> -                        * ->i_nlink and then mark it as delete pending.
> -                        */
> +
> +                       /* Update the target link count after rename. */
>                         if (S_ISDIR(inode->i_mode)) {
>                                 drop_cached_dir_by_name(xid, tcon, to_name, cifs_sb);
>                                 spin_lock(&inode->i_lock);
> @@ -2663,6 +2660,10 @@ cifs_rename2(struct mnt_idmap *idmap, struct inode *source_dir,
>                                 CIFS_I(inode)->time = 0; /* force reval */
>                                 inode_set_ctime_current(inode);
>                                 inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
> +                       } else {
> +                               cifs_mark_open_handles_for_deleted_file(inode, to_name);
> +                               cifs_drop_nlink(inode);
> +                               inode_set_ctime_current(inode);
>                         }
>                 } else if (rc == -EACCES || rc == -EEXIST) {
>                         /*
> --
> 2.54.0
>


-- 
Thanks,

Steve

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

* Re: [PATCH v2 3/3] smb/client: fix nlink of an overwritten open file
  2026-08-04 17:08   ` Steve French
@ 2026-08-04 18:53     ` ChenXiaoSong
  2026-08-04 19:38       ` ChenXiaoSong
  0 siblings, 1 reply; 11+ messages in thread
From: ChenXiaoSong @ 2026-08-04 18:53 UTC (permalink / raw)
  To: Steve French
  Cc: linkinjeon, pc, ronniesahlberg, sprasad, tom, bharathsm,
	senozhatsky, dhowells, metze, slow, linux-cifs, ChenXiaoSong

Samba has a bug, please check the email: 
https://lore.kernel.org/linux-cifs/0f6a5c9c-2c65-480e-aa44-facdf11fecc0@samba.org/

在 2026/8/5 1:08, Steve French 写道:
> generic/035 passes to Samba with posix mount option without the patch.
> Any idea why this patch was needed for ksmbd but not for Samba

-- 
ChenXiaoSong <chenxiaosong@chenxiaosong.com>
Chinese Homepage: https://chenxiaosong.com
English Homepage: https://chenxiaosong.com/en


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

* Re: [PATCH v2 3/3] smb/client: fix nlink of an overwritten open file
  2026-08-04 18:53     ` ChenXiaoSong
@ 2026-08-04 19:38       ` ChenXiaoSong
  0 siblings, 0 replies; 11+ messages in thread
From: ChenXiaoSong @ 2026-08-04 19:38 UTC (permalink / raw)
  To: Steve French
  Cc: linkinjeon, pc, ronniesahlberg, sprasad, tom, bharathsm,
	senozhatsky, dhowells, metze, slow, linux-cifs, ChenXiaoSong

As Ralph said,

- if there are one or more non-POSIX opens on the destination, MUST fail 
with STATUS_ACCESS_DENIED
- if there are only POSIX opens, the operation can proceed

Samba should allow the rename to succeed so that the silly-rename is not 
triggered.

We should fix this bug in Samba so that the Linux client should call 
cifs_drop_nlink(). Since silly-rename will not be triggered, 
__cifs_unlink() will not be called either.

在 2026/8/5 2:53, ChenXiaoSong 写道:
> Samba has a bug, please check the email: https://lore.kernel.org/linux- 
> cifs/0f6a5c9c-2c65-480e-aa44-facdf11fecc0@samba.org/
> 
> 在 2026/8/5 1:08, Steve French 写道:
>> generic/035 passes to Samba with posix mount option without the patch.
>> Any idea why this patch was needed for ksmbd but not for Samba
> 

-- 
ChenXiaoSong <chenxiaosong@chenxiaosong.com>
Chinese Homepage: https://chenxiaosong.com
English Homepage: https://chenxiaosong.com/en


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

* Re: [PATCH v2 2/3] smb/server: deny overwriting targets with non-POSIX opens
  2026-08-04 12:33 ` [PATCH v2 2/3] smb/server: deny overwriting targets with non-POSIX opens ChenXiaoSong
@ 2026-08-05  2:17   ` Namjae Jeon
  2026-08-05  2:25     ` ChenXiaoSong
       [not found]     ` <2df0ad6e-fa5c-425d-9ec1-5c668f84a4bd@chenxiaosong.com>
  0 siblings, 2 replies; 11+ messages in thread
From: Namjae Jeon @ 2026-08-05  2:17 UTC (permalink / raw)
  To: ChenXiaoSong
  Cc: smfrench, pc, ronniesahlberg, sprasad, tom, bharathsm,
	senozhatsky, dhowells, metze, slow, linux-cifs, ChenXiaoSong

> +bool ksmbd_has_other_nonposix_open(struct dentry *dentry)
> +{
> +       struct ksmbd_file *fp;
> +       struct ksmbd_inode *ci;
> +       struct inode *inode = d_inode(dentry);
> +       bool ret = false;
> +
> +       if (!inode)
> +               return false;
> +
> +       ci = ksmbd_inode_lookup_lock(dentry);
The new check is limited to the target dentry's
ksmbd_inode->m_fp_list. Therefore, it does not cover a struct
ksmbd_file opened through another hardlink dentry, even though
file_inode(fp->filp) == d_inode(dentry). For example, if file2.link is
a hardlink to file2 and file2.link is opened with a non-POSIX context,
an overwrite rename of another file to file2 can miss that open
handle.
This appears to be an existing limitation rather than a regression
introduced by this patch. However, since this patch is intended to
reject overwrites when the target has a non-POSIX ksmbd_file...

> +       if (!ci)
> +               return false;
> +
> +       down_read(&ci->m_lock);
> +       list_for_each_entry(fp, &ci->m_fp_list, node) {
> +               if (READ_ONCE(fp->f_state) != FP_INITED)
> +                       continue;
> +               if (inode != file_inode(fp->filp))
> +                       continue;
> +               if (fp->is_posix_ctxt)
> +                       continue;
> +
> +               ret = true;
> +               break;
> +       }
> +       up_read(&ci->m_lock);
> +       ksmbd_inode_put(ci);

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

* Re: [PATCH v2 2/3] smb/server: deny overwriting targets with non-POSIX opens
  2026-08-05  2:17   ` Namjae Jeon
@ 2026-08-05  2:25     ` ChenXiaoSong
       [not found]     ` <2df0ad6e-fa5c-425d-9ec1-5c668f84a4bd@chenxiaosong.com>
  1 sibling, 0 replies; 11+ messages in thread
From: ChenXiaoSong @ 2026-08-05  2:25 UTC (permalink / raw)
  To: Namjae Jeon
  Cc: smfrench, pc, ronniesahlberg, sprasad, tom, bharathsm,
	senozhatsky, dhowells, metze, slow, linux-cifs, ChenXiaoSong

Got it, I will add it to my todo list, and submit a separate patch to 
fix this pre-existing issue.

On 8/5/26 10:17, Namjae Jeon wrote:
> This appears to be an existing limitation rather than a regression
> introduced by this patch

-- 
ChenXiaoSong <chenxiaosong@chenxiaosong.com>
Chinese Homepage: https://chenxiaosong.com
English Homepage: https://chenxiaosong.com/en


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

* Re: [PATCH v2 2/3] smb/server: deny overwriting targets with non-POSIX opens
       [not found]     ` <2df0ad6e-fa5c-425d-9ec1-5c668f84a4bd@chenxiaosong.com>
@ 2026-08-05  5:46       ` Namjae Jeon
  2026-08-05  5:53         ` ChenXiaoSong
  0 siblings, 1 reply; 11+ messages in thread
From: Namjae Jeon @ 2026-08-05  5:46 UTC (permalink / raw)
  To: ChenXiaoSong
  Cc: smfrench, pc, ronniesahlberg, sprasad, tom, bharathsm,
	senozhatsky, dhowells, metze, slow, linux-cifs

On Wed, Aug 5, 2026 at 12:09 PM ChenXiaoSong
<chenxiaosong@chenxiaosong.com> wrote:
>
> Hi Namjae,
>
> What do you think about iterating over `global_ft.idr` instead?
Looks ok. I will apply after running my tests tonight.
Thanks!
>
> ```
> ksmbd_has_other_nonposix_open() {
>         read_lock(&global_ft.lock);
>         idr_for_each_entry(global_ft.idr, fp, id) {
>         }
>         read_unlock(&global_ft.lock);
> }
> ```
>
> On 8/5/26 10:17, Namjae Jeon wrote:
> > The new check is limited to the target dentry's
> > ksmbd_inode->m_fp_list. Therefore, it does not cover a struct
> > ksmbd_file opened through another hardlink dentry, even though
> > file_inode(fp->filp) == d_inode(dentry). For example, if file2.link is
> > a hardlink to file2 and file2.link is opened with a non-POSIX context,
> > an overwrite rename of another file to file2 can miss that open
> > handle.
> > This appears to be an existing limitation rather than a regression
> > introduced by this patch. However, since this patch is intended to
> > reject overwrites when the target has a non-POSIX ksmbd_file...
>
> --
> ChenXiaoSong <chenxiaosong@chenxiaosong.com>
> Chinese Homepage: https://chenxiaosong.com
> English Homepage: https://chenxiaosong.com/en
>

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

* Re: [PATCH v2 2/3] smb/server: deny overwriting targets with non-POSIX opens
  2026-08-05  5:46       ` Namjae Jeon
@ 2026-08-05  5:53         ` ChenXiaoSong
  0 siblings, 0 replies; 11+ messages in thread
From: ChenXiaoSong @ 2026-08-05  5:53 UTC (permalink / raw)
  To: Namjae Jeon
  Cc: smfrench, pc, ronniesahlberg, sprasad, tom, bharathsm,
	senozhatsky, dhowells, metze, slow, linux-cifs

I have sent v3: 
https://lore.kernel.org/linux-cifs/20260805051112.305078-1-chenxiaosong@chenxiaosong.com/

On 8/5/26 13:46, Namjae Jeon wrote:
> Looks ok. I will apply after running my tests tonight.
> Thanks!

-- 
ChenXiaoSong <chenxiaosong@chenxiaosong.com>
Chinese Homepage: https://chenxiaosong.com
English Homepage: https://chenxiaosong.com/en


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

end of thread, other threads:[~2026-08-05  5:54 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-04 12:32 [PATCH v2 0/3] smb: fix xfstests generic/035 ChenXiaoSong
2026-08-04 12:32 ` [PATCH v2 1/3] smb/server: rename to ksmbd_has_nonposix_open_child() ChenXiaoSong
2026-08-04 12:33 ` [PATCH v2 2/3] smb/server: deny overwriting targets with non-POSIX opens ChenXiaoSong
2026-08-05  2:17   ` Namjae Jeon
2026-08-05  2:25     ` ChenXiaoSong
     [not found]     ` <2df0ad6e-fa5c-425d-9ec1-5c668f84a4bd@chenxiaosong.com>
2026-08-05  5:46       ` Namjae Jeon
2026-08-05  5:53         ` ChenXiaoSong
2026-08-04 12:33 ` [PATCH v2 3/3] smb/client: fix nlink of an overwritten open file ChenXiaoSong
2026-08-04 17:08   ` Steve French
2026-08-04 18:53     ` ChenXiaoSong
2026-08-04 19:38       ` ChenXiaoSong

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