Skip to content

Commit e874a5f

Browse files
committed
Merge branch 'for-next-3.17' of git://git.samba.org/sfrench/cifs-2.6
Pull cifs/smb3 fixes from Steve French: "This includes various cifs and smb3 bug fixes including those for bugs found with the recently updated xfstests. Also I am working fixes for two additional cifs problems found by xfstests which I plan to send later (when reviewed and run additional tests)" * 'for-next-3.17' of git://git.samba.org/sfrench/cifs-2.6: Clarify Kconfig help text for CIFS and SMB2/SMB3 CIFS: Fix wrong filename length for SMB2 CIFS: Fix wrong restart readdir for SMB1 CIFS: Fix directory rename error cifs: No need to send SIGKILL to demux_thread during umount cifs: Allow directIO read/write during cache=strict cifs: remove unneeded check of null checking in if condition cifs: fix a possible use of uninit variable in SMB2_sess_setup cifs: fix memory leak when password is supplied multiple times cifs: fix a possible null pointer deref in decode_ascii_ssetup Trivial whitespace fix
2 parents 619df5d + ca5d13f commit e874a5f

File tree

12 files changed

+58
-50
lines changed

12 files changed

+58
-50
lines changed

fs/cifs/Kconfig

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ config CIFS
2222
support for OS/2 and Windows ME and similar servers is provided as
2323
well.
2424

25+
The module also provides optional support for the followon
26+
protocols for CIFS including SMB3, which enables
27+
useful performance and security features (see the description
28+
of CONFIG_CIFS_SMB2).
29+
2530
The cifs module provides an advanced network file system
2631
client for mounting to CIFS compliant servers. It includes
2732
support for DFS (hierarchical name space), secure per-user
@@ -121,7 +126,8 @@ config CIFS_ACL
121126
depends on CIFS_XATTR && KEYS
122127
help
123128
Allows fetching CIFS/NTFS ACL from the server. The DACL blob
124-
is handed over to the application/caller.
129+
is handed over to the application/caller. See the man
130+
page for getcifsacl for more information.
125131

126132
config CIFS_DEBUG
127133
bool "Enable CIFS debugging routines"
@@ -162,24 +168,29 @@ config CIFS_NFSD_EXPORT
162168
Allows NFS server to export a CIFS mounted share (nfsd over cifs)
163169

164170
config CIFS_SMB2
165-
bool "SMB2 network file system support"
171+
bool "SMB2 and SMB3 network file system support"
166172
depends on CIFS && INET
167173
select NLS
168174
select KEYS
169175
select FSCACHE
170176
select DNS_RESOLVER
171177

172178
help
173-
This enables experimental support for the SMB2 (Server Message Block
174-
version 2) protocol. The SMB2 protocol is the successor to the
175-
popular CIFS and SMB network file sharing protocols. SMB2 is the
176-
native file sharing mechanism for recent versions of Windows
177-
operating systems (since Vista). SMB2 enablement will eventually
178-
allow users better performance, security and features, than would be
179-
possible with cifs. Note that smb2 mount options also are simpler
180-
(compared to cifs) due to protocol improvements.
181-
182-
Unless you are a developer or tester, say N.
179+
This enables support for the Server Message Block version 2
180+
family of protocols, including SMB3. SMB3 support is
181+
enabled on mount by specifying "vers=3.0" in the mount
182+
options. These protocols are the successors to the popular
183+
CIFS and SMB network file sharing protocols. SMB3 is the
184+
native file sharing mechanism for the more recent
185+
versions of Windows (Windows 8 and Windows 2012 and
186+
later) and Samba server and many others support SMB3 well.
187+
In general SMB3 enables better performance, security
188+
and features, than would be possible with CIFS (Note that
189+
when mounting to Samba, due to the CIFS POSIX extensions,
190+
CIFS mounts can provide slightly better POSIX compatibility
191+
than SMB3 mounts do though). Note that SMB2/SMB3 mount
192+
options are also slightly simpler (compared to CIFS) due
193+
to protocol improvements.
183194

184195
config CIFS_FSCACHE
185196
bool "Provide CIFS client caching support"

fs/cifs/cifsglob.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,6 @@
7070
#define SERVER_NAME_LENGTH 40
7171
#define SERVER_NAME_LEN_WITH_NULL (SERVER_NAME_LENGTH + 1)
7272

73-
/* used to define string lengths for reversing unicode strings */
74-
/* (256+1)*2 = 514 */
75-
/* (max path length + 1 for null) * 2 for unicode */
76-
#define MAX_NAME 514
77-
7873
/* SMB echo "timeout" -- FIXME: tunable? */
7974
#define SMB_ECHO_INTERVAL (60 * HZ)
8075

fs/cifs/connect.c

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,6 @@ cifs_demultiplex_thread(void *p)
837837
struct TCP_Server_Info *server = p;
838838
unsigned int pdu_length;
839839
char *buf = NULL;
840-
struct task_struct *task_to_wake = NULL;
841840
struct mid_q_entry *mid_entry;
842841

843842
current->flags |= PF_MEMALLOC;
@@ -928,19 +927,7 @@ cifs_demultiplex_thread(void *p)
928927
if (server->smallbuf) /* no sense logging a debug message if NULL */
929928
cifs_small_buf_release(server->smallbuf);
930929

931-
task_to_wake = xchg(&server->tsk, NULL);
932930
clean_demultiplex_info(server);
933-
934-
/* if server->tsk was NULL then wait for a signal before exiting */
935-
if (!task_to_wake) {
936-
set_current_state(TASK_INTERRUPTIBLE);
937-
while (!signal_pending(current)) {
938-
schedule();
939-
set_current_state(TASK_INTERRUPTIBLE);
940-
}
941-
set_current_state(TASK_RUNNING);
942-
}
943-
944931
module_put_and_exit(0);
945932
}
946933

@@ -1600,6 +1587,7 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
16001587
tmp_end++;
16011588
if (!(tmp_end < end && tmp_end[1] == delim)) {
16021589
/* No it is not. Set the password to NULL */
1590+
kfree(vol->password);
16031591
vol->password = NULL;
16041592
break;
16051593
}
@@ -1637,6 +1625,7 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
16371625
options = end;
16381626
}
16391627

1628+
kfree(vol->password);
16401629
/* Now build new password string */
16411630
temp_len = strlen(value);
16421631
vol->password = kzalloc(temp_len+1, GFP_KERNEL);
@@ -2061,8 +2050,6 @@ cifs_find_tcp_session(struct smb_vol *vol)
20612050
static void
20622051
cifs_put_tcp_session(struct TCP_Server_Info *server)
20632052
{
2064-
struct task_struct *task;
2065-
20662053
spin_lock(&cifs_tcp_ses_lock);
20672054
if (--server->srv_count > 0) {
20682055
spin_unlock(&cifs_tcp_ses_lock);
@@ -2086,10 +2073,6 @@ cifs_put_tcp_session(struct TCP_Server_Info *server)
20862073
kfree(server->session_key.response);
20872074
server->session_key.response = NULL;
20882075
server->session_key.len = 0;
2089-
2090-
task = xchg(&server->tsk, NULL);
2091-
if (task)
2092-
force_sig(SIGKILL, task);
20932076
}
20942077

20952078
static struct TCP_Server_Info *

fs/cifs/dir.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,14 @@ cifs_atomic_open(struct inode *inode, struct dentry *direntry,
497497
goto out;
498498
}
499499

500+
if (file->f_flags & O_DIRECT &&
501+
CIFS_SB(inode->i_sb)->mnt_cifs_flags & CIFS_MOUNT_STRICT_IO) {
502+
if (CIFS_SB(inode->i_sb)->mnt_cifs_flags & CIFS_MOUNT_NO_BRL)
503+
file->f_op = &cifs_file_direct_nobrl_ops;
504+
else
505+
file->f_op = &cifs_file_direct_ops;
506+
}
507+
500508
file_info = cifs_new_fileinfo(&fid, file, tlink, oplock);
501509
if (file_info == NULL) {
502510
if (server->ops->close)

fs/cifs/file.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,14 @@ int cifs_open(struct inode *inode, struct file *file)
467467
cifs_dbg(FYI, "inode = 0x%p file flags are 0x%x for %s\n",
468468
inode, file->f_flags, full_path);
469469

470+
if (file->f_flags & O_DIRECT &&
471+
cifs_sb->mnt_cifs_flags & CIFS_MOUNT_STRICT_IO) {
472+
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL)
473+
file->f_op = &cifs_file_direct_nobrl_ops;
474+
else
475+
file->f_op = &cifs_file_direct_ops;
476+
}
477+
470478
if (server->oplocks)
471479
oplock = REQ_OPLOCK;
472480
else

fs/cifs/inode.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1720,7 +1720,10 @@ cifs_rename2(struct inode *source_dir, struct dentry *source_dentry,
17201720
unlink_target:
17211721
/* Try unlinking the target dentry if it's not negative */
17221722
if (target_dentry->d_inode && (rc == -EACCES || rc == -EEXIST)) {
1723-
tmprc = cifs_unlink(target_dir, target_dentry);
1723+
if (d_is_dir(target_dentry))
1724+
tmprc = cifs_rmdir(target_dir, target_dentry);
1725+
else
1726+
tmprc = cifs_unlink(target_dir, target_dentry);
17241727
if (tmprc)
17251728
goto cifs_rename_exit;
17261729
rc = cifs_do_rename(xid, source_dentry, from_name,

fs/cifs/readdir.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,8 +596,8 @@ find_cifs_entry(const unsigned int xid, struct cifs_tcon *tcon, loff_t pos,
596596
if (server->ops->dir_needs_close(cfile)) {
597597
cfile->invalidHandle = true;
598598
spin_unlock(&cifs_file_list_lock);
599-
if (server->ops->close)
600-
server->ops->close(xid, tcon, &cfile->fid);
599+
if (server->ops->close_dir)
600+
server->ops->close_dir(xid, tcon, &cfile->fid);
601601
} else
602602
spin_unlock(&cifs_file_list_lock);
603603
if (cfile->srch_inf.ntwrk_buf_start) {

fs/cifs/sess.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,11 @@ static void decode_ascii_ssetup(char **pbcc_area, __u16 bleft,
243243
kfree(ses->serverOS);
244244

245245
ses->serverOS = kzalloc(len + 1, GFP_KERNEL);
246-
if (ses->serverOS)
246+
if (ses->serverOS) {
247247
strncpy(ses->serverOS, bcc_ptr, len);
248-
if (strncmp(ses->serverOS, "OS/2", 4) == 0)
249-
cifs_dbg(FYI, "OS/2 server\n");
248+
if (strncmp(ses->serverOS, "OS/2", 4) == 0)
249+
cifs_dbg(FYI, "OS/2 server\n");
250+
}
250251

251252
bcc_ptr += len + 1;
252253
bleft -= len + 1;

fs/cifs/smb2file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ smb2_open_file(const unsigned int xid, struct cifs_open_parms *oparms,
5050
goto out;
5151
}
5252

53-
smb2_data = kzalloc(sizeof(struct smb2_file_all_info) + MAX_NAME * 2,
53+
smb2_data = kzalloc(sizeof(struct smb2_file_all_info) + PATH_MAX * 2,
5454
GFP_KERNEL);
5555
if (smb2_data == NULL) {
5656
rc = -ENOMEM;

fs/cifs/smb2inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ smb2_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
131131
*adjust_tz = false;
132132
*symlink = false;
133133

134-
smb2_data = kzalloc(sizeof(struct smb2_file_all_info) + MAX_NAME * 2,
134+
smb2_data = kzalloc(sizeof(struct smb2_file_all_info) + PATH_MAX * 2,
135135
GFP_KERNEL);
136136
if (smb2_data == NULL)
137137
return -ENOMEM;

0 commit comments

Comments
 (0)