* [PATCH] ksmbd: return the cause of a failed link
@ 2026-11-28 1:39 Ian Bridges
2026-11-28 2:27 ` Namjae Jeon
0 siblings, 1 reply; 2+ messages in thread
From: Ian Bridges @ 2026-11-28 1:39 UTC (permalink / raw)
To: linkinjeon
Cc: senozhatsky, tom, chenxiaosong, linux-cifs, linux-kernel, Ian Bridges
smb2_create_link() turns every error of the link, and of the removal of
a target that the link replaces, into -EINVAL. A link that fails
because the caller cannot write the directory therefore returns
STATUS_INVALID_PARAMETER. Return the errors as they are, as
smb2_rename() does, so that smb2_set_info() maps them in the same way
as the errors of a rename.
Signed-off-by: Ian Bridges <icb@fastmail.org>
---
Tested on ksmbd-for-next 4543a3349127 with KASAN. A link into a
directory that the caller cannot write now fails with
STATUS_ACCESS_DENIED instead of STATUS_INVALID_PARAMETER. On a Linux
cifs mount, ln into such a directory now reports "Permission denied".
Before, it reported "Operation not supported". A link into a writable
directory still succeeds. smbtorture gives the same results as on the
base.
This patch was developed with LLM assistance.
fs/smb/server/smb2pdu.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index 38326db8da40..9504c2e35819 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -8953,11 +8953,9 @@ static int smb2_create_link(struct ksmbd_work *work,
} else {
if (file_info->ReplaceIfExists) {
rc = ksmbd_vfs_remove_file(work, &path);
- if (rc) {
- rc = -EINVAL;
+ if (rc)
ksmbd_debug(SMB, "cannot delete %s\n",
link_name);
- }
} else {
rc = -EEXIST;
ksmbd_debug(SMB, "link already exists\n");
@@ -8967,8 +8965,6 @@ static int smb2_create_link(struct ksmbd_work *work,
goto out;
}
rc = ksmbd_vfs_link(work, target_name, link_name);
- if (rc)
- rc = -EINVAL;
out:
if (!IS_ERR(link_name))
base-commit: 4543a3349127baa8395397b7f4aa930d9a4f8dd5
--
2.47.3
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] ksmbd: return the cause of a failed link
2026-11-28 1:39 [PATCH] ksmbd: return the cause of a failed link Ian Bridges
@ 2026-11-28 2:27 ` Namjae Jeon
0 siblings, 0 replies; 2+ messages in thread
From: Namjae Jeon @ 2026-11-28 2:27 UTC (permalink / raw)
To: Ian Bridges; +Cc: senozhatsky, tom, chenxiaosong, linux-cifs, linux-kernel
> @@ -8967,8 +8965,6 @@ static int smb2_create_link(struct ksmbd_work *work,
> goto out;
> }
> rc = ksmbd_vfs_link(work, target_name, link_name);
> - if (rc)
> - rc = -EINVAL;
When smb2_create_link() passes through errors from the backing
filesystem, smb2_set_info() needs to map them to the appropriate
NTSTATUS values for FileLinkInformation. For example, vfs_link()
returns -EPERM when the filesystem has no ->link operation, as on
exFAT. With this patch, ksmbd returns STATUS_ACCESS_DENIED. The
expected status is STATUS_NOT_SUPPORTED. Also, -EMLINK should map to
STATUS_TOO_MANY_LINKS. We should check the NTSTATUS mappings for the
other errors this patch propagates as well...
Thanks.
> out:
>
> if (!IS_ERR(link_name))
>
> base-commit: 4543a3349127baa8395397b7f4aa930d9a4f8dd5
> --
> 2.47.3
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-28 2:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-28 1:39 [PATCH] ksmbd: return the cause of a failed link Ian Bridges
2026-11-28 2:27 ` Namjae Jeon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®