Skip to content

Commit

Permalink
Merge tag '6.13-rc3-SMB3-client-fixes' of git://git.samba.org/sfrench…
Browse files Browse the repository at this point in the history
…/cifs-2.6

Pull smb client fixes from Steve French:

 - fix regression in display of write stats

 - fix rmmod failure with network namespaces

 - two minor cleanups

* tag '6.13-rc3-SMB3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6:
  smb: fix bytes written value in /proc/fs/cifs/Stats
  smb: client: fix TCP timers deadlock after rmmod
  smb: client: Deduplicate "select NETFS_SUPPORT" in Kconfig
  smb: use macros instead of constants for leasekey size and default cifsattrs value
  • Loading branch information
torvalds committed Dec 21, 2024
2 parents 4a5da3f + 92941c7 commit baa172c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 13 deletions.
1 change: 0 additions & 1 deletion fs/smb/client/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
config CIFS
tristate "SMB3 and CIFS support (advanced network filesystem)"
depends on INET
select NETFS_SUPPORT
select NLS
select NLS_UCS2_UTILS
select CRYPTO
Expand Down
2 changes: 1 addition & 1 deletion fs/smb/client/cifsfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ cifs_alloc_inode(struct super_block *sb)
cifs_inode = alloc_inode_sb(sb, cifs_inode_cachep, GFP_KERNEL);
if (!cifs_inode)
return NULL;
cifs_inode->cifsAttrs = 0x20; /* default */
cifs_inode->cifsAttrs = ATTR_ARCHIVE; /* default */
cifs_inode->time = 0;
/*
* Until the file is open and we have gotten oplock info back from the
Expand Down
36 changes: 26 additions & 10 deletions fs/smb/client/connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -987,9 +987,13 @@ clean_demultiplex_info(struct TCP_Server_Info *server)
msleep(125);
if (cifs_rdma_enabled(server))
smbd_destroy(server);

if (server->ssocket) {
sock_release(server->ssocket);
server->ssocket = NULL;

/* Release netns reference for the socket. */
put_net(cifs_net_ns(server));
}

if (!list_empty(&server->pending_mid_q)) {
Expand Down Expand Up @@ -1037,6 +1041,7 @@ clean_demultiplex_info(struct TCP_Server_Info *server)
*/
}

/* Release netns reference for this server. */
put_net(cifs_net_ns(server));
kfree(server->leaf_fullpath);
kfree(server);
Expand Down Expand Up @@ -1713,6 +1718,8 @@ cifs_get_tcp_session(struct smb3_fs_context *ctx,

tcp_ses->ops = ctx->ops;
tcp_ses->vals = ctx->vals;

/* Grab netns reference for this server. */
cifs_set_net_ns(tcp_ses, get_net(current->nsproxy->net_ns));

tcp_ses->conn_id = atomic_inc_return(&tcpSesNextId);
Expand Down Expand Up @@ -1844,6 +1851,7 @@ cifs_get_tcp_session(struct smb3_fs_context *ctx,
out_err_crypto_release:
cifs_crypto_secmech_release(tcp_ses);

/* Release netns reference for this server. */
put_net(cifs_net_ns(tcp_ses));

out_err:
Expand All @@ -1852,8 +1860,10 @@ cifs_get_tcp_session(struct smb3_fs_context *ctx,
cifs_put_tcp_session(tcp_ses->primary_server, false);
kfree(tcp_ses->hostname);
kfree(tcp_ses->leaf_fullpath);
if (tcp_ses->ssocket)
if (tcp_ses->ssocket) {
sock_release(tcp_ses->ssocket);
put_net(cifs_net_ns(tcp_ses));
}
kfree(tcp_ses);
}
return ERR_PTR(rc);
Expand Down Expand Up @@ -3131,20 +3141,20 @@ generic_ip_connect(struct TCP_Server_Info *server)
socket = server->ssocket;
} else {
struct net *net = cifs_net_ns(server);
struct sock *sk;

rc = __sock_create(net, sfamily, SOCK_STREAM,
IPPROTO_TCP, &server->ssocket, 1);
rc = sock_create_kern(net, sfamily, SOCK_STREAM, IPPROTO_TCP, &server->ssocket);
if (rc < 0) {
cifs_server_dbg(VFS, "Error %d creating socket\n", rc);
return rc;
}

sk = server->ssocket->sk;
__netns_tracker_free(net, &sk->ns_tracker, false);
sk->sk_net_refcnt = 1;
get_net_track(net, &sk->ns_tracker, GFP_KERNEL);
sock_inuse_add(net, 1);
/*
* Grab netns reference for the socket.
*
* It'll be released here, on error, or in clean_demultiplex_info() upon server
* teardown.
*/
get_net(net);

/* BB other socket options to set KEEPALIVE, NODELAY? */
cifs_dbg(FYI, "Socket created\n");
Expand All @@ -3158,8 +3168,10 @@ generic_ip_connect(struct TCP_Server_Info *server)
}

rc = bind_socket(server);
if (rc < 0)
if (rc < 0) {
put_net(cifs_net_ns(server));
return rc;
}

/*
* Eventually check for other socket options to change from
Expand Down Expand Up @@ -3196,6 +3208,7 @@ generic_ip_connect(struct TCP_Server_Info *server)
if (rc < 0) {
cifs_dbg(FYI, "Error %d connecting to server\n", rc);
trace_smb3_connect_err(server->hostname, server->conn_id, &server->dstaddr, rc);
put_net(cifs_net_ns(server));
sock_release(socket);
server->ssocket = NULL;
return rc;
Expand All @@ -3204,6 +3217,9 @@ generic_ip_connect(struct TCP_Server_Info *server)
if (sport == htons(RFC1001_PORT))
rc = ip_rfc1001_connect(server);

if (rc < 0)
put_net(cifs_net_ns(server));

return rc;
}

Expand Down
5 changes: 4 additions & 1 deletion fs/smb/client/smb2pdu.c
Original file line number Diff line number Diff line change
Expand Up @@ -4840,6 +4840,8 @@ smb2_writev_callback(struct mid_q_entry *mid)
if (written > wdata->subreq.len)
written &= 0xFFFF;

cifs_stats_bytes_written(tcon, written);

if (written < wdata->subreq.len)
wdata->result = -ENOSPC;
else
Expand Down Expand Up @@ -5156,6 +5158,7 @@ SMB2_write(const unsigned int xid, struct cifs_io_parms *io_parms,
cifs_dbg(VFS, "Send error in write = %d\n", rc);
} else {
*nbytes = le32_to_cpu(rsp->DataLength);
cifs_stats_bytes_written(io_parms->tcon, *nbytes);
trace_smb3_write_done(0, 0, xid,
req->PersistentFileId,
io_parms->tcon->tid,
Expand Down Expand Up @@ -6204,7 +6207,7 @@ SMB2_lease_break(const unsigned int xid, struct cifs_tcon *tcon,
req->StructureSize = cpu_to_le16(36);
total_len += 12;

memcpy(req->LeaseKey, lease_key, 16);
memcpy(req->LeaseKey, lease_key, SMB2_LEASE_KEY_SIZE);
req->LeaseState = lease_state;

flags |= CIFS_NO_RSP_BUF;
Expand Down

0 comments on commit baa172c

Please sign in to comment.