Skip to content

Commit 9f4b9be

Browse files
committed
Merge tag '6.1-rc-ksmbd-fixes' of git://git.samba.org/ksmbd
Pull ksmbd updates from Steve French: - RDMA (smbdirect) fixes - fixes for SMB3.1.1 POSIX Extensions (especially for id mapping) - various casemapping fixes for mount and lookup - UID mapping fixes - fix confusing error message - protocol negotiation fixes, including NTLMSSP fix - two encryption fixes - directory listing fix - some cleanup fixes * tag '6.1-rc-ksmbd-fixes' of git://git.samba.org/ksmbd: (24 commits) ksmbd: validate share name from share config response ksmbd: call ib_drain_qp when disconnected ksmbd: make utf-8 file name comparison work in __caseless_lookup() ksmbd: Fix user namespace mapping ksmbd: hide socket error message when ipv6 config is disable ksmbd: reduce server smbdirect max send/receive segment sizes ksmbd: decrease the number of SMB3 smbdirect server SGEs ksmbd: Fix wrong return value and message length check in smb2_ioctl() ksmbd: set NTLMSSP_NEGOTIATE_SEAL flag to challenge blob ksmbd: fix encryption failure issue for session logoff response ksmbd: fix endless loop when encryption for response fails ksmbd: fill sids in SMB_FIND_FILE_POSIX_INFO response ksmbd: set file permission mode to match Samba server posix extension behavior ksmbd: change security id to the one samba used for posix extension ksmbd: update documentation ksmbd: casefold utf-8 share names and fix ascii lowercase conversion ksmbd: port to vfs{g,u}id_t and associated helpers ksmbd: fix incorrect handling of iterate_dir MAINTAINERS: remove Hyunchul Lee from ksmbd maintainers MAINTAINERS: Add Tom Talpey as ksmbd reviewer ...
2 parents 4c86114 + f5ba1cd commit 9f4b9be

26 files changed

+284
-152
lines changed

Documentation/filesystems/cifs/ksmbd.rst

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -118,26 +118,44 @@ ksmbd/nfsd interoperability Planned for future. The features that ksmbd
118118
How to run
119119
==========
120120

121-
1. Download ksmbd-tools and compile them.
122-
- https://github.com/cifsd-team/ksmbd-tools
121+
1. Download ksmbd-tools(https://github.com/cifsd-team/ksmbd-tools/releases) and
122+
compile them.
123123

124-
2. Create user/password for SMB share.
124+
- Refer README(https://github.com/cifsd-team/ksmbd-tools/blob/master/README.md)
125+
to know how to use ksmbd.mountd/adduser/addshare/control utils
125126

126-
# mkdir /etc/ksmbd/
127-
# ksmbd.adduser -a <Enter USERNAME for SMB share access>
127+
$ ./autogen.sh
128+
$ ./configure --with-rundir=/run
129+
$ make && sudo make install
128130

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
131+
2. Create /usr/local/etc/ksmbd/ksmbd.conf file, add SMB share in ksmbd.conf file.
132132

133-
4. Insert ksmbd.ko module
133+
- Refer ksmbd.conf.example in ksmbd-utils, See ksmbd.conf manpage
134+
for details to configure shares.
134135

135-
# insmod ksmbd.ko
136+
$ man ksmbd.conf
137+
138+
3. Create user/password for SMB share.
139+
140+
- See ksmbd.adduser manpage.
141+
142+
$ man ksmbd.adduser
143+
$ sudo ksmbd.adduser -a <Enter USERNAME for SMB share access>
144+
145+
4. Insert ksmbd.ko module after build your kernel. No need to load module
146+
if ksmbd is built into the kernel.
147+
148+
- Set ksmbd in menuconfig(e.g. $ make menuconfig)
149+
[*] Network File Systems --->
150+
<M> SMB3 server support (EXPERIMENTAL)
151+
152+
$ sudo modprobe ksmbd.ko
136153

137154
5. Start ksmbd user space daemon
138-
# ksmbd.mountd
139155

140-
6. Access share from Windows or Linux using CIFS
156+
$ sudo ksmbd.mountd
157+
158+
6. Access share from Windows or Linux using SMB3 client (cifs.ko or smbclient of samba)
141159

142160
Shutdown KSMBD
143161
==============

MAINTAINERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11101,8 +11101,8 @@ F: tools/testing/selftests/
1110111101
KERNEL SMB3 SERVER (KSMBD)
1110211102
M: Namjae Jeon <[email protected]>
1110311103
M: Steve French <[email protected]>
11104-
M: Hyunchul Lee <[email protected]>
1110511104
R: Sergey Senozhatsky <[email protected]>
11105+
R: Tom Talpey <[email protected]>
1110611106
1110711107
S: Maintained
1110811108
T: git git://git.samba.org/ksmbd.git

fs/ksmbd/auth.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,9 @@ ksmbd_build_ntlmssp_challenge_blob(struct challenge_message *chgblob,
424424
NTLMSSP_NEGOTIATE_56);
425425
}
426426

427+
if (cflags & NTLMSSP_NEGOTIATE_SEAL && smb3_encryption_negotiated(conn))
428+
flags |= NTLMSSP_NEGOTIATE_SEAL;
429+
427430
if (cflags & NTLMSSP_NEGOTIATE_ALWAYS_SIGN)
428431
flags |= NTLMSSP_NEGOTIATE_ALWAYS_SIGN;
429432

@@ -984,13 +987,16 @@ int ksmbd_gen_sd_hash(struct ksmbd_conn *conn, char *sd_buf, int len,
984987
return rc;
985988
}
986989

987-
static int ksmbd_get_encryption_key(struct ksmbd_conn *conn, __u64 ses_id,
990+
static int ksmbd_get_encryption_key(struct ksmbd_work *work, __u64 ses_id,
988991
int enc, u8 *key)
989992
{
990993
struct ksmbd_session *sess;
991994
u8 *ses_enc_key;
992995

993-
sess = ksmbd_session_lookup_all(conn, ses_id);
996+
if (enc)
997+
sess = work->sess;
998+
else
999+
sess = ksmbd_session_lookup_all(work->conn, ses_id);
9941000
if (!sess)
9951001
return -EINVAL;
9961002

@@ -1078,9 +1084,10 @@ static struct scatterlist *ksmbd_init_sg(struct kvec *iov, unsigned int nvec,
10781084
return sg;
10791085
}
10801086

1081-
int ksmbd_crypt_message(struct ksmbd_conn *conn, struct kvec *iov,
1087+
int ksmbd_crypt_message(struct ksmbd_work *work, struct kvec *iov,
10821088
unsigned int nvec, int enc)
10831089
{
1090+
struct ksmbd_conn *conn = work->conn;
10841091
struct smb2_transform_hdr *tr_hdr = smb2_get_msg(iov[0].iov_base);
10851092
unsigned int assoc_data_len = sizeof(struct smb2_transform_hdr) - 20;
10861093
int rc;
@@ -1094,7 +1101,7 @@ int ksmbd_crypt_message(struct ksmbd_conn *conn, struct kvec *iov,
10941101
unsigned int crypt_len = le32_to_cpu(tr_hdr->OriginalMessageSize);
10951102
struct ksmbd_crypto_ctx *ctx;
10961103

1097-
rc = ksmbd_get_encryption_key(conn,
1104+
rc = ksmbd_get_encryption_key(work,
10981105
le64_to_cpu(tr_hdr->SessionId),
10991106
enc,
11001107
key);

fs/ksmbd/auth.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@
3333

3434
struct ksmbd_session;
3535
struct ksmbd_conn;
36+
struct ksmbd_work;
3637
struct kvec;
3738

38-
int ksmbd_crypt_message(struct ksmbd_conn *conn, struct kvec *iov,
39+
int ksmbd_crypt_message(struct ksmbd_work *work, struct kvec *iov,
3940
unsigned int nvec, int enc);
4041
void ksmbd_copy_gss_neg_header(void *buf);
4142
int ksmbd_auth_ntlmv2(struct ksmbd_conn *conn, struct ksmbd_session *sess,

fs/ksmbd/connection.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ struct ksmbd_conn *ksmbd_conn_alloc(void)
6060
conn->local_nls = load_nls("utf8");
6161
if (!conn->local_nls)
6262
conn->local_nls = load_nls_default();
63+
if (IS_ENABLED(CONFIG_UNICODE))
64+
conn->um = utf8_load(UNICODE_AGE(12, 1, 0));
65+
else
66+
conn->um = ERR_PTR(-EOPNOTSUPP);
67+
if (IS_ERR(conn->um))
68+
conn->um = NULL;
6369
atomic_set(&conn->req_running, 0);
6470
atomic_set(&conn->r_count, 0);
6571
conn->total_credits = 1;
@@ -350,6 +356,8 @@ int ksmbd_conn_handler_loop(void *p)
350356
wait_event(conn->r_count_q, atomic_read(&conn->r_count) == 0);
351357

352358

359+
if (IS_ENABLED(CONFIG_UNICODE))
360+
utf8_unload(conn->um);
353361
unload_nls(conn->local_nls);
354362
if (default_conn_ops.terminate_fn)
355363
default_conn_ops.terminate_fn(conn);

fs/ksmbd/connection.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <net/request_sock.h>
1515
#include <linux/kthread.h>
1616
#include <linux/nls.h>
17+
#include <linux/unicode.h>
1718

1819
#include "smb_common.h"
1920
#include "ksmbd_work.h"
@@ -46,6 +47,7 @@ struct ksmbd_conn {
4647
char *request_buf;
4748
struct ksmbd_transport *transport;
4849
struct nls_table *local_nls;
50+
struct unicode_map *um;
4951
struct list_head conns_list;
5052
/* smb session 1 per user */
5153
struct xarray sessions;

fs/ksmbd/ksmbd_netlink.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ struct ksmbd_share_config_response {
163163
__u16 force_directory_mode;
164164
__u16 force_uid;
165165
__u16 force_gid;
166-
__u32 reserved[128]; /* Reserved room */
166+
__s8 share_name[KSMBD_REQ_MAX_SHARE_NAME];
167+
__u32 reserved[112]; /* Reserved room */
167168
__u32 veto_list_sz;
168169
__s8 ____payload[];
169170
};

fs/ksmbd/mgmt/share_config.c

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "user_config.h"
1717
#include "user_session.h"
1818
#include "../transport_ipc.h"
19+
#include "../misc.h"
1920

2021
#define SHARE_HASH_BITS 3
2122
static DEFINE_HASHTABLE(shares_table, SHARE_HASH_BITS);
@@ -26,7 +27,7 @@ struct ksmbd_veto_pattern {
2627
struct list_head list;
2728
};
2829

29-
static unsigned int share_name_hash(char *name)
30+
static unsigned int share_name_hash(const char *name)
3031
{
3132
return jhash(name, strlen(name), 0);
3233
}
@@ -72,7 +73,7 @@ __get_share_config(struct ksmbd_share_config *share)
7273
return share;
7374
}
7475

75-
static struct ksmbd_share_config *__share_lookup(char *name)
76+
static struct ksmbd_share_config *__share_lookup(const char *name)
7677
{
7778
struct ksmbd_share_config *share;
7879
unsigned int key = share_name_hash(name);
@@ -119,7 +120,8 @@ static int parse_veto_list(struct ksmbd_share_config *share,
119120
return 0;
120121
}
121122

122-
static struct ksmbd_share_config *share_config_request(char *name)
123+
static struct ksmbd_share_config *share_config_request(struct unicode_map *um,
124+
const char *name)
123125
{
124126
struct ksmbd_share_config_response *resp;
125127
struct ksmbd_share_config *share = NULL;
@@ -133,6 +135,19 @@ static struct ksmbd_share_config *share_config_request(char *name)
133135
if (resp->flags == KSMBD_SHARE_FLAG_INVALID)
134136
goto out;
135137

138+
if (*resp->share_name) {
139+
char *cf_resp_name;
140+
bool equal;
141+
142+
cf_resp_name = ksmbd_casefold_sharename(um, resp->share_name);
143+
if (IS_ERR(cf_resp_name))
144+
goto out;
145+
equal = !strcmp(cf_resp_name, name);
146+
kfree(cf_resp_name);
147+
if (!equal)
148+
goto out;
149+
}
150+
136151
share = kzalloc(sizeof(struct ksmbd_share_config), GFP_KERNEL);
137152
if (!share)
138153
goto out;
@@ -190,20 +205,11 @@ static struct ksmbd_share_config *share_config_request(char *name)
190205
return share;
191206
}
192207

193-
static void strtolower(char *share_name)
194-
{
195-
while (*share_name) {
196-
*share_name = tolower(*share_name);
197-
share_name++;
198-
}
199-
}
200-
201-
struct ksmbd_share_config *ksmbd_share_config_get(char *name)
208+
struct ksmbd_share_config *ksmbd_share_config_get(struct unicode_map *um,
209+
const char *name)
202210
{
203211
struct ksmbd_share_config *share;
204212

205-
strtolower(name);
206-
207213
down_read(&shares_table_lock);
208214
share = __share_lookup(name);
209215
if (share)
@@ -212,7 +218,7 @@ struct ksmbd_share_config *ksmbd_share_config_get(char *name)
212218

213219
if (share)
214220
return share;
215-
return share_config_request(name);
221+
return share_config_request(um, name);
216222
}
217223

218224
bool ksmbd_share_veto_filename(struct ksmbd_share_config *share,

fs/ksmbd/mgmt/share_config.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <linux/workqueue.h>
1010
#include <linux/hashtable.h>
1111
#include <linux/path.h>
12+
#include <linux/unicode.h>
1213

1314
struct ksmbd_share_config {
1415
char *name;
@@ -74,7 +75,8 @@ static inline void ksmbd_share_config_put(struct ksmbd_share_config *share)
7475
__ksmbd_share_config_put(share);
7576
}
7677

77-
struct ksmbd_share_config *ksmbd_share_config_get(char *name);
78+
struct ksmbd_share_config *ksmbd_share_config_get(struct unicode_map *um,
79+
const char *name);
7880
bool ksmbd_share_veto_filename(struct ksmbd_share_config *share,
7981
const char *filename);
8082
#endif /* __SHARE_CONFIG_MANAGEMENT_H__ */

fs/ksmbd/mgmt/tree_connect.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
struct ksmbd_tree_conn_status
1919
ksmbd_tree_conn_connect(struct ksmbd_conn *conn, struct ksmbd_session *sess,
20-
char *share_name)
20+
const char *share_name)
2121
{
2222
struct ksmbd_tree_conn_status status = {-ENOENT, NULL};
2323
struct ksmbd_tree_connect_response *resp = NULL;
@@ -26,7 +26,7 @@ ksmbd_tree_conn_connect(struct ksmbd_conn *conn, struct ksmbd_session *sess,
2626
struct sockaddr *peer_addr;
2727
int ret;
2828

29-
sc = ksmbd_share_config_get(share_name);
29+
sc = ksmbd_share_config_get(conn->um, share_name);
3030
if (!sc)
3131
return status;
3232

@@ -61,7 +61,7 @@ ksmbd_tree_conn_connect(struct ksmbd_conn *conn, struct ksmbd_session *sess,
6161
struct ksmbd_share_config *new_sc;
6262

6363
ksmbd_share_config_del(sc);
64-
new_sc = ksmbd_share_config_get(share_name);
64+
new_sc = ksmbd_share_config_get(conn->um, share_name);
6565
if (!new_sc) {
6666
pr_err("Failed to update stale share config\n");
6767
status.ret = -ESTALE;

0 commit comments

Comments
 (0)