smb: implement SMB over QUIC
Subsystems (2)
v2 cover smb: implement SMB over QUIC
Hi,
This series introduces SMB over QUIC for cifs.ko and ksmbd.ko.
I'm sending this early for review as this work was rebased on top of metze's recent transport and smbdirect changes -- at least some of it, as well as on top of lxin's QUIC branch, and depends on these branches being merged upstream.
The branch for this series is available at:
https://gitlab.com/hacr/linux/-/tree/smb-quic-v1
Changes in v2: nothing, I just sent the patches in wrong order in v1.
Henrique Carvalho (11):
smb: common: add smb_tls struct shared by client and server
smb: client: refactor negotiate context assembly
smb: client: prepare connect path for QUIC transport
smb: client: add QUIC mount and transport setup
smb: server: split interface management from TCP in preparation for
QUIC
smb: server: add shared transport helpers in preparation for QUIC
smb: server: reuse common transport helpers in TCP transport
smb: server: add QUIC transport support
smb: server: refactor TCP transport definitions
smb: server: track TCP and QUIC listener state independently
docs: smb: document SMB3 over QUIC setup for cifs.ko and ksmbd.ko
Documentation/filesystems/smb/index.rst | 1 + Documentation/filesystems/smb/ksmbd.rst | 2 +- Documentation/filesystems/smb/quic.rst | 332 +++++++++++++++ fs/smb/client/cifsglob.h | 19 +- fs/smb/client/connect.c | 234 ++++++++++- fs/smb/client/fs_context.c | 37 ++ fs/smb/client/fs_context.h | 4 + fs/smb/client/smb2pdu.c | 133 +++--- fs/smb/client/transport.c | 40 +- fs/smb/common/smbglob.h | 12 + fs/smb/server/Makefile | 3 +- fs/smb/server/connection.c | 11 +- fs/smb/server/connection.h | 10 +- fs/smb/server/interface.c | 235 +++++++++++ fs/smb/server/interface.h | 36 ++ fs/smb/server/mgmt/tree_connect.c | 2 +- fs/smb/server/server.h | 1 + fs/smb/server/smb2pdu.c | 1 + fs/smb/server/transport.c | 344 ++++++++++++++++ fs/smb/server/transport.h | 40 ++ fs/smb/server/transport_ipc.c | 3 +- fs/smb/server/transport_quic.c | 327 +++++++++++++++ fs/smb/server/transport_quic.h | 20 + fs/smb/server/transport_tcp.c | 526 ++---------------------- fs/smb/server/transport_tcp.h | 10 +- 25 files changed, 1785 insertions(+), 598 deletions(-) create mode 100644 Documentation/filesystems/smb/quic.rst create mode 100644 fs/smb/server/interface.c create mode 100644 fs/smb/server/interface.h create mode 100644 fs/smb/server/transport.c create mode 100644 fs/smb/server/transport.h create mode 100644 fs/smb/server/transport_quic.c create mode 100644 fs/smb/server/transport_quic.h
Signature · 1 line
2.53.0
PATCH v2 1/11 smb: common: add smb_tls struct shared by client and server
Both the SMB client (mount path) and ksmbd server (accept path) need to drive a TLS handshake over their accepted/connected QUIC socket via the kernel handshake API.
Pull the small bit of state shared between the two callers - the completion, status and peerid populated by the handshake callback, and the tls_handshake_args structure passed to tls_{client,server}_hello_x509() - into one common header in fs/smb/common/smbglob.h.
Define SMB_TLS_TIMEOUT_MS (3000) here as well so client and server agree on the handshake timeout.
--- fs/smb/common/smbglob.h | 12 ++++++++++++ 1 file changed, 12 insertions(+)
fs/smb/common/smbglob.h +12 -0
@@ -11,6 +11,9 @@ #ifndef _COMMON_SMB_GLOB_H #define _COMMON_SMB_GLOB_H +#include <net/sock.h> +#include <net/handshake.h> + struct smb_version_values { char *version_string; __u16 protocol_id;
@@ -66,4 +69,13 @@ static inline void inc_rfc1001_len(void *buf, int count)#define MAX_CIFS_SMALL_BUFFER_SIZE 448/* big enough for most */ +struct smb_tls { +struct completion handshake_done; +int status; +key_serial_t peerid; +struct tls_handshake_args args; +}; + +#define SMB_TLS_TIMEOUT_MS 3000 +#endif /* _COMMON_SMB_GLOB_H */
Signature · 1 line
2.53.0
PATCH v2 2/11 smb: client: refactor negotiate context assembly
In reply to Henrique CarvalhoIntroduce struct neg_ctx, smb2_neg_context_len() and add_context() to handle alignment, pointer advancement, and counter increment in one place, eliminating repetitive code.
Also fix missing ALIGN() for posix negotiate context.
--- fs/smb/client/smb2pdu.c | 106 +++++++++++++++++++++------------------- 1 file changed, 56 insertions(+), 50 deletions(-)
fs/smb/client/smb2pdu.c +56 -50
@@ -618,7 +618,15 @@ static int smb2_ioctl_req_init(u32 opcode, struct cifs_tcon *tcon,/* For explanation of negotiate contexts see MS-SMB2 section 2.2.3.1 */ -static void +static inline unsigned int +smb2_neg_context_len (const void *p) +{ +const struct smb2_neg_context *ctx = p; + +return sizeof (*ctx) +le16_to_cpu (ctx->DataLength); +} + +static unsigned int build_preauth_ctxt (struct smb2_preauth_neg_context *pneg_ctxt) { pneg_ctxt->ContextType =SMB2_PREAUTH_INTEGRITY_CAPABILITIES ;
@@ -627,9 +635,10 @@ build_preauth_ctxt(struct smb2_preauth_neg_context *pneg_ctxt) pneg_ctxt->SaltLength =cpu_to_le16 (SMB311_SALT_SIZE );get_random_bytes (pneg_ctxt->Salt,SMB311_SALT_SIZE ); pneg_ctxt->HashAlgorithms =SMB2_PREAUTH_INTEGRITY_SHA512 ; +return smb2_neg_context_len (pneg_ctxt); } -static void +static unsigned int build_compression_ctxt (struct smb2_compression_capabilities_context *pneg_ctxt) { pneg_ctxt->ContextType =SMB2_COMPRESSION_CAPABILITIES ;
@@ -640,13 +649,13 @@ build_compression_ctxt(struct smb2_compression_capabilities_context *pneg_ctxt) pneg_ctxt->CompressionAlgorithms[0 ] =SMB3_COMPRESS_LZ77 ; pneg_ctxt->CompressionAlgorithms[1 ] =SMB3_COMPRESS_LZ77_HUFF ; pneg_ctxt->CompressionAlgorithms[2 ] =SMB3_COMPRESS_LZNT1 ; +return smb2_neg_context_len (pneg_ctxt); }static unsigned int build_signing_ctxt (struct smb2_signing_capabilities *pneg_ctxt) { -unsigned int ctxt_len =sizeof (struct smb2_signing_capabilities ); -unsigned short num_algs =1 ;/* number of signing algorithms sent */ +const unsigned short num_algs =1 ;/* number of signing algorithms sent */ pneg_ctxt->ContextType =SMB2_SIGNING_CAPABILITIES ;/*
@@ -658,13 +667,11 @@ build_signing_ctxt(struct smb2_signing_capabilities *pneg_ctxt) pneg_ctxt->SigningAlgorithmCount =cpu_to_le16 (num_algs); pneg_ctxt->SigningAlgorithms[0 ] =cpu_to_le16 (SIGNING_ALG_AES_CMAC ); - ctxt_len +=sizeof (__le16) * num_algs; - ctxt_len =ALIGN (ctxt_len,8 ); -return ctxt_len; +return smb2_neg_context_len (pneg_ctxt);/* TBD add SIGNING_ALG_AES_GMAC and/or SIGNING_ALG_HMAC_SHA256 */ } -static void +static unsigned int build_encrypt_ctxt (struct smb2_encryption_neg_context *pneg_ctxt) { pneg_ctxt->ContextType =SMB2_ENCRYPTION_CAPABILITIES ;
@@ -684,6 +691,7 @@ build_encrypt_ctxt(struct smb2_encryption_neg_context *pneg_ctxt) pneg_ctxt->Ciphers[0 ] =SMB2_ENCRYPTION_AES128_GCM ; pneg_ctxt->Ciphers[1 ] =SMB2_ENCRYPTION_AES128_CCM ; } +return smb2_neg_context_len (pneg_ctxt); } static unsigned int
@@ -695,11 +703,11 @@ build_netname_ctxt(struct smb2_netname_neg_context *pneg_ctxt, char *hostname)/* copy up to max of first 100 bytes of server name to NetName field */ pneg_ctxt->DataLength =cpu_to_le16 (2 *cifs_strtoUTF16 (pneg_ctxt->NetName, hostname,100 , cp)); -/* context size is DataLength + minimal smb2_neg_context */ -return ALIGN (le16_to_cpu (pneg_ctxt->DataLength) +sizeof (struct smb2_neg_context ),8 ); + +return smb2_neg_context_len (pneg_ctxt); } -static void +static unsigned int build_posix_ctxt (struct smb2_posix_neg_context *pneg_ctxt) { pneg_ctxt->ContextType =SMB2_POSIX_EXTENSIONS_AVAILABLE ;
@@ -721,15 +729,31 @@ build_posix_ctxt(struct smb2_posix_neg_context *pneg_ctxt) pneg_ctxt->Name[13 ] =0x8B ; pneg_ctxt->Name[14 ] =0xCD ; pneg_ctxt->Name[15 ] =0x7C ; +return smb2_neg_context_len (pneg_ctxt); +} + +struct neg_ctx { +char *pos; +unsigned int len; +unsigned int cnt; +}; + +static inline void +add_context (struct neg_ctx *nc,unsigned int ctx_len) +{ +unsigned int aligned_len =ALIGN (ctx_len,8 ); + + nc->pos += aligned_len; + nc->len += aligned_len; + nc->cnt++; }static void assemble_neg_contexts (struct smb2_negotiate_req *req,struct TCP_Server_Info *server,unsigned int *total_len) { -unsigned int ctxt_len, neg_context_count; +struct neg_ctx nc;struct TCP_Server_Info *pserver; -char *pneg_ctxt;char *hostname;if (*total_len >200 ) {
@@ -744,18 +768,15 @@ assemble_neg_contexts(struct smb2_negotiate_req *req,*/ *total_len =ALIGN (*total_len,8 ); - pneg_ctxt = (*total_len) + (char *)req; req->NegotiateContextOffset =cpu_to_le32 (*total_len); -build_preauth_ctxt ((struct smb2_preauth_neg_context *)pneg_ctxt); - ctxt_len =ALIGN (sizeof (struct smb2_preauth_neg_context ),8 ); - *total_len += ctxt_len; - pneg_ctxt += ctxt_len; + nc.pos = (*total_len) + (char *)req; + nc.len = *total_len; + nc.cnt =0 ; + +add_context (&nc,build_preauth_ctxt ((struct smb2_preauth_neg_context *)nc.pos)); -build_encrypt_ctxt ((struct smb2_encryption_neg_context *)pneg_ctxt); - ctxt_len =ALIGN (sizeof (struct smb2_encryption_neg_context ),8 ); - *total_len += ctxt_len; - pneg_ctxt += ctxt_len; +add_context (&nc,build_encrypt_ctxt ((struct smb2_encryption_neg_context *)nc.pos));/* * secondary channels don't have the hostname field populated
@@ -764,41 +785,26 @@ assemble_neg_contexts(struct smb2_negotiate_req *req, pserver =SERVER_IS_CHAN (server) ? server->primary_server : server;cifs_server_lock (pserver); hostname = pserver->hostname; -if (hostname && (hostname[0 ] !=0 )) { - ctxt_len =build_netname_ctxt ((struct smb2_netname_neg_context *)pneg_ctxt, - hostname); - *total_len += ctxt_len; - pneg_ctxt += ctxt_len; - neg_context_count =3 ; - }else - neg_context_count =2 ; +if (hostname && (hostname[0 ] !=0 )) +add_context (&nc, +build_netname_ctxt ((struct smb2_netname_neg_context *)nc.pos, + hostname));cifs_server_unlock (pserver); -build_posix_ctxt ((struct smb2_posix_neg_context *)pneg_ctxt); - *total_len +=sizeof (struct smb2_posix_neg_context ); - pneg_ctxt +=sizeof (struct smb2_posix_neg_context ); - neg_context_count++; +add_context (&nc,build_posix_ctxt ((struct smb2_posix_neg_context *)nc.pos)); -if (server->compression.requested) { -build_compression_ctxt ((struct smb2_compression_capabilities_context *) - pneg_ctxt); - ctxt_len =ALIGN (sizeof (struct smb2_compression_capabilities_context ),8 ); - *total_len += ctxt_len; - pneg_ctxt += ctxt_len; - neg_context_count++; - } +if (server->compression.requested) +add_context (&nc, +build_compression_ctxt ( + (struct smb2_compression_capabilities_context *)nc.pos)); -if (enable_negotiate_signing) { - ctxt_len =build_signing_ctxt ((struct smb2_signing_capabilities *) - pneg_ctxt); - *total_len += ctxt_len; - pneg_ctxt += ctxt_len; - neg_context_count++; - } +if (enable_negotiate_signing) +add_context (&nc,build_signing_ctxt ((struct smb2_signing_capabilities *)nc.pos));/* check for and add transport_capabilities and signing capabilities */ - req->NegotiateContextCount =cpu_to_le16 (neg_context_count); + req->NegotiateContextCount =cpu_to_le16 (nc.cnt); + *total_len = nc.len; }/* If invalid preauth context warn but use what we requested, SHA-512 */
Signature · 1 line
2.53.0
PATCH v2 3/11 smb: client: prepare connect path for QUIC transport
In reply to Henrique CarvalhoRefactor the connect path to ease introducing QUIC as an alternative transport alongside TCP and RDMA.
No functional change intended.
--- fs/smb/client/connect.c | 56 ++++++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 17 deletions(-)
fs/smb/client/connect.c +39 -17
@@ -62,11 +62,18 @@ static int ip_connect(struct TCP_Server_Info *server);static int generic_ip_connect (struct TCP_Server_Info *server);static void tlink_rb_insert (struct rb_root *root,struct tcon_link *new_tlink);static void cifs_prune_tlinks (struct work_struct *work); +static void smb_sock_release (struct TCP_Server_Info *server);static struct mchan_mount *mchan_mount_alloc (struct cifs_ses *ses);static void mchan_mount_free (struct mchan_mount *mchan_mount);static void mchan_mount_work_fn (struct work_struct *work); +static void smb_sock_release (struct TCP_Server_Info *server) +{ +sock_release (server->ssocket); + server->ssocket =NULL ; +} +/* * Resolve hostname and set ip addr in tcp ses. Useful for hostnames that may * get their ip addresses changed at some point.
@@ -311,8 +318,7 @@ cifs_abort_connection(struct TCP_Server_Info *server)kernel_sock_shutdown (server->ssocket,SHUT_WR );cifs_dbg (FYI ,"Post shutdown state: 0x%x Flags: 0x%lx\n" , server->ssocket->state, server->ssocket->flags); -sock_release (server->ssocket); - server->ssocket =NULL ; +smb_sock_release (server); } server->sequence_number =0 ; server->session_estab = false;
@@ -1077,10 +1083,8 @@ clean_demultiplex_info(struct TCP_Server_Info *server)wake_up_all (&server->request_q);/* give those requests time to exit */ msleep (125 ); -if (server->ssocket) { -sock_release (server->ssocket); - server->ssocket =NULL ; - } + +smb_sock_release (server);if (!list_empty (&server->pending_mid_q)) {struct mid_q_entry *mid_entry;
@@ -1778,7 +1782,11 @@ cifs_get_tcp_session(struct smb3_fs_context *ctx, tcp_ses->noblocksnd = ctx->noblocksnd || ctx->rootfs; tcp_ses->noautotune = ctx->noautotune; tcp_ses->tcp_nodelay = ctx->sockopt_tcp_nodelay; - tcp_ses->ipproto = ctx->rdma ?IPPROTO_SMBDIRECT :IPPROTO_TCP ; +if (ctx->rdma) + tcp_ses->ipproto =IPPROTO_SMBDIRECT ; +else + tcp_ses->ipproto =IPPROTO_TCP ; + tcp_ses->in_flight =0 ; tcp_ses->max_in_flight =0 ; tcp_ses->credits =1 ;
@@ -1895,8 +1903,7 @@ cifs_get_tcp_session(struct smb3_fs_context *ctx,cifs_put_tcp_session (tcp_ses->primary_server, false);kfree (tcp_ses->hostname);kfree (tcp_ses->leaf_fullpath); -if (tcp_ses->ssocket) -sock_release (tcp_ses->ssocket); +smb_sock_release (tcp_ses);kfree (tcp_ses); }return ERR_PTR (rc);
@@ -3297,13 +3304,29 @@ ip_rfc1001_connect(struct TCP_Server_Info *server)return 0 ; } +static inline const char * +get_protocol_name (struct TCP_Server_Info *server) +{ +switch (server->ipproto) { +case IPPROTO_TCP : +return "tcp" ; +case IPPROTO_QUIC : +return "quic" ; +case IPPROTO_SMBDIRECT : +return "smbdirect" ; +default : +cifs_dbg (VFS ,"Unknown ipproto value: %d" , server->ipproto); +return "unknown" ; + } +} +static int generic_ip_connect (struct TCP_Server_Info *server) {struct sockaddr *saddr;struct socket *socket;int slen, sfamily; -const char *pname =cifs_rdma_enabled (server) ?"smbdirect" :"tcp" ; +const char *pname =get_protocol_name (server);__be16 sport;int rc =0 ;
@@ -3327,10 +3350,7 @@ generic_ip_connect(struct TCP_Server_Info *server) __func__, pname, &ipv4->sin_addr, ntohs(sport)); } -if (server->ssocket) { -sock_release (server->ssocket); - server->ssocket =NULL ; - } +smb_sock_release (server); {struct net *net =cifs_net_ns (server);
@@ -3383,7 +3403,7 @@ generic_ip_connect(struct TCP_Server_Info *server)if (server->tcp_nodelay)tcp_sock_set_nodelay (socket->sk); -if (server->ipproto ==IPPROTO_SMBDIRECT ) { +if (cifs_rdma_enabled (server)) { rc =smbd_prepare_socket (server,ntohs (sport));if (rc <0 ) { cifs_dbg(FYI, "Error %d from smbd_prepare_socket(port=%u)\n",
@@ -3431,8 +3451,7 @@ generic_ip_connect(struct TCP_Server_Info *server) close_socket:trace_smb3_connect_err (server->hostname, server->conn_id, &server->dstaddr, rc); -sock_release (socket); - server->ssocket =NULL ; +smb_sock_release (server);return rc; }
@@ -3465,6 +3484,9 @@ ip_connect(struct TCP_Server_Info *server)if (rc >=0 )return rc; +if (!port2) +return rc; +/* if it failed, try with port2 */ *sport =htons (port2); }
Signature · 1 line
2.53.0
PATCH v2 4/11 smb: client: add QUIC mount and transport setup
In reply to Henrique CarvalhoIntroduce new mount options used to drive SMB over QUIC: quic and mtls. Introduce per-server state needed to drive the QUIC transport. Introduce transport functions for smb quic tls handshake setup and initial quic transport setup. Include SMB2_TRANSPORT_CAPABILITIES negotiate context for QUIC.
--- fs/smb/client/cifsglob.h | 19 +++- fs/smb/client/connect.c | 184 +++++++++++++++++++++++++++++++++++-- fs/smb/client/fs_context.c | 37 ++++++++ fs/smb/client/fs_context.h | 4 + fs/smb/client/smb2pdu.c | 27 ++++++ fs/smb/client/transport.c | 40 ++++---- 6 files changed, 284 insertions(+), 27 deletions(-)
fs/smb/client/cifsglob.h +18 -1
@@ -35,6 +35,7 @@#define CIFS_PORT 445#define RFC1001_PORT 139#define SMBD_IWARP_PORT 5445 +#define SMB_QUIC_PORT 443/* * The sizes of various internal tables and strings
@@ -759,8 +760,10 @@ struct TCP_Server_Info {bool sec_mskerberos;/* supports legacy MS Kerberos */ bool sec_iakerb;/* supports pass-through auth for Kerberos (krb5 proxy) */ bool large_buf;/* is current buffer large? */ -int ipproto;/* IPPROTO_TCP or IPOROTO_SMBDIRECT */ +int ipproto;/* IPPROTO_TCP, IPOROTO_SMBDIRECT or IPPROTO_QUIC */ #define cifs_rdma_enabled (__server) ((__server)->ipproto == IPPROTO_SMBDIRECT) +/* point to the SMBD connection if RDMA is used instead of socket */ +struct smbd_connection *smbd_conn;struct delayed_work echo;/* echo ping workqueue job */ char *smallbuf;/* pointer to current "small" buffer */ char *bigbuf;/* pointer to current "big" buffer */
@@ -832,6 +835,14 @@ struct TCP_Server_Info {char *leaf_fullpath; bool dfs_conn:1;char dns_dom[CIFS_MAX_DOMAINNAME_LEN +1 ]; + +struct { +bool need_smb_seal;/* if unset, smb encryption is disabled over QUIC +* transport, and QUIC security (i.e. TLS 1.3) is +* the one used +*/ +bool mtls; + } quic_conn; };static inline bool is_smb1 (const struct TCP_Server_Info *server)
@@ -855,6 +866,12 @@ static inline void cifs_server_unlock(struct TCP_Server_Info *server)memalloc_nofs_restore (nofs_flag); } +static inline bool +cifs_quic_enabled (struct TCP_Server_Info *server) +{ +return server->ipproto ==IPPROTO_QUIC ; +} +struct cifs_credits {unsigned int value;unsigned int instance;
fs/smb/client/connect.c +176 -8
254 lines not on this page · raw message
fs/smb/client/fs_context.c +37 -0
@@ -127,6 +127,7 @@ const struct fs_parameter_spec smb3_fs_parameters[] = {fsparam_flag ("nosparse" , Opt_nosparse),fsparam_flag ("domainauto" , Opt_domainauto),fsparam_flag ("rdma" , Opt_rdma), +fsparam_flag ("quic" , Opt_quic),fsparam_flag ("modesid" , Opt_modesid),fsparam_flag ("modefromsid" , Opt_modesid), fsparam_flag("rootfs", Opt_rootfs),
@@ -135,6 +136,7 @@ const struct fs_parameter_spec smb3_fs_parameters[] = {fsparam_flag_no ("nativesocket" , Opt_nativesocket),fsparam_flag_no ("unicode" , Opt_unicode),fsparam_flag_no ("nbsessinit" , Opt_nbsessinit), +fsparam_flag ("mtls" , Opt_mtls),/* Mount options which take uid or gid */ fsparam_uid("backupuid", Opt_backupuid),
@@ -840,6 +842,30 @@ static int smb3_fs_context_validate(struct fs_context *fc)return -EOPNOTSUPP ; } +if (ctx->rdma && ctx->quic) { +pr_warn_once ("SMB Direct and QUIC transport are mutually exclusive. Default to rdma\n" ); + ctx->quic = false; + } + +if (ctx->quic && !ctx->got_version) { +pr_warn_once ("No dialect specified on mount, but 'quic' implies a minimum dialect of SMB3.1.1. Default has changed to SMB3.1.1\n" ); + ctx->ops = &smb311_operations; + ctx->vals = &smb311_values; + ctx->got_version = true; + } + +if (ctx->quic) { +if (!IS_ENABLED (CONFIG_IP_QUIC )) { +cifs_errorf (fc,"SMB over QUIC requires CONFIG_IP_QUIC to be enabled\n" ); +return -EOPNOTSUPP ; + } + } + +if (ctx->quic && ctx->vals->protocol_id <SMB311_PROT_ID ) { +cifs_errorf (fc,"SMB over QUIC requires Version >=3.1.1\n" ); +return -EOPNOTSUPP ; + } +#ifndef CONFIG_KEYS /* Muliuser mounts require CONFIG_KEYS support */ if (ctx->multiuser) {
@@ -1011,6 +1037,10 @@ static int smb3_verify_reconfigure_ctx(struct fs_context *fc,cifs_errorf (fc,"can not change nbsessinit during remount\n" );return -EINVAL ; } +if (new_ctx->quic != old_ctx->quic) { +cifs_errorf (fc,"can not change quic transport during remount\n" ); +return -EINVAL ; + }return 0 ; }
@@ -1871,6 +1901,9 @@ static int smb3_fs_context_parse_param(struct fs_context *fc,case Opt_rdma: ctx->rdma = true;break ; +case Opt_quic: + ctx->quic = true; +break ;case Opt_reparse:if (parse_reparse_flavor (fc, param->string, ctx)) goto cifs_parse_mount_err;
@@ -1896,7 +1929,11 @@ static int smb3_fs_context_parse_param(struct fs_context *fc, ctx->symlinkroot = param->string; param->string =NULL ;break ; +case Opt_mtls: + ctx->mtls = true; +break ; } +/* case Opt_ignore: - is ignored as expected ... */ if (ctx->multiuser && ctx->upcall_target ==UPTARGET_MOUNT ) {
fs/smb/client/fs_context.h +4 -0
@@ -143,6 +143,7 @@ enum cifs_param { Opt_tcp_nodelay, Opt_domainauto, Opt_rdma, + Opt_quic, Opt_modesid, Opt_rootfs, Opt_multichannel,
@@ -199,6 +200,7 @@ enum cifs_param { Opt_nativesocket, Opt_symlink, Opt_symlinkroot, + Opt_mtls,/* Mount options to be ignored */ Opt_ignore,
@@ -293,6 +295,8 @@ struct smb3_fs_context { bool resilient:1; /* noresilient not required since not fored for CA */ bool domainauto:1; bool rdma:1; + bool quic:1; + bool mtls:1; bool multichannel:1; bool multichannel_specified:1; /* true if user specified multichannel or nomultichannel */ bool max_channels_specified:1; /* true if user specified max_channels */
fs/smb/client/smb2pdu.c +27 -0
@@ -732,6 +732,16 @@ build_posix_ctxt(struct smb2_posix_neg_context *pneg_ctxt)return smb2_neg_context_len (pneg_ctxt); } +static unsigned int +build_transport_ctxt (struct smb2_transport_capabilities_context *pneg_ctxt) +{ + pneg_ctxt->ContextType =SMB2_TRANSPORT_CAPABILITIES ; + pneg_ctxt->DataLength =cpu_to_le16 (sizeof (struct smb2_transport_capabilities_context ) - +sizeof (struct smb2_neg_context )); + pneg_ctxt->Flags =cpu_to_le32 (SMB2_ACCEPT_TRANSPORT_LEVEL_SECURITY ); +return smb2_neg_context_len (pneg_ctxt); +} +struct neg_ctx {char *pos;unsigned int len;
@@ -801,6 +811,11 @@ assemble_neg_contexts(struct smb2_negotiate_req *req,if (enable_negotiate_signing)add_context (&nc,build_signing_ctxt ((struct smb2_signing_capabilities *)nc.pos)); +if (cifs_quic_enabled (server) && server->quic_conn.need_smb_seal) +add_context (&nc, +build_transport_ctxt ( + (struct smb2_transport_capabilities_context *)nc.pos)); +/* check for and add transport_capabilities and signing capabilities */ req->NegotiateContextCount =cpu_to_le16 (nc.cnt);
@@ -945,6 +960,15 @@ static void decode_signing_ctx(struct TCP_Server_Info *server, server->signing_algorithm); } +static void +decode_transport_ctx (struct TCP_Server_Info *server, +struct smb2_transport_capabilities_context *pctxt) +{ +if (pctxt->Flags ==cpu_to_le32 (SMB2_ACCEPT_TRANSPORT_LEVEL_SECURITY )) + server->quic_conn.need_smb_seal = false; +else + server->quic_conn.need_smb_seal = true; +} static int smb311_decode_neg_context(struct smb2_negotiate_rsp *rsp, struct TCP_Server_Info *server,
@@ -997,6 +1021,9 @@ static int smb311_decode_neg_context(struct smb2_negotiate_rsp *rsp,else if (pctx->ContextType ==SMB2_SIGNING_CAPABILITIES )decode_signing_ctx (server, (struct smb2_signing_capabilities *)pctx); +else if (pctx->ContextType ==SMB2_TRANSPORT_CAPABILITIES ) +decode_transport_ctx (server, + (struct smb2_transport_capabilities_context *)pctx);else cifs_server_dbg (VFS ,"unknown negcontext of type %d ignored\n" ,le16_to_cpu (pctx->ContextType));
fs/smb/client/transport.c +22 -18
@@ -23,6 +23,7 @@#include <linux/sched/signal.h> #include <linux/task_io_accounting_ops.h> #include <linux/task_work.h> +#include <linux/quic.h> #include "cifsglob.h" #include "cifsproto.h" #include "cifs_debug.h"
@@ -148,10 +149,12 @@ smb_send_kvec(struct TCP_Server_Info *server, struct msghdr *smb_msg, *sent =0 ; -if (server->noblocksnd) - smb_msg->msg_flags =MSG_DONTWAIT +MSG_NOSIGNAL ; -else - smb_msg->msg_flags =MSG_NOSIGNAL ; +if (cifs_quic_enabled (server)) { +if (server->noblocksnd) + smb_msg->msg_flags =MSG_DONTWAIT +MSG_NOSIGNAL ; +else + smb_msg->msg_flags =MSG_NOSIGNAL ; + }while (msg_data_left (smb_msg)) {/*
@@ -270,7 +273,8 @@ int __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst, rc =0 ;/* cork the socket */ -tcp_sock_set_cork (ssocket->sk, true); +if (!cifs_quic_enabled (server)) +tcp_sock_set_cork (ssocket->sk, true);for (j =0 ; j < num_rqst; j++) send_length +=smb_rqst_len (server, &rqst[j]);
@@ -287,19 +291,17 @@ int __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,sigprocmask (SIG_BLOCK , &mask, &oldmask);/* Generate a rfc1002 marker */ - { -struct kvec hiov = { - .iov_base = &rfc1002_marker, - .iov_len =4 - }; -iov_iter_kvec (&smb_msg.msg_iter,ITER_SOURCE , &hiov,1 ,4 ); - rc =smb_send_kvec (server, &smb_msg, &sent); -if (rc <0 ) - goto unmask; +struct kvec hiov = { + .iov_base = &rfc1002_marker, + .iov_len =4 + }; +iov_iter_kvec (&smb_msg.msg_iter,ITER_SOURCE , &hiov,1 ,4 ); + rc =smb_send_kvec (server, &smb_msg, &sent); +if (rc <0 ) + goto unmask; - total_len += sent; - send_length +=4 ; - } + total_len += sent; + send_length +=4 ;cifs_dbg (FYI ,"Sending smb: smb_len=%u\n" , send_length);
@@ -350,7 +352,9 @@ int __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst, }/* uncork it */ -tcp_sock_set_cork (ssocket->sk, false); + +if (!cifs_quic_enabled (server)) +tcp_sock_set_cork (ssocket->sk, false);if ((total_len >0 ) && (total_len != send_length)) { cifs_dbg(FYI, "partial send (wanted=%u sent=%zu): terminating session\n",
Signature · 1 line
2.53.0