Skip to content

Commit 288b27a

Browse files
committed
Merge tag '5.6-rc1-smb3-fixes' of git://git.samba.org/sfrench/cifs-2.6
Pull cifs fixes from Steve French: "Four small CIFS/SMB3 fixes. One (the EA overflow fix) for stable" * tag '5.6-rc1-smb3-fixes' of git://git.samba.org/sfrench/cifs-2.6: cifs: make sure we do not overflow the max EA buffer size cifs: enable change notification for SMB2.1 dialect cifs: Fix mode output in debugging statements cifs: fix mount option display for sec=krb5i
2 parents 8a8b809 + 85db6b7 commit 288b27a

File tree

5 files changed

+44
-6
lines changed

5 files changed

+44
-6
lines changed

fs/cifs/cifsacl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ static void access_flags_to_mode(__le32 ace_flags, int type, umode_t *pmode,
601601
((flags & FILE_EXEC_RIGHTS) == FILE_EXEC_RIGHTS))
602602
*pmode |= (S_IXUGO & (*pbits_to_set));
603603

604-
cifs_dbg(NOISY, "access flags 0x%x mode now 0x%x\n", flags, *pmode);
604+
cifs_dbg(NOISY, "access flags 0x%x mode now %04o\n", flags, *pmode);
605605
return;
606606
}
607607

@@ -630,7 +630,7 @@ static void mode_to_access_flags(umode_t mode, umode_t bits_to_use,
630630
if (mode & S_IXUGO)
631631
*pace_flags |= SET_FILE_EXEC_RIGHTS;
632632

633-
cifs_dbg(NOISY, "mode: 0x%x, access flags now 0x%x\n",
633+
cifs_dbg(NOISY, "mode: %04o, access flags now 0x%x\n",
634634
mode, *pace_flags);
635635
return;
636636
}

fs/cifs/cifsfs.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ cifs_show_security(struct seq_file *s, struct cifs_ses *ses)
414414
seq_puts(s, "ntlm");
415415
break;
416416
case Kerberos:
417-
seq_printf(s, "krb5,cruid=%u", from_kuid_munged(&init_user_ns,ses->cred_uid));
417+
seq_puts(s, "krb5");
418418
break;
419419
case RawNTLMSSP:
420420
seq_puts(s, "ntlmssp");
@@ -427,6 +427,10 @@ cifs_show_security(struct seq_file *s, struct cifs_ses *ses)
427427

428428
if (ses->sign)
429429
seq_puts(s, "i");
430+
431+
if (ses->sectype == Kerberos)
432+
seq_printf(s, ",cruid=%u",
433+
from_kuid_munged(&init_user_ns, ses->cred_uid));
430434
}
431435

432436
static void

fs/cifs/connect.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4151,7 +4151,7 @@ int cifs_setup_cifs_sb(struct smb_vol *pvolume_info,
41514151
cifs_sb->mnt_gid = pvolume_info->linux_gid;
41524152
cifs_sb->mnt_file_mode = pvolume_info->file_mode;
41534153
cifs_sb->mnt_dir_mode = pvolume_info->dir_mode;
4154-
cifs_dbg(FYI, "file mode: 0x%hx dir mode: 0x%hx\n",
4154+
cifs_dbg(FYI, "file mode: %04ho dir mode: %04ho\n",
41554155
cifs_sb->mnt_file_mode, cifs_sb->mnt_dir_mode);
41564156

41574157
cifs_sb->actimeo = pvolume_info->actimeo;

fs/cifs/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1648,7 +1648,7 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, umode_t mode)
16481648
struct TCP_Server_Info *server;
16491649
char *full_path;
16501650

1651-
cifs_dbg(FYI, "In cifs_mkdir, mode = 0x%hx inode = 0x%p\n",
1651+
cifs_dbg(FYI, "In cifs_mkdir, mode = %04ho inode = 0x%p\n",
16521652
mode, inode);
16531653

16541654
cifs_sb = CIFS_SB(inode->i_sb);

fs/cifs/smb2ops.c

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1116,7 +1116,8 @@ smb2_set_ea(const unsigned int xid, struct cifs_tcon *tcon,
11161116
void *data[1];
11171117
struct smb2_file_full_ea_info *ea = NULL;
11181118
struct kvec close_iov[1];
1119-
int rc;
1119+
struct smb2_query_info_rsp *rsp;
1120+
int rc, used_len = 0;
11201121

11211122
if (smb3_encryption_required(tcon))
11221123
flags |= CIFS_TRANSFORM_REQ;
@@ -1139,6 +1140,38 @@ smb2_set_ea(const unsigned int xid, struct cifs_tcon *tcon,
11391140
cifs_sb);
11401141
if (rc == -ENODATA)
11411142
goto sea_exit;
1143+
} else {
1144+
/* If we are adding a attribute we should first check
1145+
* if there will be enough space available to store
1146+
* the new EA. If not we should not add it since we
1147+
* would not be able to even read the EAs back.
1148+
*/
1149+
rc = smb2_query_info_compound(xid, tcon, utf16_path,
1150+
FILE_READ_EA,
1151+
FILE_FULL_EA_INFORMATION,
1152+
SMB2_O_INFO_FILE,
1153+
CIFSMaxBufSize -
1154+
MAX_SMB2_CREATE_RESPONSE_SIZE -
1155+
MAX_SMB2_CLOSE_RESPONSE_SIZE,
1156+
&rsp_iov[1], &resp_buftype[1], cifs_sb);
1157+
if (rc == 0) {
1158+
rsp = (struct smb2_query_info_rsp *)rsp_iov[1].iov_base;
1159+
used_len = le32_to_cpu(rsp->OutputBufferLength);
1160+
}
1161+
free_rsp_buf(resp_buftype[1], rsp_iov[1].iov_base);
1162+
resp_buftype[1] = CIFS_NO_BUFFER;
1163+
memset(&rsp_iov[1], 0, sizeof(rsp_iov[1]));
1164+
rc = 0;
1165+
1166+
/* Use a fudge factor of 256 bytes in case we collide
1167+
* with a different set_EAs command.
1168+
*/
1169+
if(CIFSMaxBufSize - MAX_SMB2_CREATE_RESPONSE_SIZE -
1170+
MAX_SMB2_CLOSE_RESPONSE_SIZE - 256 <
1171+
used_len + ea_name_len + ea_value_len + 1) {
1172+
rc = -ENOSPC;
1173+
goto sea_exit;
1174+
}
11421175
}
11431176
}
11441177

@@ -4795,6 +4828,7 @@ struct smb_version_operations smb21_operations = {
47954828
.wp_retry_size = smb2_wp_retry_size,
47964829
.dir_needs_close = smb2_dir_needs_close,
47974830
.enum_snapshots = smb3_enum_snapshots,
4831+
.notify = smb3_notify,
47984832
.get_dfs_refer = smb2_get_dfs_refer,
47994833
.select_sectype = smb2_select_sectype,
48004834
#ifdef CONFIG_CIFS_XATTR

0 commit comments

Comments
 (0)