diff options
author | Ronnie Sahlberg <lsahlber@redhat.com> | 2018-04-12 19:03:19 -0400 |
---|---|---|
committer | Steve French <smfrench@gmail.com> | 2018-04-12 21:32:50 -0400 |
commit | 91cb74f5142c14dd921ab2d064b7b128054f9fae (patch) | |
tree | 2b919132f80918392ddd2d518dade730a2d6d981 | |
parent | e19b2bc0790a1c25b226815ce132c06274b1ba87 (diff) |
cifs: Change SMB2_open to return an iov for the error parameter
Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: Steve French <smfrench@gmail.com>
Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com>
-rw-r--r-- | fs/cifs/smb2ops.c | 10 | ||||
-rw-r--r-- | fs/cifs/smb2pdu.c | 10 | ||||
-rw-r--r-- | fs/cifs/smb2proto.h | 2 |
3 files changed, 13 insertions, 9 deletions
diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index def84fed3571..b4ae932ea134 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c | |||
@@ -1451,6 +1451,7 @@ smb2_query_symlink(const unsigned int xid, struct cifs_tcon *tcon, | |||
1451 | __u8 oplock = SMB2_OPLOCK_LEVEL_NONE; | 1451 | __u8 oplock = SMB2_OPLOCK_LEVEL_NONE; |
1452 | struct cifs_open_parms oparms; | 1452 | struct cifs_open_parms oparms; |
1453 | struct cifs_fid fid; | 1453 | struct cifs_fid fid; |
1454 | struct kvec err_iov = {NULL, 0}; | ||
1454 | struct smb2_err_rsp *err_buf = NULL; | 1455 | struct smb2_err_rsp *err_buf = NULL; |
1455 | struct smb2_symlink_err_rsp *symlink; | 1456 | struct smb2_symlink_err_rsp *symlink; |
1456 | unsigned int sub_len; | 1457 | unsigned int sub_len; |
@@ -1473,15 +1474,16 @@ smb2_query_symlink(const unsigned int xid, struct cifs_tcon *tcon, | |||
1473 | oparms.fid = &fid; | 1474 | oparms.fid = &fid; |
1474 | oparms.reconnect = false; | 1475 | oparms.reconnect = false; |
1475 | 1476 | ||
1476 | rc = SMB2_open(xid, &oparms, utf16_path, &oplock, NULL, &err_buf); | 1477 | rc = SMB2_open(xid, &oparms, utf16_path, &oplock, NULL, &err_iov); |
1477 | 1478 | ||
1478 | if (!rc || !err_buf) { | 1479 | if (!rc || !err_buf) { |
1479 | kfree(utf16_path); | 1480 | kfree(utf16_path); |
1480 | return -ENOENT; | 1481 | return -ENOENT; |
1481 | } | 1482 | } |
1482 | 1483 | ||
1484 | err_buf = err_iov.iov_base; | ||
1483 | if (le32_to_cpu(err_buf->ByteCount) < sizeof(struct smb2_symlink_err_rsp) || | 1485 | if (le32_to_cpu(err_buf->ByteCount) < sizeof(struct smb2_symlink_err_rsp) || |
1484 | get_rfc1002_length(err_buf) + server->vals->header_preamble_size < SMB2_SYMLINK_STRUCT_SIZE) { | 1486 | err_iov.iov_len + server->vals->header_preamble_size < SMB2_SYMLINK_STRUCT_SIZE) { |
1485 | kfree(utf16_path); | 1487 | kfree(utf16_path); |
1486 | return -ENOENT; | 1488 | return -ENOENT; |
1487 | } | 1489 | } |
@@ -1494,13 +1496,13 @@ smb2_query_symlink(const unsigned int xid, struct cifs_tcon *tcon, | |||
1494 | print_len = le16_to_cpu(symlink->PrintNameLength); | 1496 | print_len = le16_to_cpu(symlink->PrintNameLength); |
1495 | print_offset = le16_to_cpu(symlink->PrintNameOffset); | 1497 | print_offset = le16_to_cpu(symlink->PrintNameOffset); |
1496 | 1498 | ||
1497 | if (get_rfc1002_length(err_buf) + server->vals->header_preamble_size < | 1499 | if (err_iov.iov_len + server->vals->header_preamble_size < |
1498 | SMB2_SYMLINK_STRUCT_SIZE + sub_offset + sub_len) { | 1500 | SMB2_SYMLINK_STRUCT_SIZE + sub_offset + sub_len) { |
1499 | kfree(utf16_path); | 1501 | kfree(utf16_path); |
1500 | return -ENOENT; | 1502 | return -ENOENT; |
1501 | } | 1503 | } |
1502 | 1504 | ||
1503 | if (get_rfc1002_length(err_buf) + server->vals->header_preamble_size < | 1505 | if (err_iov.iov_len + server->vals->header_preamble_size < |
1504 | SMB2_SYMLINK_STRUCT_SIZE + print_offset + print_len) { | 1506 | SMB2_SYMLINK_STRUCT_SIZE + print_offset + print_len) { |
1505 | kfree(utf16_path); | 1507 | kfree(utf16_path); |
1506 | return -ENOENT; | 1508 | return -ENOENT; |
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index be44c5c3e77e..8a6921ef2ce1 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c | |||
@@ -1807,7 +1807,7 @@ alloc_path_with_tree_prefix(__le16 **out_path, int *out_size, int *out_len, | |||
1807 | int | 1807 | int |
1808 | SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path, | 1808 | SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path, |
1809 | __u8 *oplock, struct smb2_file_all_info *buf, | 1809 | __u8 *oplock, struct smb2_file_all_info *buf, |
1810 | struct smb2_err_rsp **err_buf) | 1810 | struct kvec *err_iov) |
1811 | { | 1811 | { |
1812 | struct smb2_create_req *req; | 1812 | struct smb2_create_req *req; |
1813 | struct smb2_create_rsp *rsp; | 1813 | struct smb2_create_rsp *rsp; |
@@ -1947,9 +1947,11 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path, | |||
1947 | 1947 | ||
1948 | if (rc != 0) { | 1948 | if (rc != 0) { |
1949 | cifs_stats_fail_inc(tcon, SMB2_CREATE_HE); | 1949 | cifs_stats_fail_inc(tcon, SMB2_CREATE_HE); |
1950 | if (err_buf && rsp) | 1950 | if (err_iov && rsp) { |
1951 | *err_buf = kmemdup(rsp, get_rfc1002_length(rsp) + 4, | 1951 | *err_iov = rsp_iov; |
1952 | GFP_KERNEL); | 1952 | resp_buftype = CIFS_NO_BUFFER; |
1953 | rsp = NULL; | ||
1954 | } | ||
1953 | goto creat_exit; | 1955 | goto creat_exit; |
1954 | } | 1956 | } |
1955 | 1957 | ||
diff --git a/fs/cifs/smb2proto.h b/fs/cifs/smb2proto.h index cbcce3f7e86f..8ba24a95db71 100644 --- a/fs/cifs/smb2proto.h +++ b/fs/cifs/smb2proto.h | |||
@@ -122,7 +122,7 @@ extern int SMB2_tdis(const unsigned int xid, struct cifs_tcon *tcon); | |||
122 | extern int SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, | 122 | extern int SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, |
123 | __le16 *path, __u8 *oplock, | 123 | __le16 *path, __u8 *oplock, |
124 | struct smb2_file_all_info *buf, | 124 | struct smb2_file_all_info *buf, |
125 | struct smb2_err_rsp **err_buf); | 125 | struct kvec *err_iov); |
126 | extern int SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, | 126 | extern int SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, |
127 | u64 persistent_fid, u64 volatile_fid, u32 opcode, | 127 | u64 persistent_fid, u64 volatile_fid, u32 opcode, |
128 | bool is_fsctl, char *in_data, u32 indatalen, | 128 | bool is_fsctl, char *in_data, u32 indatalen, |