Skip to content

Commit b5ee94a

Browse files
pkerlingsmfrench
authored andcommitted
ksmbd: allow a filename to contain colons on SMB3.1.1 posix extensions
If the client sends SMB2_CREATE_POSIX_CONTEXT to ksmbd, allow the filename to contain a colon (':'). This requires disabling the support for Alternate Data Streams (ADS), which are denoted by a colon-separated suffix to the filename on Windows. This should not be an issue, since this concept is not known to POSIX anyway and the client has to explicitly request a POSIX context to get this behavior. Link: https://lore.kernel.org/all/[email protected]/ Signed-off-by: Philipp Kerling <[email protected]> Acked-by: Namjae Jeon <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent b320789 commit b5ee94a

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

fs/smb/server/smb2pdu.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2951,18 +2951,19 @@ int smb2_open(struct ksmbd_work *work)
29512951
}
29522952

29532953
ksmbd_debug(SMB, "converted name = %s\n", name);
2954-
if (strchr(name, ':')) {
2955-
if (!test_share_config_flag(work->tcon->share_conf,
2956-
KSMBD_SHARE_FLAG_STREAMS)) {
2957-
rc = -EBADF;
2958-
goto err_out2;
2959-
}
2960-
rc = parse_stream_name(name, &stream_name, &s_type);
2961-
if (rc < 0)
2962-
goto err_out2;
2963-
}
29642954

29652955
if (posix_ctxt == false) {
2956+
if (strchr(name, ':')) {
2957+
if (!test_share_config_flag(work->tcon->share_conf,
2958+
KSMBD_SHARE_FLAG_STREAMS)) {
2959+
rc = -EBADF;
2960+
goto err_out2;
2961+
}
2962+
rc = parse_stream_name(name, &stream_name, &s_type);
2963+
if (rc < 0)
2964+
goto err_out2;
2965+
}
2966+
29662967
rc = ksmbd_validate_filename(name);
29672968
if (rc < 0)
29682969
goto err_out2;
@@ -3443,6 +3444,8 @@ int smb2_open(struct ksmbd_work *work)
34433444
fp->attrib_only = !(req->DesiredAccess & ~(FILE_READ_ATTRIBUTES_LE |
34443445
FILE_WRITE_ATTRIBUTES_LE | FILE_SYNCHRONIZE_LE));
34453446

3447+
fp->is_posix_ctxt = posix_ctxt;
3448+
34463449
/* fp should be searchable through ksmbd_inode.m_fp_list
34473450
* after daccess, saccess, attrib_only, and stream are
34483451
* initialized.
@@ -5988,7 +5991,7 @@ static int smb2_rename(struct ksmbd_work *work,
59885991
if (IS_ERR(new_name))
59895992
return PTR_ERR(new_name);
59905993

5991-
if (strchr(new_name, ':')) {
5994+
if (fp->is_posix_ctxt == false && strchr(new_name, ':')) {
59925995
int s_type;
59935996
char *xattr_stream_name, *stream_name = NULL;
59945997
size_t xattr_stream_size;

fs/smb/server/vfs_cache.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ struct ksmbd_file {
112112
bool is_durable;
113113
bool is_persistent;
114114
bool is_resilient;
115+
116+
bool is_posix_ctxt;
115117
};
116118

117119
static inline void set_ctx_actor(struct dir_context *ctx,

0 commit comments

Comments
 (0)