Commit d874ca05 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'v7.0-rc3-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6

Pull smb client fixes from Steve French:
 - Fix reconnect when using non-default port
 - Fix default retransmission behavior
 - Fix open handle reuse in cifs_open
 - Fix export for smb2-mapperror-test
 - Fix potential corruption on write retry
 - Fix potentially uninitialized superblock flags
 - Fix missing O_DIRECT and O_SYNC flags on create

* tag 'v7.0-rc3-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6:
  cifs: make default value of retrans as zero
  smb: client: fix open handle lookup in cifs_open()
  smb: client: fix iface port assignment in parse_server_interfaces
  smb/client: only export symbol for 'smb2maperror-test' module
  smb: client: fix in-place encryption corruption in SMB2_write()
  smb: client: fix sbflags initialization
  smb: client: fix atomic open with O_DIRECT & O_SYNC
parents b36eb6e3 e3beefd3
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1489,7 +1489,7 @@ struct smb_ntsd *get_cifs_acl(struct cifs_sb_info *cifs_sb,
	struct cifsFileInfo *open_file = NULL;

	if (inode)
		open_file = find_readable_file(CIFS_I(inode), true);
		open_file = find_readable_file(CIFS_I(inode), FIND_FSUID_ONLY);
	if (!open_file)
		return get_cifs_acl_by_path(cifs_sb, path, pacllen, info);

+1 −1
Original line number Diff line number Diff line
@@ -1269,7 +1269,7 @@ static int cifs_precopy_set_eof(struct inode *src_inode, struct cifsInodeInfo *s
	struct cifsFileInfo *writeable_srcfile;
	int rc = -EINVAL;

	writeable_srcfile = find_writable_file(src_cifsi, FIND_WR_FSUID_ONLY);
	writeable_srcfile = find_writable_file(src_cifsi, FIND_FSUID_ONLY);
	if (writeable_srcfile) {
		if (src_tcon->ses->server->ops->set_file_size)
			rc = src_tcon->ses->server->ops->set_file_size(
+17 −6
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#include <linux/utsname.h>
#include <linux/sched/mm.h>
#include <linux/netfs.h>
#include <linux/fcntl.h>
#include "cifs_fs_sb.h"
#include "cifsacl.h"
#include <crypto/internal/hash.h>
@@ -1884,12 +1885,12 @@ static inline bool is_replayable_error(int error)
}


/* cifs_get_writable_file() flags */
enum cifs_writable_file_flags {
	FIND_WR_ANY			= 0U,
	FIND_WR_FSUID_ONLY		= (1U << 0),
	FIND_WR_WITH_DELETE		= (1U << 1),
	FIND_WR_NO_PENDING_DELETE	= (1U << 2),
enum cifs_find_flags {
	FIND_ANY		= 0U,
	FIND_FSUID_ONLY		= (1U << 0),
	FIND_WITH_DELETE	= (1U << 1),
	FIND_NO_PENDING_DELETE	= (1U << 2),
	FIND_OPEN_FLAGS		= (1U << 3),
};

#define   MID_FREE 0
@@ -2375,4 +2376,14 @@ static inline bool cifs_forced_shutdown(const struct cifs_sb_info *sbi)
	return cifs_sb_flags(sbi) & CIFS_MOUNT_SHUTDOWN;
}

static inline int cifs_open_create_options(unsigned int oflags, int opts)
{
	/* O_SYNC also has bit for O_DSYNC so following check picks up either */
	if (oflags & O_SYNC)
		opts |= CREATE_WRITE_THROUGH;
	if (oflags & O_DIRECT)
		opts |= CREATE_NO_BUFFER;
	return opts;
}

#endif	/* _CIFS_GLOB_H */
+22 −4
Original line number Diff line number Diff line
@@ -138,12 +138,14 @@ void cifs_write_subrequest_terminated(struct cifs_io_subrequest *wdata,
				      ssize_t result);
struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *cifs_inode,
					int flags);
int cifs_get_writable_file(struct cifsInodeInfo *cifs_inode, int flags,
int __cifs_get_writable_file(struct cifsInodeInfo *cifs_inode,
			     unsigned int find_flags, unsigned int open_flags,
			     struct cifsFileInfo **ret_file);
int cifs_get_writable_path(struct cifs_tcon *tcon, const char *name, int flags,
			   struct cifsFileInfo **ret_file);
struct cifsFileInfo *find_readable_file(struct cifsInodeInfo *cifs_inode,
					bool fsuid_only);
struct cifsFileInfo *__find_readable_file(struct cifsInodeInfo *cifs_inode,
					  unsigned int find_flags,
					  unsigned int open_flags);
int cifs_get_readable_path(struct cifs_tcon *tcon, const char *name,
			   struct cifsFileInfo **ret_file);
int cifs_get_hardlink_path(struct cifs_tcon *tcon, struct inode *inode,
@@ -596,4 +598,20 @@ static inline void cifs_sg_set_buf(struct sg_table *sgtable,
	}
}

static inline int cifs_get_writable_file(struct cifsInodeInfo *cifs_inode,
					 unsigned int find_flags,
					 struct cifsFileInfo **ret_file)
{
	find_flags &= ~FIND_OPEN_FLAGS;
	return __cifs_get_writable_file(cifs_inode, find_flags, 0, ret_file);
}

static inline struct cifsFileInfo *
find_readable_file(struct cifsInodeInfo *cinode, unsigned int find_flags)
{
	find_flags &= ~FIND_OPEN_FLAGS;
	find_flags |= FIND_NO_PENDING_DELETE;
	return __find_readable_file(cinode, find_flags, 0);
}

#endif			/* _CIFSPROTO_H */
+2 −2
Original line number Diff line number Diff line
@@ -187,7 +187,7 @@ static int cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned
	const char *full_path;
	void *page = alloc_dentry_path();
	struct inode *newinode = NULL;
	unsigned int sbflags;
	unsigned int sbflags = cifs_sb_flags(cifs_sb);
	int disposition;
	struct TCP_Server_Info *server = tcon->ses->server;
	struct cifs_open_parms oparms;
@@ -308,6 +308,7 @@ static int cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned
		goto out;
	}

	create_options |= cifs_open_create_options(oflags, create_options);
	/*
	 * if we're not using unix extensions, see if we need to set
	 * ATTR_READONLY on the create call
@@ -367,7 +368,6 @@ static int cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned
	 * If Open reported that we actually created a file then we now have to
	 * set the mode if possible.
	 */
	sbflags = cifs_sb_flags(cifs_sb);
	if ((tcon->unix_ext) && (*oplock & CIFS_CREATE_ACTION)) {
		struct cifs_unix_set_info_args args = {
				.mode	= mode,
Loading