Commit 59f3fd30 authored by Linus Torvalds's avatar Linus Torvalds

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()
parents 102363a3 3b8bb317
...@@ -2474,8 +2474,9 @@ cifs_put_tcon(struct cifs_tcon *tcon) ...@@ -2474,8 +2474,9 @@ cifs_put_tcon(struct cifs_tcon *tcon)
static struct cifs_tcon * static struct cifs_tcon *
cifs_get_tcon(struct cifs_ses *ses, struct smb3_fs_context *ctx) cifs_get_tcon(struct cifs_ses *ses, struct smb3_fs_context *ctx)
{ {
int rc, xid;
struct cifs_tcon *tcon; struct cifs_tcon *tcon;
bool nohandlecache;
int rc, xid;
tcon = cifs_find_tcon(ses, ctx); tcon = cifs_find_tcon(ses, ctx);
if (tcon) { if (tcon) {
...@@ -2493,14 +2494,17 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb3_fs_context *ctx) ...@@ -2493,14 +2494,17 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb3_fs_context *ctx)
goto out_fail; goto out_fail;
} }
if (ses->server->capabilities & SMB2_GLOBAL_CAP_DIRECTORY_LEASING) if (ses->server->dialect >= SMB20_PROT_ID &&
tcon = tcon_info_alloc(true); (ses->server->capabilities & SMB2_GLOBAL_CAP_DIRECTORY_LEASING))
nohandlecache = ctx->nohandlecache;
else else
tcon = tcon_info_alloc(false); nohandlecache = true;
tcon = tcon_info_alloc(!nohandlecache);
if (tcon == NULL) { if (tcon == NULL) {
rc = -ENOMEM; rc = -ENOMEM;
goto out_fail; goto out_fail;
} }
tcon->nohandlecache = nohandlecache;
if (ctx->snapshot_time) { if (ctx->snapshot_time) {
if (ses->server->vals->protocol_id == 0) { if (ses->server->vals->protocol_id == 0) {
...@@ -2662,10 +2666,6 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb3_fs_context *ctx) ...@@ -2662,10 +2666,6 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb3_fs_context *ctx)
tcon->nocase = ctx->nocase; tcon->nocase = ctx->nocase;
tcon->broken_sparse_sup = ctx->no_sparse; tcon->broken_sparse_sup = ctx->no_sparse;
tcon->max_cached_dirs = ctx->max_cached_dirs; tcon->max_cached_dirs = ctx->max_cached_dirs;
if (ses->server->capabilities & SMB2_GLOBAL_CAP_DIRECTORY_LEASING)
tcon->nohandlecache = ctx->nohandlecache;
else
tcon->nohandlecache = true;
tcon->nodelete = ctx->nodelete; tcon->nodelete = ctx->nodelete;
tcon->local_lease = ctx->local_lease; tcon->local_lease = ctx->local_lease;
INIT_LIST_HEAD(&tcon->pending_opens); INIT_LIST_HEAD(&tcon->pending_opens);
...@@ -2895,9 +2895,9 @@ bind_socket(struct TCP_Server_Info *server) ...@@ -2895,9 +2895,9 @@ bind_socket(struct TCP_Server_Info *server)
if (server->srcaddr.ss_family != AF_UNSPEC) { if (server->srcaddr.ss_family != AF_UNSPEC) {
/* Bind to the specified local IP address */ /* Bind to the specified local IP address */
struct socket *socket = server->ssocket; struct socket *socket = server->ssocket;
rc = socket->ops->bind(socket, rc = kernel_bind(socket,
(struct sockaddr *) &server->srcaddr, (struct sockaddr *) &server->srcaddr,
sizeof(server->srcaddr)); sizeof(server->srcaddr));
if (rc < 0) { if (rc < 0) {
struct sockaddr_in *saddr4; struct sockaddr_in *saddr4;
struct sockaddr_in6 *saddr6; struct sockaddr_in6 *saddr6;
...@@ -3046,8 +3046,8 @@ generic_ip_connect(struct TCP_Server_Info *server) ...@@ -3046,8 +3046,8 @@ generic_ip_connect(struct TCP_Server_Info *server)
socket->sk->sk_sndbuf, socket->sk->sk_sndbuf,
socket->sk->sk_rcvbuf, socket->sk->sk_rcvtimeo); socket->sk->sk_rcvbuf, socket->sk->sk_rcvtimeo);
rc = socket->ops->connect(socket, saddr, slen, rc = kernel_connect(socket, saddr, slen,
server->noblockcnt ? O_NONBLOCK : 0); server->noblockcnt ? O_NONBLOCK : 0);
/* /*
* When mounting SMB root file systems, we do not want to block in * When mounting SMB root file systems, we do not want to block in
* connect. Otherwise bail out and then let cifs_reconnect() perform * connect. Otherwise bail out and then let cifs_reconnect() perform
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment