Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
cifsd: introduce SMB3 kernel server
Introduce cifsd kernel server which implements SMB3 protocol in kernel space for sharing files over network. Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com> Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Signed-off-by: Hyunchul Lee <hyc.lee@gmail.com> Acked-by: Ronnie Sahlberg <lsahlber@redhat.com> Signed-off-by: Steve French <stfrench@microsoft.com>
- Loading branch information
1 parent
4877846
commit 1962fa7df128499a7a17c381204023e5c8c11d21
Showing
64 changed files
with
31,195 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,141 @@ | ||
| .. SPDX-License-Identifier: GPL-2.0 | ||
| ========================== | ||
| CIFSD - SMB3 Kernel Server | ||
| ========================== | ||
|
|
||
| CIFSD is a linux kernel server which implements SMB3 protocol in kernel space | ||
| for sharing files over network. | ||
|
|
||
| CIFSD architecture | ||
| ================== | ||
|
|
||
| The subset of performance related operations belong in kernelspace and | ||
| the other subset which belong to operations which are not really related with | ||
| performance in userspace. So, DCE/RPC management that has historically resulted | ||
| into number of buffer overflow issues and dangerous security bugs and user | ||
| account management are implemented in user space as ksmbd.mountd. | ||
| File operations that are related with performance (open/read/write/close etc.) | ||
| in kernel space (ksmbd). This also allows for easier integration with VFS | ||
| interface for all file operations. | ||
|
|
||
| ksmbd (kernel daemon) | ||
| --------------------- | ||
|
|
||
| When the server daemon is started, It starts up a forker thread | ||
| (ksmbd/interface name) at initialization time and open a dedicated port 445 | ||
| for listening to SMB requests. Whenever new clients make request, Forker | ||
| thread will accept the client connection and fork a new thread for dedicated | ||
| communication channel between the client and the server. It allows for parallel | ||
| processing of SMB requests(commands) from clients as well as allowing for new | ||
| clients to make new connections. Each instance is named ksmbd/1~n(port number) | ||
| to indicate connected clients. Depending on the SMB request types, each new | ||
| thread can decide to pass through the commands to the user space (ksmbd.mountd), | ||
| currently DCE/RPC commands are identified to be handled through the user space. | ||
| To further utilize the linux kernel, it has been chosen to process the commands | ||
| as workitems and to be executed in the handlers of the ksmbd-io kworker threads. | ||
| It allows for multiplexing of the handlers as the kernel take care of initiating | ||
| extra worker threads if the load is increased and vice versa, if the load is | ||
| decreased it destroys the extra worker threads. So, after connection is | ||
| established with client. Dedicated ksmbd/1..n(port number) takes complete | ||
| ownership of receiving/parsing of SMB commands. Each received command is worked | ||
| in parallel i.e., There can be multiple clients commands which are worked in | ||
| parallel. After receiving each command a separated kernel workitem is prepared | ||
| for each command which is further queued to be handled by ksmbd-io kworkers. | ||
| So, each SMB workitem is queued to the kworkers. This allows the benefit of load | ||
| sharing to be managed optimally by the default kernel and optimizing client | ||
| performance by handling client commands in parallel. | ||
|
|
||
| ksmbd.mountd (user space daemon) | ||
| -------------------------------- | ||
|
|
||
| ksmbd.mountd is userspace process to, transfer user account and password that | ||
| are registered using ksmbd.adduser(part of utils for user space). Further it | ||
| allows sharing information parameters that parsed from smb.conf to ksmbd in | ||
| kernel. For the execution part it has a daemon which is continuously running | ||
| and connected to the kernel interface using netlink socket, it waits for the | ||
| requests(dcerpc and share/user info). It handles RPC calls (at a minimum few | ||
| dozen) that are most important for file server from NetShareEnum and | ||
| NetServerGetInfo. Complete DCE/RPC response is prepared from the user space | ||
| and passed over to the associated kernel thread for the client. | ||
|
|
||
| Key Features | ||
| ============ | ||
|
|
||
| The supported features are: | ||
| * SMB3 protocols for basic file sharing | ||
| * Auto negotiation | ||
| * Compound requests | ||
| * Oplock/Lease | ||
| * Large MTU | ||
| * NTLM/NTLMv2 | ||
| * HMAC-SHA256 Signing | ||
| * Secure negotiate | ||
| * Signing Update | ||
| * Pre-authentication integrity(SMB 3.1.1) | ||
| * SMB3 encryption(CCM, GCM) | ||
| * SMB direct(RDMA) | ||
| * The part of POSIX extension support (posix context, modebit) | ||
|
|
||
| The features that are planned or not supported: | ||
| * SMB3 Multi-channel | ||
| * Durable handle v1,v2 | ||
| * Kerberos | ||
| * Persistent handles | ||
| * Directory lease | ||
| * WinAcl | ||
| * POSIX extension support | ||
| * SMB2 notify | ||
|
|
||
| How to run | ||
| ========== | ||
|
|
||
| 1. Download cifsd-tools and compile them. | ||
| - https://github.com/cifsd-team/cifsd-tools | ||
|
|
||
| 2. Create user/password for SMB share. | ||
|
|
||
| # mkdir /etc/ksmbd/ | ||
| # ksmbd.adduser -a <Enter USERNAME for SMB share access> | ||
|
|
||
| 3. Create /etc/ksmbd/smb.conf file, add SMB share in smb.conf file | ||
| - Refer smb.conf.example and Documentation/configuration.txt | ||
| in cifsd-tools | ||
|
|
||
| 4. Insert ksmbd.ko module | ||
|
|
||
| # insmod ksmbd.ko | ||
|
|
||
| 5. Start ksmbd user space daemon | ||
| # ksmbd.mountd | ||
|
|
||
| 6. Access share from Windows or Linux using CIFS | ||
|
|
||
| Shutdown CIFSD | ||
| ============== | ||
|
|
||
| 1. kill user space daemon | ||
| # killall ksmbd.mountd | ||
|
|
||
| 2. kill kernel space daemon | ||
| # echo hard > /sys/class/ksmbd-control/kill_server | ||
|
|
||
|
|
||
| How to turn debug print on | ||
| ========================== | ||
|
|
||
| Each layer | ||
| /sys/class/ksmbd-control/debug | ||
|
|
||
| 1. Enable SMB related debug print | ||
| # echo "smb" > /sys/class/ksmbd-control/debug | ||
|
|
||
| 2. Enable RDMA related print. | ||
| echo "rdma" > /sys/class/ksmbd-control/debug | ||
|
|
||
| 3. Show what prints are enable. | ||
| # cat/sys/class/ksmbd-control/debug | ||
| [smb] auth vfs oplock ipc conn [rdma] | ||
|
|
||
| 4. If you want to turn all prints on, Do echo "all". | ||
| # echo "all" > /sys/class/ksmbd-control/debug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| config SMB_SERVER | ||
| tristate "SMB server support (EXPERIMENTAL)" | ||
| depends on INET | ||
| select NLS | ||
| select NLS_UTF8 | ||
| select CRYPTO | ||
| select CRYPTO_MD4 | ||
| select CRYPTO_MD5 | ||
| select CRYPTO_HMAC | ||
| select CRYPTO_ARC4 | ||
| select CRYPTO_ECB | ||
| select CRYPTO_LIB_DES | ||
| select CRYPTO_SHA256 | ||
| select CRYPTO_CMAC | ||
| select CRYPTO_SHA512 | ||
| select CRYPTO_AEAD2 | ||
| select CRYPTO_CCM | ||
| select CRYPTO_GCM | ||
| default n | ||
| help | ||
| Choose Y here if you want to allow SMB3 compliant clients | ||
| to access files residing on this system using SMB3 protocol. | ||
| To compile the SMB3 server support as a module, | ||
| choose M here: the module will be called ksmbd. | ||
|
|
||
| You may choose to use a samba server instead, in which | ||
| case you can choose N here. | ||
|
|
||
| You also need to install user space programs which can be found | ||
| in cifsd-tools, available from | ||
| https://github.com/cifsd-team/cifsd-tools. | ||
| More detail about how to run the cifsd kernel server is | ||
| available via README file | ||
| (https://github.com/cifsd-team/cifsd-tools/blob/master/README). | ||
|
|
||
| cifsd kernel server includes support for auto-negotiation, | ||
| Secure negotiate, Pre-authentication integrity, oplock/lease, | ||
| compound requests, multi-credit, packet signing, RDMA(smbdirect), | ||
| smb3 encryption, copy-offload, secure per-user session | ||
| establishment via NTLM or NTLMv2. | ||
|
|
||
| config SMB_SERVER_SMBDIRECT | ||
| bool "Support for SMB Direct protocol" | ||
| depends on SMB_SERVER=m && INFINIBAND && INFINIBAND_ADDR_TRANS || SMB_SERVER=y && INFINIBAND=y && INFINIBAND_ADDR_TRANS=y | ||
| default n | ||
|
|
||
| help | ||
| Enables SMB Direct support for SMB 3.0, 3.02 and 3.1.1. | ||
|
|
||
| SMB Direct allows transferring SMB packets over RDMA. If unsure, | ||
| say N. | ||
|
|
||
| config SMB_SERVER_CHECK_CAP_NET_ADMIN | ||
| bool "Enable check network administration capability" | ||
| depends on SMB_SERVER | ||
| default n | ||
|
|
||
| help | ||
| Prevent unprivileged processes to start the cifsd kernel server. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # SPDX-License-Identifier: GPL-2.0-or-later | ||
| # | ||
| # Makefile for Linux SMB3 kernel server | ||
| # | ||
| obj-$(CONFIG_SMB_SERVER) += ksmbd.o | ||
|
|
||
| ksmbd-y := unicode.o auth.o vfs.o vfs_cache.o server.o buffer_pool.o \ | ||
| misc.o oplock.o connection.o ksmbd_work.o crypto_ctx.o \ | ||
| mgmt/ksmbd_ida.o mgmt/user_config.o mgmt/share_config.o \ | ||
| mgmt/tree_connect.o mgmt/user_session.o smb_common.o \ | ||
| transport_tcp.o transport_ipc.o smbacl.o smb2pdu.o \ | ||
| smb2ops.o smb2misc.o asn1.o netmisc.o | ||
| ksmbd-$(CONFIG_SMB_SERVER_SMBDIRECT) += transport_rdma.o |
Oops, something went wrong.