Skip to contentSkip to conversation

smb/server: do not require delete access for non-replacing links

PATCH Applied ChenXiaoSong 2 participants 3 messages Jun 28

Subsystems (3)
lore
Share & tools
lore

ChenXiaoSong

author reviewer
#0 lore raw

PATCH 1/1 smb/server: do not require delete access for non-replacing links

From: ChenXiaoSong <[email protected]>

Reproducer:

1. server: systemctl start ksmbd
2. client: mount -t cifs //${server_ip}/export /mnt
3. client: touch /mnt/file; ln /mnt/file /mnt/hardlink
4. client err log: ln: failed to create hard link 'hardlink' => 'file': Permission denied
5. server err log: ksmbd: no right to delete : 0x80

Fixes 13f3942f2bf4 ("ksmbd: add per-handle permission check to FILE_LINK_INFORMATION")
---
 fs/smb/server/smb2pdu.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
fs/smb/server/smb2pdu.c +8 -6
index 727ba86ede36..097f51fc7ed6 100644
@@ -6921,16 +6921,18 @@ static int smb2_set_info_file(struct ksmbd_work *work, struct ksmbd_file *fp,
 	}
 	case FILE_LINK_INFORMATION:
 	{
-		if (!(fp->daccess & FILE_DELETE_LE)) {
-			pr_err("no right to delete : 0x%x\n", fp->daccess);
-			return -EACCES;
-		}
+		struct smb2_file_link_info *file_info;
 
 		if (buf_len < sizeof(struct smb2_file_link_info))
 			return -EMSGSIZE;
 
-		return smb2_create_link(work, work->tcon->share_conf,
-					(struct smb2_file_link_info *)buffer,
+		file_info = (struct smb2_file_link_info *)buffer;
+		if (file_info->ReplaceIfExists && !(fp->daccess & FILE_DELETE_LE)) {
+			pr_err("no right to delete : 0x%x\n", fp->daccess);
+			return -EACCES;
+		}
+
+		return smb2_create_link(work, work->tcon->share_conf, file_info,
 					buf_len, fp->filp,
 					work->conn->local_nls);
 	}
Signature · 1 line
2.54.0
author reviewer
#1 lore raw
Quoted 13 lines · ChenXiaoSong

From: ChenXiaoSong <[email protected]>

Reproducer:

1. server: systemctl start ksmbd
2. client: mount -t cifs //${server_ip}/export /mnt
3. client: touch /mnt/file; ln /mnt/file /mnt/hardlink
4. client err log: ln: failed to create hard link 'hardlink' => 'file': Permission denied
5. server err log: ksmbd: no right to delete : 0x80

Fixes 13f3942f2bf4 ("ksmbd: add per-handle permission check to FILE_LINK_INFORMATION")
Signature · 3 lines
ChenXiaoSong <[email protected]>
Chinese Homepage: https://chenxiaosong.com
English Homepage: https://chenxiaosong.com/en
maintainer Applied
#2 lore raw
In reply to ChenXiaoSong
Quoted 11 lines · ChenXiaoSong

From: ChenXiaoSong <[email protected]>

Reproducer:

1. server: systemctl start ksmbd
2. client: mount -t cifs //${server_ip}/export /mnt
3. client: touch /mnt/file; ln /mnt/file /mnt/hardlink
4. client err log: ln: failed to create hard link 'hardlink' => 'file': Permission denied
5. server err log: ksmbd: no right to delete : 0x80

Quoted 3 lines
Fixes 13f3942f2bf4 ("ksmbd: add per-handle permission check to FILE_LINK_INFORMATION")

Applied it to #ksmbd-for-next-next.
Thanks!