forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge tag '5.15-rc-first-ksmbd-merge' of git://git.samba.org/ksmbd
Pull initial ksmbd implementation from Steve French: "Initial merge of kernel smb3 file server, ksmbd. The SMB family of protocols is the most widely deployed network filesystem protocol, the default on Windows and Macs (and even on many phones and tablets), with clients and servers on all major operating systems, but lacked a kernel server for Linux. For many cases the current userspace server choices were suboptimal either due to memory footprint, performance or difficulty integrating well with advanced Linux features. ksmbd is a new kernel module which implements the server-side of the SMB3 protocol. The target is to provide optimized performance, GPLv2 SMB server, and better lease handling (distributed caching). The bigger goal is to add new features more rapidly (e.g. RDMA aka "smbdirect", and recent encryption and signing improvements to the protocol) which are easier to develop on a smaller, more tightly optimized kernel server than for example in Samba. The Samba project is much broader in scope (tools, security services, LDAP, Active Directory Domain Controller, and a cross platform file server for a wider variety of purposes) but the user space file server portion of Samba has proved hard to optimize for some Linux workloads, including for smaller devices. This is not meant to replace Samba, but rather be an extension to allow better optimizing for Linux, and will continue to integrate well with Samba user space tools and libraries where appropriate. Working with the Samba team we have already made sure that the configuration files and xattrs are in a compatible format between the kernel and user space server. Various types of functional and regression tests are regularly run against it. One example is the automated 'buildbot' regression tests which use the Linux client to test against ksmbd, e.g. http://smb3-test-rhel-75.southcentralus.cloudapp.azure.com/#/builders/8/builds/56 but other test suites, including Samba's smbtorture functional test suite are also used regularly" * tag '5.15-rc-first-ksmbd-merge' of git://git.samba.org/ksmbd: (219 commits) ksmbd: fix __write_overflow warning in ndr_read_string MAINTAINERS: ksmbd: add cifs_common directory to ksmbd entry MAINTAINERS: ksmbd: update my email address ksmbd: fix permission check issue on chown and chmod ksmbd: don't set FILE DELETE and FILE_DELETE_CHILD in access mask by default MAINTAINERS: add git adddress of ksmbd ksmbd: update SMB3 multi-channel support in ksmbd.rst ksmbd: smbd: fix kernel oops during server shutdown ksmbd: remove select FS_POSIX_ACL in Kconfig ksmbd: use proper errno instead of -1 in smb2_get_ksmbd_tcon() ksmbd: update the comment for smb2_get_ksmbd_tcon() ksmbd: change int data type to boolean ksmbd: Fix multi-protocol negotiation ksmbd: fix an oops in error handling in smb2_open() ksmbd: add ipv6_addr_v4mapped check to know if connection from client is ipv4 ksmbd: fix missing error code in smb2_lock ksmbd: use channel signingkey for binding SMB2 session setup ksmbd: don't set RSS capable in FSCTL_QUERY_NETWORK_INTERFACE_INFO ksmbd: Return STATUS_OBJECT_PATH_NOT_FOUND if smb2_creat() returns ENOENT ksmbd: fix -Wstringop-truncation warnings ...
- Loading branch information
Showing
66 changed files
with
32,254 additions
and
2 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,10 @@ | ||
=============================== | ||
CIFS | ||
=============================== | ||
|
||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
|
||
ksmbd | ||
cifsroot |
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,165 @@ | ||
.. SPDX-License-Identifier: GPL-2.0 | ||
========================== | ||
KSMBD - SMB3 Kernel Server | ||
========================== | ||
|
||
KSMBD is a linux kernel server which implements SMB3 protocol in kernel space | ||
for sharing files over network. | ||
|
||
KSMBD 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. | ||
|
||
|
||
KSMBD Feature Status | ||
==================== | ||
|
||
============================== ================================================= | ||
Feature name Status | ||
============================== ================================================= | ||
Dialects Supported. SMB2.1 SMB3.0, SMB3.1.1 dialects | ||
(intentionally excludes security vulnerable SMB1 | ||
dialect). | ||
Auto Negotiation Supported. | ||
Compound Request Supported. | ||
Oplock Cache Mechanism Supported. | ||
SMB2 leases(v1 lease) Supported. | ||
Directory leases(v2 lease) Planned for future. | ||
Multi-credits Supported. | ||
NTLM/NTLMv2 Supported. | ||
HMAC-SHA256 Signing Supported. | ||
Secure negotiate Supported. | ||
Signing Update Supported. | ||
Pre-authentication integrity Supported. | ||
SMB3 encryption(CCM, GCM) Supported. (CCM and GCM128 supported, GCM256 in | ||
progress) | ||
SMB direct(RDMA) Partially Supported. SMB3 Multi-channel is | ||
required to connect to Windows client. | ||
SMB3 Multi-channel Partially Supported. Planned to implement | ||
replay/retry mechanisms for future. | ||
SMB3.1.1 POSIX extension Supported. | ||
ACLs Partially Supported. only DACLs available, SACLs | ||
(auditing) is planned for the future. For | ||
ownership (SIDs) ksmbd generates random subauth | ||
values(then store it to disk) and use uid/gid | ||
get from inode as RID for local domain SID. | ||
The current acl implementation is limited to | ||
standalone server, not a domain member. | ||
Integration with Samba tools is being worked on | ||
to allow future support for running as a domain | ||
member. | ||
Kerberos Supported. | ||
Durable handle v1,v2 Planned for future. | ||
Persistent handle Planned for future. | ||
SMB2 notify Planned for future. | ||
Sparse file support Supported. | ||
DCE/RPC support Partially Supported. a few calls(NetShareEnumAll, | ||
NetServerGetInfo, SAMR, LSARPC) that are needed | ||
for file server handled via netlink interface | ||
from ksmbd.mountd. Additional integration with | ||
Samba tools and libraries via upcall is being | ||
investigated to allow support for additional | ||
DCE/RPC management calls (and future support | ||
for Witness protocol e.g.) | ||
ksmbd/nfsd interoperability Planned for future. The features that ksmbd | ||
support are Leases, Notify, ACLs and Share modes. | ||
============================== ================================================= | ||
|
||
|
||
How to run | ||
========== | ||
|
||
1. Download ksmbd-tools and compile them. | ||
- https://github.com/cifsd-team/ksmbd-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 | ||
https://github.com/cifsd-team/ksmbd-tools/blob/master/Documentation/configuration.txt | ||
|
||
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 KSMBD | ||
============== | ||
|
||
1. kill user and kernel space daemon | ||
# sudo ksmbd.control -s | ||
|
||
How to turn debug print on | ||
========================== | ||
|
||
Each layer | ||
/sys/class/ksmbd-control/debug | ||
|
||
1. Enable all component prints | ||
# sudo ksmbd.control -d "all" | ||
|
||
2. Enable one of components(smb, auth, vfs, oplock, ipc, conn, rdma) | ||
# sudo ksmbd.control -d "smb" | ||
|
||
3. Show what prints are enable. | ||
# cat/sys/class/ksmbd-control/debug | ||
[smb] auth vfs oplock ipc conn [rdma] | ||
|
||
4. Disable prints: | ||
If you try the selected component once more, It is disabled without brackets. |
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 |
---|---|---|
|
@@ -4620,7 +4620,7 @@ F: include/linux/clk/ | |
F: include/linux/of_clk.h | ||
X: drivers/clk/clkdev.c | ||
|
||
COMMON INTERNET FILE SYSTEM (CIFS) | ||
COMMON INTERNET FILE SYSTEM CLIENT (CIFS) | ||
M: Steve French <[email protected]> | ||
L: [email protected] | ||
L: [email protected] (moderated for non-subscribers) | ||
|
@@ -10113,6 +10113,17 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git | |
F: Documentation/dev-tools/kselftest* | ||
F: tools/testing/selftests/ | ||
|
||
KERNEL SMB3 SERVER (KSMBD) | ||
M: Namjae Jeon <[email protected]> | ||
M: Sergey Senozhatsky <[email protected]> | ||
M: Steve French <[email protected]> | ||
M: Hyunchul Lee <[email protected]> | ||
L: [email protected] | ||
S: Maintained | ||
T: git git://git.samba.org/ksmbd.git | ||
F: fs/cifs_common/ | ||
F: fs/ksmbd/ | ||
|
||
KERNEL UNIT TESTING FRAMEWORK (KUnit) | ||
M: Brendan Higgins <[email protected]> | ||
L: [email protected] | ||
|
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,68 @@ | ||
config SMB_SERVER | ||
tristate "SMB3 server support (EXPERIMENTAL)" | ||
depends on INET | ||
depends on MULTIUSER | ||
depends on FILE_LOCKING | ||
select NLS | ||
select NLS_UTF8 | ||
select CRYPTO | ||
select CRYPTO_MD4 | ||
select CRYPTO_MD5 | ||
select CRYPTO_HMAC | ||
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 | ||
select ASN1 | ||
select OID_REGISTRY | ||
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 ksmbd-tools, available from | ||
https://github.com/cifsd-team/ksmbd-tools. | ||
More detail about how to run the ksmbd kernel server is | ||
available via README file | ||
(https://github.com/cifsd-team/ksmbd-tools/blob/master/README). | ||
|
||
ksmbd 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 | ||
select SG_POOL | ||
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 y | ||
|
||
help | ||
Prevent unprivileged processes to start the ksmbd kernel server. | ||
|
||
config SMB_SERVER_KERBEROS5 | ||
bool "Support for Kerberos 5" | ||
depends on SMB_SERVER | ||
default n |
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,20 @@ | ||
# 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 ndr.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 ksmbd_spnego_negtokeninit.asn1.o \ | ||
ksmbd_spnego_negtokentarg.asn1.o asn1.o | ||
|
||
$(obj)/asn1.o: $(obj)/ksmbd_spnego_negtokeninit.asn1.h $(obj)/ksmbd_spnego_negtokentarg.asn1.h | ||
|
||
$(obj)/ksmbd_spnego_negtokeninit.asn1.o: $(obj)/ksmbd_spnego_negtokeninit.asn1.c $(obj)/ksmbd_spnego_negtokeninit.asn1.h | ||
$(obj)/ksmbd_spnego_negtokentarg.asn1.o: $(obj)/ksmbd_spnego_negtokentarg.asn1.c $(obj)/ksmbd_spnego_negtokentarg.asn1.h | ||
|
||
ksmbd-$(CONFIG_SMB_SERVER_SMBDIRECT) += transport_rdma.o |
Oops, something went wrong.