Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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/f9401718e2be2ab22058b45a6817db912784ef61.camel@rx2.rx-server.de/
Signed-off-by: Philipp Kerling <pkerling@casix.org>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>

authored by

Philipp Kerling and committed by
Steve French
b5ee94ac b320789d

+16 -11
+14 -11
fs/smb/server/smb2pdu.c
··· 2951 2951 } 2952 2952 2953 2953 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 - } 2964 2954 2965 2955 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 + 2966 2967 rc = ksmbd_validate_filename(name); 2967 2968 if (rc < 0) 2968 2969 goto err_out2; ··· 3443 3442 3444 3443 fp->attrib_only = !(req->DesiredAccess & ~(FILE_READ_ATTRIBUTES_LE | 3445 3444 FILE_WRITE_ATTRIBUTES_LE | FILE_SYNCHRONIZE_LE)); 3445 + 3446 + fp->is_posix_ctxt = posix_ctxt; 3446 3447 3447 3448 /* fp should be searchable through ksmbd_inode.m_fp_list 3448 3449 * after daccess, saccess, attrib_only, and stream are ··· 5991 5988 if (IS_ERR(new_name)) 5992 5989 return PTR_ERR(new_name); 5993 5990 5994 - if (strchr(new_name, ':')) { 5991 + if (fp->is_posix_ctxt == false && strchr(new_name, ':')) { 5995 5992 int s_type; 5996 5993 char *xattr_stream_name, *stream_name = NULL; 5997 5994 size_t xattr_stream_size;
+2
fs/smb/server/vfs_cache.h
··· 112 112 bool is_durable; 113 113 bool is_persistent; 114 114 bool is_resilient; 115 + 116 + bool is_posix_ctxt; 115 117 }; 116 118 117 119 static inline void set_ctx_actor(struct dir_context *ctx,