Skip to content

Commit 59f3fd3

Browse files
committed
Merge tag '6.6-rc4-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6
Pull smb client fixes from Steve French: - protect cifs/smb3 socket connect from BPF address overwrite - fix case when directory leases disabled but wasting resources with unneeded thread on each mount * tag '6.6-rc4-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6: smb: client: do not start laundromat thread on nohandlecache smb: use kernel_connect() and kernel_bind()
2 parents 102363a + 3b8bb31 commit 59f3fd3

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

fs/smb/client/connect.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2474,8 +2474,9 @@ cifs_put_tcon(struct cifs_tcon *tcon)
24742474
static struct cifs_tcon *
24752475
cifs_get_tcon(struct cifs_ses *ses, struct smb3_fs_context *ctx)
24762476
{
2477-
int rc, xid;
24782477
struct cifs_tcon *tcon;
2478+
bool nohandlecache;
2479+
int rc, xid;
24792480

24802481
tcon = cifs_find_tcon(ses, ctx);
24812482
if (tcon) {
@@ -2493,14 +2494,17 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb3_fs_context *ctx)
24932494
goto out_fail;
24942495
}
24952496

2496-
if (ses->server->capabilities & SMB2_GLOBAL_CAP_DIRECTORY_LEASING)
2497-
tcon = tcon_info_alloc(true);
2497+
if (ses->server->dialect >= SMB20_PROT_ID &&
2498+
(ses->server->capabilities & SMB2_GLOBAL_CAP_DIRECTORY_LEASING))
2499+
nohandlecache = ctx->nohandlecache;
24982500
else
2499-
tcon = tcon_info_alloc(false);
2501+
nohandlecache = true;
2502+
tcon = tcon_info_alloc(!nohandlecache);
25002503
if (tcon == NULL) {
25012504
rc = -ENOMEM;
25022505
goto out_fail;
25032506
}
2507+
tcon->nohandlecache = nohandlecache;
25042508

25052509
if (ctx->snapshot_time) {
25062510
if (ses->server->vals->protocol_id == 0) {
@@ -2662,10 +2666,6 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb3_fs_context *ctx)
26622666
tcon->nocase = ctx->nocase;
26632667
tcon->broken_sparse_sup = ctx->no_sparse;
26642668
tcon->max_cached_dirs = ctx->max_cached_dirs;
2665-
if (ses->server->capabilities & SMB2_GLOBAL_CAP_DIRECTORY_LEASING)
2666-
tcon->nohandlecache = ctx->nohandlecache;
2667-
else
2668-
tcon->nohandlecache = true;
26692669
tcon->nodelete = ctx->nodelete;
26702670
tcon->local_lease = ctx->local_lease;
26712671
INIT_LIST_HEAD(&tcon->pending_opens);
@@ -2895,9 +2895,9 @@ bind_socket(struct TCP_Server_Info *server)
28952895
if (server->srcaddr.ss_family != AF_UNSPEC) {
28962896
/* Bind to the specified local IP address */
28972897
struct socket *socket = server->ssocket;
2898-
rc = socket->ops->bind(socket,
2899-
(struct sockaddr *) &server->srcaddr,
2900-
sizeof(server->srcaddr));
2898+
rc = kernel_bind(socket,
2899+
(struct sockaddr *) &server->srcaddr,
2900+
sizeof(server->srcaddr));
29012901
if (rc < 0) {
29022902
struct sockaddr_in *saddr4;
29032903
struct sockaddr_in6 *saddr6;
@@ -3046,8 +3046,8 @@ generic_ip_connect(struct TCP_Server_Info *server)
30463046
socket->sk->sk_sndbuf,
30473047
socket->sk->sk_rcvbuf, socket->sk->sk_rcvtimeo);
30483048

3049-
rc = socket->ops->connect(socket, saddr, slen,
3050-
server->noblockcnt ? O_NONBLOCK : 0);
3049+
rc = kernel_connect(socket, saddr, slen,
3050+
server->noblockcnt ? O_NONBLOCK : 0);
30513051
/*
30523052
* When mounting SMB root file systems, we do not want to block in
30533053
* connect. Otherwise bail out and then let cifs_reconnect() perform

0 commit comments

Comments
 (0)