Skip to content

Commit ccda3c4

Browse files
committed
Merge tag '4.17-rc4-SMB3-Fixes' of git://git.samba.org/sfrench/cifs-2.6
Pull cifs fixes from Steve French: "Some small SMB3 fixes for 4.17-rc5, some for stable" * tag '4.17-rc4-SMB3-Fixes' of git://git.samba.org/sfrench/cifs-2.6: smb3: directory sync should not return an error cifs: smb2ops: Fix listxattr() when there are no EAs cifs: smbd: Enable signing with smbdirect cifs: Allocate validate negotiation request through kmalloc
2 parents 427fbe8 + 6e70c26 commit ccda3c4

File tree

4 files changed

+57
-43
lines changed

4 files changed

+57
-43
lines changed

fs/cifs/cifsfs.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,6 +1047,18 @@ ssize_t cifs_file_copychunk_range(unsigned int xid,
10471047
return rc;
10481048
}
10491049

1050+
/*
1051+
* Directory operations under CIFS/SMB2/SMB3 are synchronous, so fsync()
1052+
* is a dummy operation.
1053+
*/
1054+
static int cifs_dir_fsync(struct file *file, loff_t start, loff_t end, int datasync)
1055+
{
1056+
cifs_dbg(FYI, "Sync directory - name: %pD datasync: 0x%x\n",
1057+
file, datasync);
1058+
1059+
return 0;
1060+
}
1061+
10501062
static ssize_t cifs_copy_file_range(struct file *src_file, loff_t off,
10511063
struct file *dst_file, loff_t destoff,
10521064
size_t len, unsigned int flags)
@@ -1181,6 +1193,7 @@ const struct file_operations cifs_dir_ops = {
11811193
.copy_file_range = cifs_copy_file_range,
11821194
.clone_file_range = cifs_clone_file_range,
11831195
.llseek = generic_file_llseek,
1196+
.fsync = cifs_dir_fsync,
11841197
};
11851198

11861199
static void

fs/cifs/connect.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1977,14 +1977,6 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
19771977
goto cifs_parse_mount_err;
19781978
}
19791979

1980-
#ifdef CONFIG_CIFS_SMB_DIRECT
1981-
if (vol->rdma && vol->sign) {
1982-
cifs_dbg(VFS, "Currently SMB direct doesn't support signing."
1983-
" This is being fixed\n");
1984-
goto cifs_parse_mount_err;
1985-
}
1986-
#endif
1987-
19881980
#ifndef CONFIG_KEYS
19891981
/* Muliuser mounts require CONFIG_KEYS support */
19901982
if (vol->multiuser) {

fs/cifs/smb2ops.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,9 +589,15 @@ smb2_query_eas(const unsigned int xid, struct cifs_tcon *tcon,
589589

590590
SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);
591591

592+
/*
593+
* If ea_name is NULL (listxattr) and there are no EAs, return 0 as it's
594+
* not an error. Otherwise, the specified ea_name was not found.
595+
*/
592596
if (!rc)
593597
rc = move_smb2_ea_to_cifs(ea_data, buf_size, smb2_data,
594598
SMB2_MAX_EA_BUF, ea_name);
599+
else if (!ea_name && rc == -ENODATA)
600+
rc = 0;
595601

596602
kfree(smb2_data);
597603
return rc;

fs/cifs/smb2pdu.c

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -730,19 +730,14 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses)
730730

731731
int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon)
732732
{
733-
int rc = 0;
734-
struct validate_negotiate_info_req vneg_inbuf;
733+
int rc;
734+
struct validate_negotiate_info_req *pneg_inbuf;
735735
struct validate_negotiate_info_rsp *pneg_rsp = NULL;
736736
u32 rsplen;
737737
u32 inbuflen; /* max of 4 dialects */
738738

739739
cifs_dbg(FYI, "validate negotiate\n");
740740

741-
#ifdef CONFIG_CIFS_SMB_DIRECT
742-
if (tcon->ses->server->rdma)
743-
return 0;
744-
#endif
745-
746741
/* In SMB3.11 preauth integrity supersedes validate negotiate */
747742
if (tcon->ses->server->dialect == SMB311_PROT_ID)
748743
return 0;
@@ -765,63 +760,69 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon)
765760
if (tcon->ses->session_flags & SMB2_SESSION_FLAG_IS_NULL)
766761
cifs_dbg(VFS, "Unexpected null user (anonymous) auth flag sent by server\n");
767762

768-
vneg_inbuf.Capabilities =
763+
pneg_inbuf = kmalloc(sizeof(*pneg_inbuf), GFP_NOFS);
764+
if (!pneg_inbuf)
765+
return -ENOMEM;
766+
767+
pneg_inbuf->Capabilities =
769768
cpu_to_le32(tcon->ses->server->vals->req_capabilities);
770-
memcpy(vneg_inbuf.Guid, tcon->ses->server->client_guid,
769+
memcpy(pneg_inbuf->Guid, tcon->ses->server->client_guid,
771770
SMB2_CLIENT_GUID_SIZE);
772771

773772
if (tcon->ses->sign)
774-
vneg_inbuf.SecurityMode =
773+
pneg_inbuf->SecurityMode =
775774
cpu_to_le16(SMB2_NEGOTIATE_SIGNING_REQUIRED);
776775
else if (global_secflags & CIFSSEC_MAY_SIGN)
777-
vneg_inbuf.SecurityMode =
776+
pneg_inbuf->SecurityMode =
778777
cpu_to_le16(SMB2_NEGOTIATE_SIGNING_ENABLED);
779778
else
780-
vneg_inbuf.SecurityMode = 0;
779+
pneg_inbuf->SecurityMode = 0;
781780

782781

783782
if (strcmp(tcon->ses->server->vals->version_string,
784783
SMB3ANY_VERSION_STRING) == 0) {
785-
vneg_inbuf.Dialects[0] = cpu_to_le16(SMB30_PROT_ID);
786-
vneg_inbuf.Dialects[1] = cpu_to_le16(SMB302_PROT_ID);
787-
vneg_inbuf.DialectCount = cpu_to_le16(2);
784+
pneg_inbuf->Dialects[0] = cpu_to_le16(SMB30_PROT_ID);
785+
pneg_inbuf->Dialects[1] = cpu_to_le16(SMB302_PROT_ID);
786+
pneg_inbuf->DialectCount = cpu_to_le16(2);
788787
/* structure is big enough for 3 dialects, sending only 2 */
789-
inbuflen = sizeof(struct validate_negotiate_info_req) - 2;
788+
inbuflen = sizeof(*pneg_inbuf) -
789+
sizeof(pneg_inbuf->Dialects[0]);
790790
} else if (strcmp(tcon->ses->server->vals->version_string,
791791
SMBDEFAULT_VERSION_STRING) == 0) {
792-
vneg_inbuf.Dialects[0] = cpu_to_le16(SMB21_PROT_ID);
793-
vneg_inbuf.Dialects[1] = cpu_to_le16(SMB30_PROT_ID);
794-
vneg_inbuf.Dialects[2] = cpu_to_le16(SMB302_PROT_ID);
795-
vneg_inbuf.DialectCount = cpu_to_le16(3);
792+
pneg_inbuf->Dialects[0] = cpu_to_le16(SMB21_PROT_ID);
793+
pneg_inbuf->Dialects[1] = cpu_to_le16(SMB30_PROT_ID);
794+
pneg_inbuf->Dialects[2] = cpu_to_le16(SMB302_PROT_ID);
795+
pneg_inbuf->DialectCount = cpu_to_le16(3);
796796
/* structure is big enough for 3 dialects */
797-
inbuflen = sizeof(struct validate_negotiate_info_req);
797+
inbuflen = sizeof(*pneg_inbuf);
798798
} else {
799799
/* otherwise specific dialect was requested */
800-
vneg_inbuf.Dialects[0] =
800+
pneg_inbuf->Dialects[0] =
801801
cpu_to_le16(tcon->ses->server->vals->protocol_id);
802-
vneg_inbuf.DialectCount = cpu_to_le16(1);
802+
pneg_inbuf->DialectCount = cpu_to_le16(1);
803803
/* structure is big enough for 3 dialects, sending only 1 */
804-
inbuflen = sizeof(struct validate_negotiate_info_req) - 4;
804+
inbuflen = sizeof(*pneg_inbuf) -
805+
sizeof(pneg_inbuf->Dialects[0]) * 2;
805806
}
806807

807808
rc = SMB2_ioctl(xid, tcon, NO_FILE_ID, NO_FILE_ID,
808809
FSCTL_VALIDATE_NEGOTIATE_INFO, true /* is_fsctl */,
809-
(char *)&vneg_inbuf, sizeof(struct validate_negotiate_info_req),
810-
(char **)&pneg_rsp, &rsplen);
810+
(char *)pneg_inbuf, inbuflen, (char **)&pneg_rsp, &rsplen);
811811

812812
if (rc != 0) {
813813
cifs_dbg(VFS, "validate protocol negotiate failed: %d\n", rc);
814-
return -EIO;
814+
rc = -EIO;
815+
goto out_free_inbuf;
815816
}
816817

817-
if (rsplen != sizeof(struct validate_negotiate_info_rsp)) {
818+
rc = -EIO;
819+
if (rsplen != sizeof(*pneg_rsp)) {
818820
cifs_dbg(VFS, "invalid protocol negotiate response size: %d\n",
819821
rsplen);
820822

821823
/* relax check since Mac returns max bufsize allowed on ioctl */
822-
if ((rsplen > CIFSMaxBufSize)
823-
|| (rsplen < sizeof(struct validate_negotiate_info_rsp)))
824-
goto err_rsp_free;
824+
if (rsplen > CIFSMaxBufSize || rsplen < sizeof(*pneg_rsp))
825+
goto out_free_rsp;
825826
}
826827

827828
/* check validate negotiate info response matches what we got earlier */
@@ -838,15 +839,17 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon)
838839
goto vneg_out;
839840

840841
/* validate negotiate successful */
842+
rc = 0;
841843
cifs_dbg(FYI, "validate negotiate info successful\n");
842-
kfree(pneg_rsp);
843-
return 0;
844+
goto out_free_rsp;
844845

845846
vneg_out:
846847
cifs_dbg(VFS, "protocol revalidation - security settings mismatch\n");
847-
err_rsp_free:
848+
out_free_rsp:
848849
kfree(pneg_rsp);
849-
return -EIO;
850+
out_free_inbuf:
851+
kfree(pneg_inbuf);
852+
return rc;
850853
}
851854

852855
enum securityEnum

0 commit comments

Comments
 (0)