Skip to content

Commit c5f44a3

Browse files
Paulo Alcantarasmfrench
authored andcommitted
smb: client: make smb2_compound_op() return resp buffer on success
If @out_iov and @out_buftype are passed, then return compounded responses regardless whether the request failed or not. This will be useful for detecting reparse points on SMB2_CREATE responses as specified in MS-SMB2 2.2.14. No functional changes. Signed-off-by: Paulo Alcantara (SUSE) <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 8b4e285 commit c5f44a3

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

fs/smb/client/smb2inode.c

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,16 @@ struct cop_vars {
5252
* note: If cfile is passed, the reference to it is dropped here.
5353
* So make sure that you do not reuse cfile after return from this func.
5454
*
55-
* If passing @err_iov and @err_buftype, ensure to make them both large enough (>= 3) to hold all
56-
* error responses. Caller is also responsible for freeing them up.
55+
* If passing @out_iov and @out_buftype, ensure to make them both large enough
56+
* (>= 3) to hold all compounded responses. Caller is also responsible for
57+
* freeing them up with free_rsp_buf().
5758
*/
5859
static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,
5960
struct cifs_sb_info *cifs_sb, const char *full_path,
6061
__u32 desired_access, __u32 create_disposition, __u32 create_options,
6162
umode_t mode, void *ptr, int command, struct cifsFileInfo *cfile,
6263
__u8 **extbuf, size_t *extbuflen,
63-
struct kvec *err_iov, int *err_buftype)
64+
struct kvec *out_iov, int *out_buftype)
6465
{
6566
struct cop_vars *vars = NULL;
6667
struct kvec *rsp_iov;
@@ -529,9 +530,9 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,
529530
if (cfile)
530531
cifsFileInfo_put(cfile);
531532

532-
if (rc && err_iov && err_buftype) {
533-
memcpy(err_iov, rsp_iov, 3 * sizeof(*err_iov));
534-
memcpy(err_buftype, resp_buftype, 3 * sizeof(*err_buftype));
533+
if (out_iov && out_buftype) {
534+
memcpy(out_iov, rsp_iov, 3 * sizeof(*out_iov));
535+
memcpy(out_buftype, resp_buftype, 3 * sizeof(*out_buftype));
535536
} else {
536537
free_rsp_buf(resp_buftype[0], rsp_iov[0].iov_base);
537538
free_rsp_buf(resp_buftype[1], rsp_iov[1].iov_base);
@@ -550,8 +551,8 @@ int smb2_query_path_info(const unsigned int xid,
550551
__u32 create_options = 0;
551552
struct cifsFileInfo *cfile;
552553
struct cached_fid *cfid = NULL;
553-
struct kvec err_iov[3] = {};
554-
int err_buftype[3] = {};
554+
struct kvec out_iov[3] = {};
555+
int out_buftype[3] = {};
555556
bool islink;
556557
int rc, rc2;
557558

@@ -577,15 +578,15 @@ int smb2_query_path_info(const unsigned int xid,
577578
cifs_get_readable_path(tcon, full_path, &cfile);
578579
rc = smb2_compound_op(xid, tcon, cifs_sb, full_path, FILE_READ_ATTRIBUTES, FILE_OPEN,
579580
create_options, ACL_NO_MODE, data, SMB2_OP_QUERY_INFO, cfile,
580-
NULL, NULL, err_iov, err_buftype);
581+
NULL, NULL, out_iov, out_buftype);
581582
if (rc) {
582-
struct smb2_hdr *hdr = err_iov[0].iov_base;
583+
struct smb2_hdr *hdr = out_iov[0].iov_base;
583584

584-
if (unlikely(!hdr || err_buftype[0] == CIFS_NO_BUFFER))
585+
if (unlikely(!hdr || out_buftype[0] == CIFS_NO_BUFFER))
585586
goto out;
586587
if (rc == -EOPNOTSUPP && hdr->Command == SMB2_CREATE &&
587588
hdr->Status == STATUS_STOPPED_ON_SYMLINK) {
588-
rc = smb2_parse_symlink_response(cifs_sb, err_iov,
589+
rc = smb2_parse_symlink_response(cifs_sb, out_iov,
589590
&data->symlink_target);
590591
if (rc)
591592
goto out;
@@ -614,13 +615,12 @@ int smb2_query_path_info(const unsigned int xid,
614615
}
615616

616617
out:
617-
free_rsp_buf(err_buftype[0], err_iov[0].iov_base);
618-
free_rsp_buf(err_buftype[1], err_iov[1].iov_base);
619-
free_rsp_buf(err_buftype[2], err_iov[2].iov_base);
618+
free_rsp_buf(out_buftype[0], out_iov[0].iov_base);
619+
free_rsp_buf(out_buftype[1], out_iov[1].iov_base);
620+
free_rsp_buf(out_buftype[2], out_iov[2].iov_base);
620621
return rc;
621622
}
622623

623-
624624
int smb311_posix_query_path_info(const unsigned int xid,
625625
struct cifs_tcon *tcon,
626626
struct cifs_sb_info *cifs_sb,
@@ -632,8 +632,8 @@ int smb311_posix_query_path_info(const unsigned int xid,
632632
int rc;
633633
__u32 create_options = 0;
634634
struct cifsFileInfo *cfile;
635-
struct kvec err_iov[3] = {};
636-
int err_buftype[3] = {};
635+
struct kvec out_iov[3] = {};
636+
int out_buftype[3] = {};
637637
__u8 *sidsbuf = NULL;
638638
__u8 *sidsbuf_end = NULL;
639639
size_t sidsbuflen = 0;
@@ -652,13 +652,13 @@ int smb311_posix_query_path_info(const unsigned int xid,
652652
cifs_get_readable_path(tcon, full_path, &cfile);
653653
rc = smb2_compound_op(xid, tcon, cifs_sb, full_path, FILE_READ_ATTRIBUTES, FILE_OPEN,
654654
create_options, ACL_NO_MODE, data, SMB2_OP_POSIX_QUERY_INFO, cfile,
655-
&sidsbuf, &sidsbuflen, err_iov, err_buftype);
655+
&sidsbuf, &sidsbuflen, out_iov, out_buftype);
656656
if (rc == -EOPNOTSUPP) {
657657
/* BB TODO: When support for special files added to Samba re-verify this path */
658-
if (err_iov[0].iov_base && err_buftype[0] != CIFS_NO_BUFFER &&
659-
((struct smb2_hdr *)err_iov[0].iov_base)->Command == SMB2_CREATE &&
660-
((struct smb2_hdr *)err_iov[0].iov_base)->Status == STATUS_STOPPED_ON_SYMLINK) {
661-
rc = smb2_parse_symlink_response(cifs_sb, err_iov, &data->symlink_target);
658+
if (out_iov[0].iov_base && out_buftype[0] != CIFS_NO_BUFFER &&
659+
((struct smb2_hdr *)out_iov[0].iov_base)->Command == SMB2_CREATE &&
660+
((struct smb2_hdr *)out_iov[0].iov_base)->Status == STATUS_STOPPED_ON_SYMLINK) {
661+
rc = smb2_parse_symlink_response(cifs_sb, out_iov, &data->symlink_target);
662662
if (rc)
663663
goto out;
664664
}
@@ -694,9 +694,9 @@ int smb311_posix_query_path_info(const unsigned int xid,
694694

695695
out:
696696
kfree(sidsbuf);
697-
free_rsp_buf(err_buftype[0], err_iov[0].iov_base);
698-
free_rsp_buf(err_buftype[1], err_iov[1].iov_base);
699-
free_rsp_buf(err_buftype[2], err_iov[2].iov_base);
697+
free_rsp_buf(out_buftype[0], out_iov[0].iov_base);
698+
free_rsp_buf(out_buftype[1], out_iov[1].iov_base);
699+
free_rsp_buf(out_buftype[2], out_iov[2].iov_base);
700700
return rc;
701701
}
702702

0 commit comments

Comments
 (0)