Skip to contentSkip to conversation

ksmbd: remove follow symlinks support

PATCH Superseded Namjae Jeon 3 participants 10 messages Sep 20, 2021 – Sep 21, 2021

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Namjae Jeon

author maintainer
#0 lore raw

PATCH 1/1 ksmbd: remove follow symlinks support

This patch remove symlink support that can be vulnerable, and we re-implement it as reparse point later.

Cc Ronnie Sahlberg <[email protected]>
Cc Ralph Böhme <[email protected]>
Cc Steve French <[email protected]>
---
 fs/ksmbd/smb2pdu.c | 55 ++++++++++------------------------------------
 fs/ksmbd/vfs.c     | 50 +++++++++--------------------------------
 2 files changed, 21 insertions(+), 84 deletions(-)
fs/ksmbd/smb2pdu.c +11 -44
index afc508c2656d..911c5e97678d 100644
@@ -2661,17 +2661,7 @@ int smb2_open(struct ksmbd_work *work)
 	}
 
 	if (req->CreateOptions & FILE_DELETE_ON_CLOSE_LE) {
-		if (test_share_config_flag(work->tcon->share_conf,
-					   KSMBD_SHARE_FLAG_FOLLOW_SYMLINKS)) {
-			/*
-			 * On delete request, instead of following up, need to
-			 * look the current entity
-			 */
-			rc = ksmbd_vfs_kern_path(name, 0, &path, 1);
-		} else {
-			rc = ksmbd_vfs_kern_path(name, LOOKUP_NO_SYMLINKS, &path, 1);
-		}
-
+		rc = ksmbd_vfs_kern_path(name, LOOKUP_NO_SYMLINKS, &path, 1);
 		if (!rc) {
 			/*
 			 * If file exists with under flags, return access
@@ -2693,24 +2683,11 @@ int smb2_open(struct ksmbd_work *work)
 			}
 		}
 	} else {
-		if (test_share_config_flag(work->tcon->share_conf,
-					   KSMBD_SHARE_FLAG_FOLLOW_SYMLINKS)) {
-			/*
-			 * Use LOOKUP_FOLLOW to follow the path of
-			 * symlink in path buildup
-			 */
-			rc = ksmbd_vfs_kern_path(name, LOOKUP_FOLLOW, &path, 1);
-			if (rc) { /* Case for broken link ?*/
-				rc = ksmbd_vfs_kern_path(name, 0, &path, 1);
-			}
-		} else {
-			rc = ksmbd_vfs_kern_path(name, LOOKUP_NO_SYMLINKS,
-						 &path, 1);
-			if (!rc && d_is_symlink(path.dentry)) {
-				rc = -EACCES;
-				path_put(&path);
-				goto err_out;
-			}
+		rc = ksmbd_vfs_kern_path(name, LOOKUP_NO_SYMLINKS, &path, 1);
+		if (!rc && d_is_symlink(path.dentry)) {
+			rc = -EACCES;
+			path_put(&path);
+			goto err_out;
 		}
 	}
 
@@ -4795,12 +4772,8 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work,
 	struct path path;
 	int rc = 0, len;
 	int fs_infoclass_size = 0;
-	int lookup_flags = LOOKUP_NO_SYMLINKS;
 
-	if (test_share_config_flag(share, KSMBD_SHARE_FLAG_FOLLOW_SYMLINKS))
-		lookup_flags = LOOKUP_FOLLOW;
-
-	rc = ksmbd_vfs_kern_path(share->path, lookup_flags, &path, 0);
+	rc = ksmbd_vfs_kern_path(share->path, LOOKUP_NO_SYMLINKS, &path, 0);
 	if (rc) {
 		pr_err("cannot create vfs path\n");
 		return -EIO;
@@ -5307,7 +5280,7 @@ static int smb2_rename(struct ksmbd_work *work,
 	char *pathname = NULL;
 	struct path path;
 	bool file_present = true;
-	int rc, lookup_flags = LOOKUP_NO_SYMLINKS;
+	int rc;
 
 	ksmbd_debug(SMB, "setting FILE_RENAME_INFO\n");
 	pathname = kmalloc(PATH_MAX, GFP_KERNEL);
@@ -5376,11 +5349,8 @@ static int smb2_rename(struct ksmbd_work *work,
 		goto out;
 	}
 
-	if (test_share_config_flag(share, KSMBD_SHARE_FLAG_FOLLOW_SYMLINKS))
-		lookup_flags = LOOKUP_FOLLOW;
-
 	ksmbd_debug(SMB, "new name %s\n", new_name);
-	rc = ksmbd_vfs_kern_path(new_name, lookup_flags, &path, 1);
+	rc = ksmbd_vfs_kern_path(new_name, LOOKUP_NO_SYMLINKS, &path, 1);
 	if (rc)
 		file_present = false;
 	else
@@ -5430,7 +5400,7 @@ static int smb2_create_link(struct ksmbd_work *work,
 	char *link_name = NULL, *target_name = NULL, *pathname = NULL;
 	struct path path;
 	bool file_present = true;
-	int rc, lookup_flags = LOOKUP_NO_SYMLINKS;
+	int rc;
 
 	if (buf_len < sizeof(struct smb2_file_link_info) +
 			le32_to_cpu(file_info->FileNameLength))
@@ -5457,11 +5427,8 @@ static int smb2_create_link(struct ksmbd_work *work,
 		goto out;
 	}
 
-	if (test_share_config_flag(share, KSMBD_SHARE_FLAG_FOLLOW_SYMLINKS))
-		lookup_flags = LOOKUP_FOLLOW;
-
 	ksmbd_debug(SMB, "target name is %s\n", target_name);
-	rc = ksmbd_vfs_kern_path(link_name, lookup_flags, &path, 0);
+	rc = ksmbd_vfs_kern_path(link_name, LOOKUP_NO_SYMLINKS, &path, 0);
 	if (rc)
 		file_present = false;
 	else
fs/ksmbd/vfs.c +10 -40

109 lines not on this page · raw message

Signature · 1 line
2.25.1
#1 lore raw

Hi Namjae,

Am 20.09.21 um 08:56 schrieb Namjae Jeon:

Quoted 52 lines

This patch remove symlink support that can be vulnerable, and we re-implement it as reparse point later.

Cc Ronnie Sahlberg <[email protected]>
Cc Ralph Böhme <[email protected]>
Cc Steve French <[email protected]>
---
  fs/ksmbd/smb2pdu.c | 55 ++++++++++------------------------------------
  fs/ksmbd/vfs.c     | 50 +++++++++--------------------------------
  2 files changed, 21 insertions(+), 84 deletions(-)
fs/ksmbd/smb2pdu.c +1 -24
index afc508c2656d..911c5e97678d 100644
@@ -2661,17 +2661,7 @@ int smb2_open(struct ksmbd_work *work)
  	}
 
  	if (req->CreateOptions & FILE_DELETE_ON_CLOSE_LE) {
-		if (test_share_config_flag(work->tcon->share_conf,
-					   KSMBD_SHARE_FLAG_FOLLOW_SYMLINKS)) {
-			/*
-			 * On delete request, instead of following up, need to
-			 * look the current entity
-			 */
-			rc = ksmbd_vfs_kern_path(name, 0, &path, 1);
-		} else {
-			rc = ksmbd_vfs_kern_path(name, LOOKUP_NO_SYMLINKS, &path, 1);
-		}
-
+		rc = ksmbd_vfs_kern_path(name, LOOKUP_NO_SYMLINKS, &path, 1);
  		if (!rc) {
  			/*
  			 * If file exists with under flags, return access
@@ -2693,24 +2683,11 @@ int smb2_open(struct ksmbd_work *work)
  			}
  		}
  	} else {
-		if (test_share_config_flag(work->tcon->share_conf,
-					   KSMBD_SHARE_FLAG_FOLLOW_SYMLINKS)) {
-			/*
-			 * Use LOOKUP_FOLLOW to follow the path of
-			 * symlink in path buildup
-			 */
-			rc = ksmbd_vfs_kern_path(name, LOOKUP_FOLLOW, &path, 1);
-			if (rc) { /* Case for broken link ?*/
-				rc = ksmbd_vfs_kern_path(name, 0, &path, 1);
-			}
-		} else {
-			rc = ksmbd_vfs_kern_path(name, LOOKUP_NO_SYMLINKS,
-						 &path, 1);

fs/ksmbd/smb2pdu.c int smb2_open(struct ksmbd_work *work) · line 2690

Quoted 10 lines
fs/ksmbd/smb2pdu.c +5 -5
-			if (!rc && d_is_symlink(path.dentry)) {
-				rc = -EACCES;
-				path_put(&path);
-				goto err_out;
-			}
+		rc = ksmbd_vfs_kern_path(name, LOOKUP_NO_SYMLINKS, &path, 1);
+		if (!rc && d_is_symlink(path.dentry)) {
+			rc = -EACCES;
+			path_put(&path);
+			goto err_out;

why the the check for d_is_symlink()? Wouldn't ksmbd_vfs_kern_path() just return -ELOOP if a path component is a symlink? Hence I guess the below if (rc) where we handle EACCESS should be expanded to handle ELOOP.

I guess I would also refactor the

if (req->CreateOptions & FILE_DELETE_ON_CLOSE_LE)

logic in a previous commit to change the codeflow so there's only one call to ksmbd_vfs_kern_path().

Quoted 7 lines
fs/ksmbd/smb2pdu.c +0 -0
  		}
  	}
 
@@ -4795,12 +4772,8 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work,
  	struct path path;
  	int rc = 0, len;
  	int fs_infoclass_size = 0;

fs/ksmbd/smb2pdu.c static int smb2_get_info_filesystem(struct ksmbd_work *work, · line 4779

Quoted 10 lines
fs/ksmbd/smb2pdu.c +1 -5
-	int lookup_flags = LOOKUP_NO_SYMLINKS;
 
-	if (test_share_config_flag(share, KSMBD_SHARE_FLAG_FOLLOW_SYMLINKS))
-		lookup_flags = LOOKUP_FOLLOW;
-
-	rc = ksmbd_vfs_kern_path(share->path, lookup_flags, &path, 0);
+	rc = ksmbd_vfs_kern_path(share->path, LOOKUP_NO_SYMLINKS, &path, 0);
  	if (rc) {
  		pr_err("cannot create vfs path\n");
  		return -EIO;

why doesn't this return rc?

Quoted 11 lines
fs/ksmbd/smb2pdu.c +1 -1
@@ -5307,7 +5280,7 @@ static int smb2_rename(struct ksmbd_work *work,
  	char *pathname = NULL;
  	struct path path;
  	bool file_present = true;
-	int rc, lookup_flags = LOOKUP_NO_SYMLINKS;
+	int rc;
 
  	ksmbd_debug(SMB, "setting FILE_RENAME_INFO\n");
  	pathname = kmalloc(PATH_MAX, GFP_KERNEL);
@@ -5376,11 +5349,8 @@ static int smb2_rename(struct ksmbd_work *work,
  		goto out;

fs/ksmbd/smb2pdu.c static int smb2_rename(struct ksmbd_work *work, · line 5355

Quoted 10 lines
fs/ksmbd/smb2pdu.c +1 -4
  	}
 
-	if (test_share_config_flag(share, KSMBD_SHARE_FLAG_FOLLOW_SYMLINKS))
-		lookup_flags = LOOKUP_FOLLOW;
-
  	ksmbd_debug(SMB, "new name %s\n", new_name);
-	rc = ksmbd_vfs_kern_path(new_name, lookup_flags, &path, 1);
+	rc = ksmbd_vfs_kern_path(new_name, LOOKUP_NO_SYMLINKS, &path, 1);
  	if (rc)
  		file_present = false;

I guess this should handle ELOOP?

Quoted 12 lines
fs/ksmbd/smb2pdu.c +1 -1
  	else
@@ -5430,7 +5400,7 @@ static int smb2_create_link(struct ksmbd_work *work,
  	char *link_name = NULL, *target_name = NULL, *pathname = NULL;
  	struct path path;
  	bool file_present = true;
-	int rc, lookup_flags = LOOKUP_NO_SYMLINKS;
+	int rc;
 
  	if (buf_len < sizeof(struct smb2_file_link_info) +
  			le32_to_cpu(file_info->FileNameLength))
@@ -5457,11 +5427,8 @@ static int smb2_create_link(struct ksmbd_work *work,
  		goto out;

fs/ksmbd/smb2pdu.c static int smb2_create_link(struct ksmbd_work *work, · line 5433

Quoted 10 lines
fs/ksmbd/smb2pdu.c +1 -4
  	}
 
-	if (test_share_config_flag(share, KSMBD_SHARE_FLAG_FOLLOW_SYMLINKS))
-		lookup_flags = LOOKUP_FOLLOW;
-
  	ksmbd_debug(SMB, "target name is %s\n", target_name);
-	rc = ksmbd_vfs_kern_path(link_name, lookup_flags, &path, 0);
+	rc = ksmbd_vfs_kern_path(link_name, LOOKUP_NO_SYMLINKS, &path, 0);
  	if (rc)
  		file_present = false;

same here?

Other then that: lgtm. Oh, besides, guess this needs an accomanying change to ksmbd-tools?

Cheers!
-slow

Signature · 2 lines
Ralph Boehme, Samba Team                 https://samba.org/
SerNet Samba Team Lead      https://sernet.de/en/team-samba
author maintainer
#2 lore raw

2021-09-20 22:57 GMT+09:00, Ralph Boehme <[email protected]>:

Quoted 61 lines

Hi Namjae,

Am 20.09.21 um 08:56 schrieb Namjae Jeon:

Quoted 58 lines

This patch remove symlink support that can be vulnerable, and we re-implement it as reparse point later.

Cc Ronnie Sahlberg <[email protected]>
Cc Ralph Böhme <[email protected]>
Cc Steve French <[email protected]>
---
  fs/ksmbd/smb2pdu.c | 55 ++++++++++------------------------------------
  fs/ksmbd/vfs.c     | 50 +++++++++--------------------------------
  2 files changed, 21 insertions(+), 84 deletions(-)
fs/ksmbd/smb2pdu.c +2 -29
index afc508c2656d..911c5e97678d 100644
@@ -2661,17 +2661,7 @@ int smb2_open(struct ksmbd_work *work)
  	}
 
  	if (req->CreateOptions & FILE_DELETE_ON_CLOSE_LE) {
-		if (test_share_config_flag(work->tcon->share_conf,
-					   KSMBD_SHARE_FLAG_FOLLOW_SYMLINKS)) {
-			/*
-			 * On delete request, instead of following up, need to
-			 * look the current entity
-			 */
-			rc = ksmbd_vfs_kern_path(name, 0, &path, 1);
-		} else {
-			rc = ksmbd_vfs_kern_path(name, LOOKUP_NO_SYMLINKS, &path, 1);
-		}
-
+		rc = ksmbd_vfs_kern_path(name, LOOKUP_NO_SYMLINKS, &path, 1);
  		if (!rc) {
  			/*
  			 * If file exists with under flags, return access
@@ -2693,24 +2683,11 @@ int smb2_open(struct ksmbd_work *work)
  			}
  		}
  	} else {
-		if (test_share_config_flag(work->tcon->share_conf,
-					   KSMBD_SHARE_FLAG_FOLLOW_SYMLINKS)) {
-			/*
-			 * Use LOOKUP_FOLLOW to follow the path of
-			 * symlink in path buildup
-			 */
-			rc = ksmbd_vfs_kern_path(name, LOOKUP_FOLLOW, &path, 1);
-			if (rc) { /* Case for broken link ?*/
-				rc = ksmbd_vfs_kern_path(name, 0, &path, 1);
-			}
-		} else {
-			rc = ksmbd_vfs_kern_path(name, LOOKUP_NO_SYMLINKS,
-						 &path, 1);
-			if (!rc && d_is_symlink(path.dentry)) {
-				rc = -EACCES;
-				path_put(&path);
-				goto err_out;
-			}
+		rc = ksmbd_vfs_kern_path(name, LOOKUP_NO_SYMLINKS, &path, 1);
Quoted 8 lines

fs/ksmbd/smb2pdu.c int smb2_open(struct ksmbd_work *work) · line 2690

Quoted 4 lines
fs/ksmbd/smb2pdu.c +4 -0
+		if (!rc && d_is_symlink(path.dentry)) {
+			rc = -EACCES;
+			path_put(&path);
+			goto err_out;

why the the check for d_is_symlink()? Wouldn't ksmbd_vfs_kern_path() just return -ELOOP if a path component is a symlink? Hence I guess the below if (rc) where we handle EACCESS should be expanded to handle ELOOP.

ksmbd_vfs_kern_path() doesn't return -ELOOP if last component is a symlink. So need to check it using d_is_symlink().

Quoted 7 lines

I guess I would also refactor the

if (req->CreateOptions & FILE_DELETE_ON_CLOSE_LE)

logic in a previous commit to change the codeflow so there's only one call to ksmbd_vfs_kern_path().

Right. Will do it on v2.

Quoted 11 lines
Quoted 11 lines
fs/ksmbd/smb2pdu.c +0 -1
  		}
  	}
 
@@ -4795,12 +4772,8 @@ static int smb2_get_info_filesystem(struct
 ksmbd_work *work,
  	struct path path;
  	int rc = 0, len;
  	int fs_infoclass_size = 0;
-	int lookup_flags = LOOKUP_NO_SYMLINKS;
 
Quoted 10 lines
Quoted 8 lines
fs/ksmbd/smb2pdu.c +1 -4
-	if (test_share_config_flag(share, KSMBD_SHARE_FLAG_FOLLOW_SYMLINKS))
-		lookup_flags = LOOKUP_FOLLOW;
-
-	rc = ksmbd_vfs_kern_path(share->path, lookup_flags, &path, 0);
+	rc = ksmbd_vfs_kern_path(share->path, LOOKUP_NO_SYMLINKS, &path, 0);
  	if (rc) {
  		pr_err("cannot create vfs path\n");

return -EIO;

why doesn't this return rc?

This is not related with this patch. If needed, we can fix it on another patch. As I remember, To return STATUS_UNEXPECTED_IO_ERROR error?

Quoted 14 lines
Quoted 14 lines
fs/ksmbd/smb2pdu.c +1 -1
@@ -5307,7 +5280,7 @@ static int smb2_rename(struct ksmbd_work *work,
  	char *pathname = NULL;
  	struct path path;
  	bool file_present = true;
-	int rc, lookup_flags = LOOKUP_NO_SYMLINKS;
+	int rc;
 
  	ksmbd_debug(SMB, "setting FILE_RENAME_INFO\n");
  	pathname = kmalloc(PATH_MAX, GFP_KERNEL);
@@ -5376,11 +5349,8 @@ static int smb2_rename(struct ksmbd_work *work,
  		goto out;
  	}
 
Quoted 10 lines

fs/ksmbd/smb2pdu.c static int smb2_rename(struct ksmbd_work *work, · line 5355

Quoted 8 lines
fs/ksmbd/smb2pdu.c +1 -4
-	if (test_share_config_flag(share, KSMBD_SHARE_FLAG_FOLLOW_SYMLINKS))
-		lookup_flags = LOOKUP_FOLLOW;
-
  	ksmbd_debug(SMB, "new name %s\n", new_name);
-	rc = ksmbd_vfs_kern_path(new_name, lookup_flags, &path, 1);
+	rc = ksmbd_vfs_kern_path(new_name, LOOKUP_NO_SYMLINKS, &path, 1);
  	if (rc)
  		file_present = false;

I guess this should handle ELOOP?

I have answered above. ksmbd_vfs_kern_path doesn't return it.

Quoted 17 lines
Quoted 17 lines
fs/ksmbd/smb2pdu.c +1 -1
  	else
@@ -5430,7 +5400,7 @@ static int smb2_create_link(struct ksmbd_work
 *work,
  	char *link_name = NULL, *target_name = NULL, *pathname = NULL;
  	struct path path;
  	bool file_present = true;
-	int rc, lookup_flags = LOOKUP_NO_SYMLINKS;
+	int rc;
 
  	if (buf_len < sizeof(struct smb2_file_link_info) +

le32_to_cpu(file_info->FileNameLength))

fs/ksmbd/smb2pdu.c +0 -0
@@ -5457,11 +5427,8 @@ static int smb2_create_link(struct ksmbd_work
 *work,
  		goto out;
  	}
 
Quoted 10 lines

fs/ksmbd/smb2pdu.c static int smb2_create_link(struct ksmbd_work *work, · line 5433

Quoted 8 lines
fs/ksmbd/smb2pdu.c +1 -4
-	if (test_share_config_flag(share, KSMBD_SHARE_FLAG_FOLLOW_SYMLINKS))
-		lookup_flags = LOOKUP_FOLLOW;
-
  	ksmbd_debug(SMB, "target name is %s\n", target_name);
-	rc = ksmbd_vfs_kern_path(link_name, lookup_flags, &path, 0);
+	rc = ksmbd_vfs_kern_path(link_name, LOOKUP_NO_SYMLINKS, &path, 0);
  	if (rc)
  		file_present = false;

same here?

ditto.

Quoted 3 lines

Other then that: lgtm. Oh, besides, guess this needs an accomanying change to ksmbd-tools?

Yes. It is needed, but I will change ksmbd-tools also after this patch is applied.

Thanks for your review!

Quoted 9 lines

Cheers!
-slow

--
Ralph Boehme, Samba Team https://samba.org/
SerNet Samba Team Lead https://sernet.de/en/team-samba

#3 lore raw

Am 20.09.21 um 17:57 schrieb Namjae Jeon:

Quoted 2 lines

ksmbd_vfs_kern_path() doesn't return -ELOOP if last component is a symlink. So need to check it using d_is_symlink().

Really? I missed that. Is that a behaviour of kern_path() when passing LOOKUP_NO_SYMLINKS? I don't see the behaviour expressed inside ksmbd_vfs_kern_path(), but maybe I'm looking at the wrong branch+patchset?

-slow

Signature · 2 lines
Ralph Boehme, Samba Team                 https://samba.org/
SerNet Samba Team Lead      https://sernet.de/en/team-samba
author maintainer
#4 lore raw

2021-09-21 1:28 GMT+09:00, Ralph Boehme <[email protected]>:

Quoted 6 lines

Am 20.09.21 um 17:57 schrieb Namjae Jeon:

Quoted 2 lines

ksmbd_vfs_kern_path() doesn't return -ELOOP if last component is a symlink. So need to check it using d_is_symlink().

Really? I missed that. Is that a behaviour of kern_path() when passing LOOKUP_NO_SYMLINKS?

Yes.

Quoted 2 lines

I don't see the behaviour expressed inside ksmbd_vfs_kern_path(), but maybe I'm looking at the wrong branch+patchset?

I think that you checked correct branch and patch-set.

Quoted 8 lines

-slow

--
Ralph Boehme, Samba Team https://samba.org/
SerNet Samba Team Lead https://sernet.de/en/team-samba

#5 lore raw

Am 20.09.21 um 18:37 schrieb Namjae Jeon:

Quoted 8 lines

2021-09-21 1:28 GMT+09:00, Ralph Boehme <[email protected]>:

Quoted 6 lines

Am 20.09.21 um 17:57 schrieb Namjae Jeon:

Quoted 2 lines

ksmbd_vfs_kern_path() doesn't return -ELOOP if last component is a symlink. So need to check it using d_is_symlink().

Really? I missed that. Is that a behaviour of kern_path() when passing LOOKUP_NO_SYMLINKS?

Yes.

d'oh! Got it. We're yet to make use of those flags in Samba, so I hadn't really wrapped my head fully around this to understand how it works in detail, so I messed up the semantics a bit. :)

-slow

Signature · 2 lines
Ralph Boehme, Samba Team                 https://samba.org/
SerNet Samba Team Lead      https://sernet.de/en/team-samba
#6 lore raw
In reply to Namjae Jeon

Am 19.09.21 um 04:13 schrieb Namjae Jeon:

Quoted 2 lines

Use LOOKUP_NO_SYMLINKS flags for default lookup to prohibit the middle of symlink component lookup.

maybe this patch should be squashed with the "ksmbd: remove follow symlinks support" patch?

-slow

Signature · 2 lines
Ralph Boehme, Samba Team                 https://samba.org/
SerNet Samba Team Lead      https://sernet.de/en/team-samba
#7 lore raw
Quoted 7 lines · Ralph Boehme

Am 19.09.21 um 04:13 schrieb Namjae Jeon:

Quoted 2 lines

Use LOOKUP_NO_SYMLINKS flags for default lookup to prohibit the middle of symlink component lookup.

maybe this patch should be squashed with the "ksmbd: remove follow symlinks support" patch?

These two could be merged if it makes review easier or less likely to cause merge conflicts later (in this case that may be true since they both touch smb2_open), but that assumes that removing ability to follow all symlinks is agreed upon.

Removing the ability to follow symlinks may be preferable, but I can imagine cases where the admin is exporting only via SMB3 or only read only where symlinks could be of value inside a share and safe (if
remote users can't create symlinks outside the share). I don't have
a strong opinion but also can imagine cases where symlinks could be required (share exported by both nfs and smb3 e.g.) but obviously checked to avoid escaping from the share.

Signature · 3 lines
Thanks,

Steve
#8 lore raw

Am 20.09.21 um 17:19 schrieb Steve French:

Quoted 10 lines · Ralph Boehme
Quoted 5 lines

Am 19.09.21 um 04:13 schrieb Namjae Jeon:

Quoted 1 line

Use LOOKUP_NO_SYMLINKS flags for default lookup to prohibit the middle of symlink component lookup.

maybe this patch should be squashed with the "ksmbd: remove follow symlinks support" patch?

These two could be merged if it makes review easier or less likely to cause merge conflicts later (in this case that may be true since they both touch smb2_open),

from a high level perspective having both patches in the history is at least confusing and should be avoided.

The first patch changes the semantics of "follow symlinks" and the second one then changes it again by basically removing the option, enforcing "never follow symlinks" behaviour.

Quoted 2 lines

but that assumes that removing ability to follow all symlinks is agreed upon.

Well, as discussed you could use LOOKUP_BENEATH. The only downside would be that symlinks with absolute paths are not allowed.

Note that with the current WIP patches we either

a) don't support symlink at all ("follow symlinks = yes")

b) have no protection against follow symlinks outside of a configured share ("follow symlinks = no")

-slow

Signature · 2 lines
Ralph Boehme, Samba Team                 https://samba.org/
SerNet Samba Team Lead      https://sernet.de/en/team-samba
author maintainer
#9 lore raw
In reply to Ralph Boehme

2021-09-20 23:44 GMT+09:00, Ralph Boehme <[email protected]>:

Quoted 6 lines

Am 19.09.21 um 04:13 schrieb Namjae Jeon:

Quoted 2 lines

Use LOOKUP_NO_SYMLINKS flags for default lookup to prohibit the middle of symlink component lookup.

maybe this patch should be squashed with the "ksmbd: remove follow symlinks support" patch?

I think that the subject is slightly different.
1. prohibit the middle of symlinks component on path.
2. remove LOOKUP_FOLLOW and "follow symlink" parameter check.

Thanks!

Quoted 8 lines

-slow

--
Ralph Boehme, Samba Team https://samba.org/
SerNet Samba Team Lead https://sernet.de/en/team-samba