Skip to content

Commit e24c567

Browse files
committed
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 ...
2 parents b91db6a + 7d5d8d7 commit e24c567

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+32254
-2
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
===============================
2+
CIFS
3+
===============================
4+
5+
6+
.. toctree::
7+
:maxdepth: 1
8+
9+
ksmbd
10+
cifsroot
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
.. SPDX-License-Identifier: GPL-2.0
2+
3+
==========================
4+
KSMBD - SMB3 Kernel Server
5+
==========================
6+
7+
KSMBD is a linux kernel server which implements SMB3 protocol in kernel space
8+
for sharing files over network.
9+
10+
KSMBD architecture
11+
==================
12+
13+
The subset of performance related operations belong in kernelspace and
14+
the other subset which belong to operations which are not really related with
15+
performance in userspace. So, DCE/RPC management that has historically resulted
16+
into number of buffer overflow issues and dangerous security bugs and user
17+
account management are implemented in user space as ksmbd.mountd.
18+
File operations that are related with performance (open/read/write/close etc.)
19+
in kernel space (ksmbd). This also allows for easier integration with VFS
20+
interface for all file operations.
21+
22+
ksmbd (kernel daemon)
23+
---------------------
24+
25+
When the server daemon is started, It starts up a forker thread
26+
(ksmbd/interface name) at initialization time and open a dedicated port 445
27+
for listening to SMB requests. Whenever new clients make request, Forker
28+
thread will accept the client connection and fork a new thread for dedicated
29+
communication channel between the client and the server. It allows for parallel
30+
processing of SMB requests(commands) from clients as well as allowing for new
31+
clients to make new connections. Each instance is named ksmbd/1~n(port number)
32+
to indicate connected clients. Depending on the SMB request types, each new
33+
thread can decide to pass through the commands to the user space (ksmbd.mountd),
34+
currently DCE/RPC commands are identified to be handled through the user space.
35+
To further utilize the linux kernel, it has been chosen to process the commands
36+
as workitems and to be executed in the handlers of the ksmbd-io kworker threads.
37+
It allows for multiplexing of the handlers as the kernel take care of initiating
38+
extra worker threads if the load is increased and vice versa, if the load is
39+
decreased it destroys the extra worker threads. So, after connection is
40+
established with client. Dedicated ksmbd/1..n(port number) takes complete
41+
ownership of receiving/parsing of SMB commands. Each received command is worked
42+
in parallel i.e., There can be multiple clients commands which are worked in
43+
parallel. After receiving each command a separated kernel workitem is prepared
44+
for each command which is further queued to be handled by ksmbd-io kworkers.
45+
So, each SMB workitem is queued to the kworkers. This allows the benefit of load
46+
sharing to be managed optimally by the default kernel and optimizing client
47+
performance by handling client commands in parallel.
48+
49+
ksmbd.mountd (user space daemon)
50+
--------------------------------
51+
52+
ksmbd.mountd is userspace process to, transfer user account and password that
53+
are registered using ksmbd.adduser(part of utils for user space). Further it
54+
allows sharing information parameters that parsed from smb.conf to ksmbd in
55+
kernel. For the execution part it has a daemon which is continuously running
56+
and connected to the kernel interface using netlink socket, it waits for the
57+
requests(dcerpc and share/user info). It handles RPC calls (at a minimum few
58+
dozen) that are most important for file server from NetShareEnum and
59+
NetServerGetInfo. Complete DCE/RPC response is prepared from the user space
60+
and passed over to the associated kernel thread for the client.
61+
62+
63+
KSMBD Feature Status
64+
====================
65+
66+
============================== =================================================
67+
Feature name Status
68+
============================== =================================================
69+
Dialects Supported. SMB2.1 SMB3.0, SMB3.1.1 dialects
70+
(intentionally excludes security vulnerable SMB1
71+
dialect).
72+
Auto Negotiation Supported.
73+
Compound Request Supported.
74+
Oplock Cache Mechanism Supported.
75+
SMB2 leases(v1 lease) Supported.
76+
Directory leases(v2 lease) Planned for future.
77+
Multi-credits Supported.
78+
NTLM/NTLMv2 Supported.
79+
HMAC-SHA256 Signing Supported.
80+
Secure negotiate Supported.
81+
Signing Update Supported.
82+
Pre-authentication integrity Supported.
83+
SMB3 encryption(CCM, GCM) Supported. (CCM and GCM128 supported, GCM256 in
84+
progress)
85+
SMB direct(RDMA) Partially Supported. SMB3 Multi-channel is
86+
required to connect to Windows client.
87+
SMB3 Multi-channel Partially Supported. Planned to implement
88+
replay/retry mechanisms for future.
89+
SMB3.1.1 POSIX extension Supported.
90+
ACLs Partially Supported. only DACLs available, SACLs
91+
(auditing) is planned for the future. For
92+
ownership (SIDs) ksmbd generates random subauth
93+
values(then store it to disk) and use uid/gid
94+
get from inode as RID for local domain SID.
95+
The current acl implementation is limited to
96+
standalone server, not a domain member.
97+
Integration with Samba tools is being worked on
98+
to allow future support for running as a domain
99+
member.
100+
Kerberos Supported.
101+
Durable handle v1,v2 Planned for future.
102+
Persistent handle Planned for future.
103+
SMB2 notify Planned for future.
104+
Sparse file support Supported.
105+
DCE/RPC support Partially Supported. a few calls(NetShareEnumAll,
106+
NetServerGetInfo, SAMR, LSARPC) that are needed
107+
for file server handled via netlink interface
108+
from ksmbd.mountd. Additional integration with
109+
Samba tools and libraries via upcall is being
110+
investigated to allow support for additional
111+
DCE/RPC management calls (and future support
112+
for Witness protocol e.g.)
113+
ksmbd/nfsd interoperability Planned for future. The features that ksmbd
114+
support are Leases, Notify, ACLs and Share modes.
115+
============================== =================================================
116+
117+
118+
How to run
119+
==========
120+
121+
1. Download ksmbd-tools and compile them.
122+
- https://github.com/cifsd-team/ksmbd-tools
123+
124+
2. Create user/password for SMB share.
125+
126+
# mkdir /etc/ksmbd/
127+
# ksmbd.adduser -a <Enter USERNAME for SMB share access>
128+
129+
3. Create /etc/ksmbd/smb.conf file, add SMB share in smb.conf file
130+
- Refer smb.conf.example and
131+
https://github.com/cifsd-team/ksmbd-tools/blob/master/Documentation/configuration.txt
132+
133+
4. Insert ksmbd.ko module
134+
135+
# insmod ksmbd.ko
136+
137+
5. Start ksmbd user space daemon
138+
# ksmbd.mountd
139+
140+
6. Access share from Windows or Linux using CIFS
141+
142+
Shutdown KSMBD
143+
==============
144+
145+
1. kill user and kernel space daemon
146+
# sudo ksmbd.control -s
147+
148+
How to turn debug print on
149+
==========================
150+
151+
Each layer
152+
/sys/class/ksmbd-control/debug
153+
154+
1. Enable all component prints
155+
# sudo ksmbd.control -d "all"
156+
157+
2. Enable one of components(smb, auth, vfs, oplock, ipc, conn, rdma)
158+
# sudo ksmbd.control -d "smb"
159+
160+
3. Show what prints are enable.
161+
# cat/sys/class/ksmbd-control/debug
162+
[smb] auth vfs oplock ipc conn [rdma]
163+
164+
4. Disable prints:
165+
If you try the selected component once more, It is disabled without brackets.

Documentation/filesystems/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Documentation for filesystem implementations.
7272
befs
7373
bfs
7474
btrfs
75-
cifs/cifsroot
75+
cifs/index
7676
ceph
7777
coda
7878
configfs

MAINTAINERS

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4620,7 +4620,7 @@ F: include/linux/clk/
46204620
F: include/linux/of_clk.h
46214621
X: drivers/clk/clkdev.c
46224622

4623-
COMMON INTERNET FILE SYSTEM (CIFS)
4623+
COMMON INTERNET FILE SYSTEM CLIENT (CIFS)
46244624
M: Steve French <[email protected]>
46254625
46264626
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
1011310113
F: Documentation/dev-tools/kselftest*
1011410114
F: tools/testing/selftests/
1011510115

10116+
KERNEL SMB3 SERVER (KSMBD)
10117+
M: Namjae Jeon <[email protected]>
10118+
M: Sergey Senozhatsky <[email protected]>
10119+
M: Steve French <[email protected]>
10120+
M: Hyunchul Lee <[email protected]>
10121+
10122+
S: Maintained
10123+
T: git git://git.samba.org/ksmbd.git
10124+
F: fs/cifs_common/
10125+
F: fs/ksmbd/
10126+
1011610127
KERNEL UNIT TESTING FRAMEWORK (KUnit)
1011710128
M: Brendan Higgins <[email protected]>
1011810129

fs/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ config NFS_V4_2_SSC_HELPER
349349
source "net/sunrpc/Kconfig"
350350
source "fs/ceph/Kconfig"
351351
source "fs/cifs/Kconfig"
352+
source "fs/ksmbd/Kconfig"
352353
source "fs/coda/Kconfig"
353354
source "fs/afs/Kconfig"
354355
source "fs/9p/Kconfig"

fs/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ obj-$(CONFIG_NLS) += nls/
9797
obj-$(CONFIG_UNICODE) += unicode/
9898
obj-$(CONFIG_SYSV_FS) += sysv/
9999
obj-$(CONFIG_CIFS) += cifs/
100+
obj-$(CONFIG_SMB_SERVER) += ksmbd/
100101
obj-$(CONFIG_HPFS_FS) += hpfs/
101102
obj-$(CONFIG_NTFS_FS) += ntfs/
102103
obj-$(CONFIG_UFS_FS) += ufs/

fs/ksmbd/Kconfig

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
config SMB_SERVER
2+
tristate "SMB3 server support (EXPERIMENTAL)"
3+
depends on INET
4+
depends on MULTIUSER
5+
depends on FILE_LOCKING
6+
select NLS
7+
select NLS_UTF8
8+
select CRYPTO
9+
select CRYPTO_MD4
10+
select CRYPTO_MD5
11+
select CRYPTO_HMAC
12+
select CRYPTO_ECB
13+
select CRYPTO_LIB_DES
14+
select CRYPTO_SHA256
15+
select CRYPTO_CMAC
16+
select CRYPTO_SHA512
17+
select CRYPTO_AEAD2
18+
select CRYPTO_CCM
19+
select CRYPTO_GCM
20+
select ASN1
21+
select OID_REGISTRY
22+
default n
23+
help
24+
Choose Y here if you want to allow SMB3 compliant clients
25+
to access files residing on this system using SMB3 protocol.
26+
To compile the SMB3 server support as a module,
27+
choose M here: the module will be called ksmbd.
28+
29+
You may choose to use a samba server instead, in which
30+
case you can choose N here.
31+
32+
You also need to install user space programs which can be found
33+
in ksmbd-tools, available from
34+
https://github.com/cifsd-team/ksmbd-tools.
35+
More detail about how to run the ksmbd kernel server is
36+
available via README file
37+
(https://github.com/cifsd-team/ksmbd-tools/blob/master/README).
38+
39+
ksmbd kernel server includes support for auto-negotiation,
40+
Secure negotiate, Pre-authentication integrity, oplock/lease,
41+
compound requests, multi-credit, packet signing, RDMA(smbdirect),
42+
smb3 encryption, copy-offload, secure per-user session
43+
establishment via NTLM or NTLMv2.
44+
45+
config SMB_SERVER_SMBDIRECT
46+
bool "Support for SMB Direct protocol"
47+
depends on SMB_SERVER=m && INFINIBAND && INFINIBAND_ADDR_TRANS || SMB_SERVER=y && INFINIBAND=y && INFINIBAND_ADDR_TRANS=y
48+
select SG_POOL
49+
default n
50+
51+
help
52+
Enables SMB Direct support for SMB 3.0, 3.02 and 3.1.1.
53+
54+
SMB Direct allows transferring SMB packets over RDMA. If unsure,
55+
say N.
56+
57+
config SMB_SERVER_CHECK_CAP_NET_ADMIN
58+
bool "Enable check network administration capability"
59+
depends on SMB_SERVER
60+
default y
61+
62+
help
63+
Prevent unprivileged processes to start the ksmbd kernel server.
64+
65+
config SMB_SERVER_KERBEROS5
66+
bool "Support for Kerberos 5"
67+
depends on SMB_SERVER
68+
default n

fs/ksmbd/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# SPDX-License-Identifier: GPL-2.0-or-later
2+
#
3+
# Makefile for Linux SMB3 kernel server
4+
#
5+
obj-$(CONFIG_SMB_SERVER) += ksmbd.o
6+
7+
ksmbd-y := unicode.o auth.o vfs.o vfs_cache.o server.o ndr.o \
8+
misc.o oplock.o connection.o ksmbd_work.o crypto_ctx.o \
9+
mgmt/ksmbd_ida.o mgmt/user_config.o mgmt/share_config.o \
10+
mgmt/tree_connect.o mgmt/user_session.o smb_common.o \
11+
transport_tcp.o transport_ipc.o smbacl.o smb2pdu.o \
12+
smb2ops.o smb2misc.o ksmbd_spnego_negtokeninit.asn1.o \
13+
ksmbd_spnego_negtokentarg.asn1.o asn1.o
14+
15+
$(obj)/asn1.o: $(obj)/ksmbd_spnego_negtokeninit.asn1.h $(obj)/ksmbd_spnego_negtokentarg.asn1.h
16+
17+
$(obj)/ksmbd_spnego_negtokeninit.asn1.o: $(obj)/ksmbd_spnego_negtokeninit.asn1.c $(obj)/ksmbd_spnego_negtokeninit.asn1.h
18+
$(obj)/ksmbd_spnego_negtokentarg.asn1.o: $(obj)/ksmbd_spnego_negtokentarg.asn1.c $(obj)/ksmbd_spnego_negtokentarg.asn1.h
19+
20+
ksmbd-$(CONFIG_SMB_SERVER_SMBDIRECT) += transport_rdma.o

0 commit comments

Comments
 (0)