Skip to content

Commit 42eb017

Browse files
committed
Merge tag 'v7.0rc1-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6
Pull smb client fixes from Steve French: - Two multichannel fixes - Locking fix for superblock flags - Fix to remove debug message that could log password - Cleanup fix for setting credentials * tag 'v7.0rc1-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6: smb: client: Use snprintf in cifs_set_cifscreds smb: client: Don't log plaintext credentials in cifs_set_cifscreds smb: client: fix broken multichannel with krb5+signing smb: client: use atomic_t for mnt_cifs_flags smb: client: fix cifs_pick_channel when channels are equally loaded
2 parents 9197e59 + f505a45 commit 42eb017

28 files changed

+489
-445
lines changed

fs/smb/client/cached_dir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ static const char *path_no_prefix(struct cifs_sb_info *cifs_sb,
118118
if (!*path)
119119
return path;
120120

121-
if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH) &&
121+
if ((cifs_sb_flags(cifs_sb) & CIFS_MOUNT_USE_PREFIX_PATH) &&
122122
cifs_sb->prepath) {
123123
len = strlen(cifs_sb->prepath) + 1;
124124
if (unlikely(len > strlen(path)))

fs/smb/client/cifs_fs_sb.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ struct cifs_sb_info {
5555
struct nls_table *local_nls;
5656
struct smb3_fs_context *ctx;
5757
atomic_t active;
58-
unsigned int mnt_cifs_flags;
58+
atomic_t mnt_cifs_flags;
5959
struct delayed_work prune_tlinks;
6060
struct rcu_head rcu;
6161

fs/smb/client/cifs_ioctl.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,3 @@ struct smb3_notify_info {
122122
#define CIFS_GOING_FLAGS_DEFAULT 0x0 /* going down */
123123
#define CIFS_GOING_FLAGS_LOGFLUSH 0x1 /* flush log but not data */
124124
#define CIFS_GOING_FLAGS_NOLOGFLUSH 0x2 /* don't flush log nor data */
125-
126-
static inline bool cifs_forced_shutdown(struct cifs_sb_info *sbi)
127-
{
128-
if (CIFS_MOUNT_SHUTDOWN & sbi->mnt_cifs_flags)
129-
return true;
130-
else
131-
return false;
132-
}

fs/smb/client/cifs_unicode.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,6 @@
1111
#include "cifsglob.h"
1212
#include "cifs_debug.h"
1313

14-
int cifs_remap(struct cifs_sb_info *cifs_sb)
15-
{
16-
int map_type;
17-
18-
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SFM_CHR)
19-
map_type = SFM_MAP_UNI_RSVD;
20-
else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR)
21-
map_type = SFU_MAP_UNI_RSVD;
22-
else
23-
map_type = NO_MAP_UNI_RSVD;
24-
25-
return map_type;
26-
}
27-
2814
/* Convert character using the SFU - "Services for Unix" remapping range */
2915
static bool
3016
convert_sfu_char(const __u16 src_char, char *target)

fs/smb/client/cifs_unicode.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <linux/types.h>
2323
#include <linux/nls.h>
2424
#include "../../nls/nls_ucs2_utils.h"
25+
#include "cifsglob.h"
2526

2627
/*
2728
* Macs use an older "SFM" mapping of the symbols above. Fortunately it does
@@ -65,10 +66,21 @@ char *cifs_strndup_from_utf16(const char *src, const int maxlen,
6566
const struct nls_table *codepage);
6667
int cifsConvertToUTF16(__le16 *target, const char *source, int srclen,
6768
const struct nls_table *cp, int map_chars);
68-
int cifs_remap(struct cifs_sb_info *cifs_sb);
6969
__le16 *cifs_strndup_to_utf16(const char *src, const int maxlen,
7070
int *utf16_len, const struct nls_table *cp,
7171
int remap);
7272
wchar_t cifs_toupper(wchar_t in);
7373

74+
static inline int cifs_remap(const struct cifs_sb_info *cifs_sb)
75+
{
76+
unsigned int sbflags = cifs_sb_flags(cifs_sb);
77+
78+
if (sbflags & CIFS_MOUNT_MAP_SFM_CHR)
79+
return SFM_MAP_UNI_RSVD;
80+
if (sbflags & CIFS_MOUNT_MAP_SPECIAL_CHR)
81+
return SFU_MAP_UNI_RSVD;
82+
83+
return NO_MAP_UNI_RSVD;
84+
}
85+
7486
#endif /* _CIFS_UNICODE_H */

fs/smb/client/cifsacl.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ sid_to_id(struct cifs_sb_info *cifs_sb, struct smb_sid *psid,
356356
psid->num_subauth, SID_MAX_SUB_AUTHORITIES);
357357
}
358358

359-
if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UID_FROM_ACL) ||
359+
if ((cifs_sb_flags(cifs_sb) & CIFS_MOUNT_UID_FROM_ACL) ||
360360
(cifs_sb_master_tcon(cifs_sb)->posix_extensions)) {
361361
uint32_t unix_id;
362362
bool is_group;
@@ -1612,7 +1612,8 @@ id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64 *pnmode,
16121612
struct smb_acl *dacl_ptr = NULL;
16131613
struct smb_ntsd *pntsd = NULL; /* acl obtained from server */
16141614
struct smb_ntsd *pnntsd = NULL; /* modified acl to be sent to server */
1615-
struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
1615+
struct cifs_sb_info *cifs_sb = CIFS_SB(inode);
1616+
unsigned int sbflags;
16161617
struct tcon_link *tlink;
16171618
struct smb_version_operations *ops;
16181619
bool mode_from_sid, id_from_sid;
@@ -1643,15 +1644,9 @@ id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64 *pnmode,
16431644
return rc;
16441645
}
16451646

1646-
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MODE_FROM_SID)
1647-
mode_from_sid = true;
1648-
else
1649-
mode_from_sid = false;
1650-
1651-
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UID_FROM_ACL)
1652-
id_from_sid = true;
1653-
else
1654-
id_from_sid = false;
1647+
sbflags = cifs_sb_flags(cifs_sb);
1648+
mode_from_sid = sbflags & CIFS_MOUNT_MODE_FROM_SID;
1649+
id_from_sid = sbflags & CIFS_MOUNT_UID_FROM_ACL;
16551650

16561651
/* Potentially, five new ACEs can be added to the ACL for U,G,O mapping */
16571652
if (pnmode && *pnmode != NO_CHANGE_64) { /* chmod */

fs/smb/client/cifsfs.c

Lines changed: 44 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -226,16 +226,18 @@ cifs_sb_deactive(struct super_block *sb)
226226
static int
227227
cifs_read_super(struct super_block *sb)
228228
{
229-
struct inode *inode;
230229
struct cifs_sb_info *cifs_sb;
231230
struct cifs_tcon *tcon;
231+
unsigned int sbflags;
232232
struct timespec64 ts;
233+
struct inode *inode;
233234
int rc = 0;
234235

235236
cifs_sb = CIFS_SB(sb);
236237
tcon = cifs_sb_master_tcon(cifs_sb);
238+
sbflags = cifs_sb_flags(cifs_sb);
237239

238-
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIXACL)
240+
if (sbflags & CIFS_MOUNT_POSIXACL)
239241
sb->s_flags |= SB_POSIXACL;
240242

241243
if (tcon->snapshot_time)
@@ -311,7 +313,7 @@ cifs_read_super(struct super_block *sb)
311313
}
312314

313315
#ifdef CONFIG_CIFS_NFSD_EXPORT
314-
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) {
316+
if (sbflags & CIFS_MOUNT_SERVER_INUM) {
315317
cifs_dbg(FYI, "export ops supported\n");
316318
sb->s_export_op = &cifs_export_ops;
317319
}
@@ -389,8 +391,7 @@ cifs_statfs(struct dentry *dentry, struct kstatfs *buf)
389391

390392
static long cifs_fallocate(struct file *file, int mode, loff_t off, loff_t len)
391393
{
392-
struct cifs_sb_info *cifs_sb = CIFS_FILE_SB(file);
393-
struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb);
394+
struct cifs_tcon *tcon = cifs_sb_master_tcon(CIFS_SB(file));
394395
struct TCP_Server_Info *server = tcon->ses->server;
395396
struct inode *inode = file_inode(file);
396397
int rc;
@@ -418,11 +419,9 @@ static long cifs_fallocate(struct file *file, int mode, loff_t off, loff_t len)
418419
static int cifs_permission(struct mnt_idmap *idmap,
419420
struct inode *inode, int mask)
420421
{
421-
struct cifs_sb_info *cifs_sb;
422+
unsigned int sbflags = cifs_sb_flags(CIFS_SB(inode));
422423

423-
cifs_sb = CIFS_SB(inode->i_sb);
424-
425-
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM) {
424+
if (sbflags & CIFS_MOUNT_NO_PERM) {
426425
if ((mask & MAY_EXEC) && !execute_ok(inode))
427426
return -EACCES;
428427
else
@@ -568,15 +567,17 @@ cifs_show_security(struct seq_file *s, struct cifs_ses *ses)
568567
static void
569568
cifs_show_cache_flavor(struct seq_file *s, struct cifs_sb_info *cifs_sb)
570569
{
570+
unsigned int sbflags = cifs_sb_flags(cifs_sb);
571+
571572
seq_puts(s, ",cache=");
572573

573-
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_STRICT_IO)
574+
if (sbflags & CIFS_MOUNT_STRICT_IO)
574575
seq_puts(s, "strict");
575-
else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO)
576+
else if (sbflags & CIFS_MOUNT_DIRECT_IO)
576577
seq_puts(s, "none");
577-
else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RW_CACHE)
578+
else if (sbflags & CIFS_MOUNT_RW_CACHE)
578579
seq_puts(s, "singleclient"); /* assume only one client access */
579-
else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RO_CACHE)
580+
else if (sbflags & CIFS_MOUNT_RO_CACHE)
580581
seq_puts(s, "ro"); /* read only caching assumed */
581582
else
582583
seq_puts(s, "loose");
@@ -637,6 +638,8 @@ cifs_show_options(struct seq_file *s, struct dentry *root)
637638
struct cifs_sb_info *cifs_sb = CIFS_SB(root->d_sb);
638639
struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb);
639640
struct sockaddr *srcaddr;
641+
unsigned int sbflags;
642+
640643
srcaddr = (struct sockaddr *)&tcon->ses->server->srcaddr;
641644

642645
seq_show_option(s, "vers", tcon->ses->server->vals->version_string);
@@ -670,16 +673,17 @@ cifs_show_options(struct seq_file *s, struct dentry *root)
670673
(int)(srcaddr->sa_family));
671674
}
672675

676+
sbflags = cifs_sb_flags(cifs_sb);
673677
seq_printf(s, ",uid=%u",
674678
from_kuid_munged(&init_user_ns, cifs_sb->ctx->linux_uid));
675-
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID)
679+
if (sbflags & CIFS_MOUNT_OVERR_UID)
676680
seq_puts(s, ",forceuid");
677681
else
678682
seq_puts(s, ",noforceuid");
679683

680684
seq_printf(s, ",gid=%u",
681685
from_kgid_munged(&init_user_ns, cifs_sb->ctx->linux_gid));
682-
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID)
686+
if (sbflags & CIFS_MOUNT_OVERR_GID)
683687
seq_puts(s, ",forcegid");
684688
else
685689
seq_puts(s, ",noforcegid");
@@ -722,53 +726,53 @@ cifs_show_options(struct seq_file *s, struct dentry *root)
722726
seq_puts(s, ",unix");
723727
else
724728
seq_puts(s, ",nounix");
725-
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_DFS)
729+
if (sbflags & CIFS_MOUNT_NO_DFS)
726730
seq_puts(s, ",nodfs");
727-
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS)
731+
if (sbflags & CIFS_MOUNT_POSIX_PATHS)
728732
seq_puts(s, ",posixpaths");
729-
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID)
733+
if (sbflags & CIFS_MOUNT_SET_UID)
730734
seq_puts(s, ",setuids");
731-
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UID_FROM_ACL)
735+
if (sbflags & CIFS_MOUNT_UID_FROM_ACL)
732736
seq_puts(s, ",idsfromsid");
733-
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)
737+
if (sbflags & CIFS_MOUNT_SERVER_INUM)
734738
seq_puts(s, ",serverino");
735-
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD)
739+
if (sbflags & CIFS_MOUNT_RWPIDFORWARD)
736740
seq_puts(s, ",rwpidforward");
737-
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL)
741+
if (sbflags & CIFS_MOUNT_NOPOSIXBRL)
738742
seq_puts(s, ",forcemand");
739-
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
743+
if (sbflags & CIFS_MOUNT_NO_XATTR)
740744
seq_puts(s, ",nouser_xattr");
741-
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR)
745+
if (sbflags & CIFS_MOUNT_MAP_SPECIAL_CHR)
742746
seq_puts(s, ",mapchars");
743-
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SFM_CHR)
747+
if (sbflags & CIFS_MOUNT_MAP_SFM_CHR)
744748
seq_puts(s, ",mapposix");
745-
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL)
749+
if (sbflags & CIFS_MOUNT_UNX_EMUL)
746750
seq_puts(s, ",sfu");
747-
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL)
751+
if (sbflags & CIFS_MOUNT_NO_BRL)
748752
seq_puts(s, ",nobrl");
749-
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_HANDLE_CACHE)
753+
if (sbflags & CIFS_MOUNT_NO_HANDLE_CACHE)
750754
seq_puts(s, ",nohandlecache");
751-
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MODE_FROM_SID)
755+
if (sbflags & CIFS_MOUNT_MODE_FROM_SID)
752756
seq_puts(s, ",modefromsid");
753-
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL)
757+
if (sbflags & CIFS_MOUNT_CIFS_ACL)
754758
seq_puts(s, ",cifsacl");
755-
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DYNPERM)
759+
if (sbflags & CIFS_MOUNT_DYNPERM)
756760
seq_puts(s, ",dynperm");
757761
if (root->d_sb->s_flags & SB_POSIXACL)
758762
seq_puts(s, ",acl");
759-
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MF_SYMLINKS)
763+
if (sbflags & CIFS_MOUNT_MF_SYMLINKS)
760764
seq_puts(s, ",mfsymlinks");
761-
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_FSCACHE)
765+
if (sbflags & CIFS_MOUNT_FSCACHE)
762766
seq_puts(s, ",fsc");
763-
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC)
767+
if (sbflags & CIFS_MOUNT_NOSSYNC)
764768
seq_puts(s, ",nostrictsync");
765-
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM)
769+
if (sbflags & CIFS_MOUNT_NO_PERM)
766770
seq_puts(s, ",noperm");
767-
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_BACKUPUID)
771+
if (sbflags & CIFS_MOUNT_CIFS_BACKUPUID)
768772
seq_printf(s, ",backupuid=%u",
769773
from_kuid_munged(&init_user_ns,
770774
cifs_sb->ctx->backupuid));
771-
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_BACKUPGID)
775+
if (sbflags & CIFS_MOUNT_CIFS_BACKUPGID)
772776
seq_printf(s, ",backupgid=%u",
773777
from_kgid_munged(&init_user_ns,
774778
cifs_sb->ctx->backupgid));
@@ -909,10 +913,10 @@ static int cifs_write_inode(struct inode *inode, struct writeback_control *wbc)
909913

910914
static int cifs_drop_inode(struct inode *inode)
911915
{
912-
struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
916+
unsigned int sbflags = cifs_sb_flags(CIFS_SB(inode));
913917

914918
/* no serverino => unconditional eviction */
915-
return !(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) ||
919+
return !(sbflags & CIFS_MOUNT_SERVER_INUM) ||
916920
inode_generic_drop(inode);
917921
}
918922

@@ -950,7 +954,7 @@ cifs_get_root(struct smb3_fs_context *ctx, struct super_block *sb)
950954
char *s, *p;
951955
char sep;
952956

953-
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH)
957+
if (cifs_sb_flags(cifs_sb) & CIFS_MOUNT_USE_PREFIX_PATH)
954958
return dget(sb->s_root);
955959

956960
full_path = cifs_build_path_to_root(ctx, cifs_sb,

0 commit comments

Comments
 (0)