diff options
| author | Pavel Shilovsky <pshilov@microsoft.com> | 2016-10-31 16:49:30 -0400 |
|---|---|---|
| committer | Steve French <smfrench@gmail.com> | 2017-02-01 17:46:35 -0500 |
| commit | 7fb8986e7449d0a5cebd84d059927afa423fbf85 (patch) | |
| tree | 143981b02ed6afbb0dcbc22a344a1cd62451e3d4 /fs/cifs/smb2pdu.c | |
| parent | b8f57ee8aad414a3122bff72d7968a94baacb9b6 (diff) | |
CIFS: Add capability to transform requests before sending
This will allow us to do protocol specific tranformations of packets
before sending to the server. For SMB3 it can be used to support
encryption.
Signed-off-by: Pavel Shilovsky <pshilov@microsoft.com>
Diffstat (limited to 'fs/cifs/smb2pdu.c')
| -rw-r--r-- | fs/cifs/smb2pdu.c | 129 |
1 files changed, 104 insertions, 25 deletions
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index d1a90371b649..bf5b693412f0 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c | |||
| @@ -77,6 +77,13 @@ static const int smb2_req_struct_sizes[NUMBER_OF_SMB2_COMMANDS] = { | |||
| 77 | /* SMB2_OPLOCK_BREAK */ 24 /* BB this is 36 for LEASE_BREAK variant */ | 77 | /* SMB2_OPLOCK_BREAK */ 24 /* BB this is 36 for LEASE_BREAK variant */ |
| 78 | }; | 78 | }; |
| 79 | 79 | ||
| 80 | static int encryption_required(const struct cifs_tcon *tcon) | ||
| 81 | { | ||
| 82 | if ((tcon->ses->session_flags & SMB2_SESSION_FLAG_ENCRYPT_DATA) || | ||
| 83 | (tcon->share_flags & SHI1005_FLAGS_ENCRYPT_DATA)) | ||
| 84 | return 1; | ||
| 85 | return 0; | ||
| 86 | } | ||
| 80 | 87 | ||
| 81 | static void | 88 | static void |
| 82 | smb2_hdr_assemble(struct smb2_sync_hdr *shdr, __le16 smb2_cmd, | 89 | smb2_hdr_assemble(struct smb2_sync_hdr *shdr, __le16 smb2_cmd, |
| @@ -130,7 +137,8 @@ smb2_hdr_assemble(struct smb2_sync_hdr *shdr, __le16 smb2_cmd, | |||
| 130 | /* if (tcon->share_flags & SHI1005_FLAGS_DFS) | 137 | /* if (tcon->share_flags & SHI1005_FLAGS_DFS) |
| 131 | shdr->Flags |= SMB2_FLAGS_DFS_OPERATIONS; */ | 138 | shdr->Flags |= SMB2_FLAGS_DFS_OPERATIONS; */ |
| 132 | 139 | ||
| 133 | if (tcon->ses && tcon->ses->server && tcon->ses->server->sign) | 140 | if (tcon->ses && tcon->ses->server && tcon->ses->server->sign && |
| 141 | !encryption_required(tcon)) | ||
| 134 | shdr->Flags |= SMB2_FLAGS_SIGNED; | 142 | shdr->Flags |= SMB2_FLAGS_SIGNED; |
| 135 | out: | 143 | out: |
| 136 | return; | 144 | return; |
| @@ -423,7 +431,6 @@ static void assemble_neg_contexts(struct smb2_negotiate_req *req) | |||
| 423 | } | 431 | } |
| 424 | #endif /* SMB311 */ | 432 | #endif /* SMB311 */ |
| 425 | 433 | ||
| 426 | |||
| 427 | /* | 434 | /* |
| 428 | * | 435 | * |
| 429 | * SMB2 Worker functions follow: | 436 | * SMB2 Worker functions follow: |
| @@ -1070,6 +1077,7 @@ SMB2_logoff(const unsigned int xid, struct cifs_ses *ses) | |||
| 1070 | struct smb2_logoff_req *req; /* response is also trivial struct */ | 1077 | struct smb2_logoff_req *req; /* response is also trivial struct */ |
| 1071 | int rc = 0; | 1078 | int rc = 0; |
| 1072 | struct TCP_Server_Info *server; | 1079 | struct TCP_Server_Info *server; |
| 1080 | int flags = 0; | ||
| 1073 | 1081 | ||
| 1074 | cifs_dbg(FYI, "disconnect session %p\n", ses); | 1082 | cifs_dbg(FYI, "disconnect session %p\n", ses); |
| 1075 | 1083 | ||
| @@ -1088,10 +1096,13 @@ SMB2_logoff(const unsigned int xid, struct cifs_ses *ses) | |||
| 1088 | 1096 | ||
| 1089 | /* since no tcon, smb2_init can not do this, so do here */ | 1097 | /* since no tcon, smb2_init can not do this, so do here */ |
| 1090 | req->hdr.sync_hdr.SessionId = ses->Suid; | 1098 | req->hdr.sync_hdr.SessionId = ses->Suid; |
| 1091 | if (server->sign) | 1099 | |
| 1100 | if (ses->session_flags & SMB2_SESSION_FLAG_ENCRYPT_DATA) | ||
| 1101 | flags |= CIFS_TRANSFORM_REQ; | ||
| 1102 | else if (server->sign) | ||
| 1092 | req->hdr.sync_hdr.Flags |= SMB2_FLAGS_SIGNED; | 1103 | req->hdr.sync_hdr.Flags |= SMB2_FLAGS_SIGNED; |
| 1093 | 1104 | ||
| 1094 | rc = SendReceiveNoRsp(xid, ses, (char *) req, 0); | 1105 | rc = SendReceiveNoRsp(xid, ses, (char *) req, flags); |
| 1095 | cifs_small_buf_release(req); | 1106 | cifs_small_buf_release(req); |
| 1096 | /* | 1107 | /* |
| 1097 | * No tcon so can't do | 1108 | * No tcon so can't do |
| @@ -1130,6 +1141,7 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree, | |||
| 1130 | int unc_path_len; | 1141 | int unc_path_len; |
| 1131 | struct TCP_Server_Info *server; | 1142 | struct TCP_Server_Info *server; |
| 1132 | __le16 *unc_path = NULL; | 1143 | __le16 *unc_path = NULL; |
| 1144 | int flags = 0; | ||
| 1133 | 1145 | ||
| 1134 | cifs_dbg(FYI, "TCON\n"); | 1146 | cifs_dbg(FYI, "TCON\n"); |
| 1135 | 1147 | ||
| @@ -1164,6 +1176,9 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree, | |||
| 1164 | return rc; | 1176 | return rc; |
| 1165 | } | 1177 | } |
| 1166 | 1178 | ||
| 1179 | if (ses->session_flags & SMB2_SESSION_FLAG_ENCRYPT_DATA) | ||
| 1180 | flags |= CIFS_TRANSFORM_REQ; | ||
| 1181 | |||
| 1167 | if (tcon == NULL) { | 1182 | if (tcon == NULL) { |
| 1168 | /* since no tcon, smb2_init can not do this, so do here */ | 1183 | /* since no tcon, smb2_init can not do this, so do here */ |
| 1169 | req->hdr.sync_hdr.SessionId = ses->Suid; | 1184 | req->hdr.sync_hdr.SessionId = ses->Suid; |
| @@ -1184,7 +1199,7 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree, | |||
| 1184 | 1199 | ||
| 1185 | inc_rfc1001_len(req, unc_path_len - 1 /* pad */); | 1200 | inc_rfc1001_len(req, unc_path_len - 1 /* pad */); |
| 1186 | 1201 | ||
| 1187 | rc = SendReceive2(xid, ses, iov, 2, &resp_buftype, 0, &rsp_iov); | 1202 | rc = SendReceive2(xid, ses, iov, 2, &resp_buftype, flags, &rsp_iov); |
| 1188 | cifs_small_buf_release(req); | 1203 | cifs_small_buf_release(req); |
| 1189 | rsp = (struct smb2_tree_connect_rsp *)rsp_iov.iov_base; | 1204 | rsp = (struct smb2_tree_connect_rsp *)rsp_iov.iov_base; |
| 1190 | 1205 | ||
| @@ -1252,6 +1267,7 @@ SMB2_tdis(const unsigned int xid, struct cifs_tcon *tcon) | |||
| 1252 | int rc = 0; | 1267 | int rc = 0; |
| 1253 | struct TCP_Server_Info *server; | 1268 | struct TCP_Server_Info *server; |
| 1254 | struct cifs_ses *ses = tcon->ses; | 1269 | struct cifs_ses *ses = tcon->ses; |
| 1270 | int flags = 0; | ||
| 1255 | 1271 | ||
| 1256 | cifs_dbg(FYI, "Tree Disconnect\n"); | 1272 | cifs_dbg(FYI, "Tree Disconnect\n"); |
| 1257 | 1273 | ||
| @@ -1267,7 +1283,10 @@ SMB2_tdis(const unsigned int xid, struct cifs_tcon *tcon) | |||
| 1267 | if (rc) | 1283 | if (rc) |
| 1268 | return rc; | 1284 | return rc; |
| 1269 | 1285 | ||
| 1270 | rc = SendReceiveNoRsp(xid, ses, (char *)req, 0); | 1286 | if (encryption_required(tcon)) |
| 1287 | flags |= CIFS_TRANSFORM_REQ; | ||
| 1288 | |||
| 1289 | rc = SendReceiveNoRsp(xid, ses, (char *)req, flags); | ||
| 1271 | cifs_small_buf_release(req); | 1290 | cifs_small_buf_release(req); |
| 1272 | if (rc) | 1291 | if (rc) |
| 1273 | cifs_stats_fail_inc(tcon, SMB2_TREE_DISCONNECT_HE); | 1292 | cifs_stats_fail_inc(tcon, SMB2_TREE_DISCONNECT_HE); |
| @@ -1539,6 +1558,7 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path, | |||
| 1539 | unsigned int n_iov = 2; | 1558 | unsigned int n_iov = 2; |
| 1540 | __u32 file_attributes = 0; | 1559 | __u32 file_attributes = 0; |
| 1541 | char *dhc_buf = NULL, *lc_buf = NULL; | 1560 | char *dhc_buf = NULL, *lc_buf = NULL; |
| 1561 | int flags = 0; | ||
| 1542 | 1562 | ||
| 1543 | cifs_dbg(FYI, "create/open\n"); | 1563 | cifs_dbg(FYI, "create/open\n"); |
| 1544 | 1564 | ||
| @@ -1551,6 +1571,9 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path, | |||
| 1551 | if (rc) | 1571 | if (rc) |
| 1552 | return rc; | 1572 | return rc; |
| 1553 | 1573 | ||
| 1574 | if (encryption_required(tcon)) | ||
| 1575 | flags |= CIFS_TRANSFORM_REQ; | ||
| 1576 | |||
| 1554 | if (oparms->create_options & CREATE_OPTION_READONLY) | 1577 | if (oparms->create_options & CREATE_OPTION_READONLY) |
| 1555 | file_attributes |= ATTR_READONLY; | 1578 | file_attributes |= ATTR_READONLY; |
| 1556 | if (oparms->create_options & CREATE_OPTION_SPECIAL) | 1579 | if (oparms->create_options & CREATE_OPTION_SPECIAL) |
| @@ -1630,7 +1653,7 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path, | |||
| 1630 | dhc_buf = iov[n_iov-1].iov_base; | 1653 | dhc_buf = iov[n_iov-1].iov_base; |
| 1631 | } | 1654 | } |
| 1632 | 1655 | ||
| 1633 | rc = SendReceive2(xid, ses, iov, n_iov, &resp_buftype, 0, &rsp_iov); | 1656 | rc = SendReceive2(xid, ses, iov, n_iov, &resp_buftype, flags, &rsp_iov); |
| 1634 | cifs_small_buf_release(req); | 1657 | cifs_small_buf_release(req); |
| 1635 | rsp = (struct smb2_create_rsp *)rsp_iov.iov_base; | 1658 | rsp = (struct smb2_create_rsp *)rsp_iov.iov_base; |
| 1636 | 1659 | ||
| @@ -1684,6 +1707,7 @@ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, | |||
| 1684 | int resp_buftype; | 1707 | int resp_buftype; |
| 1685 | int n_iov; | 1708 | int n_iov; |
| 1686 | int rc = 0; | 1709 | int rc = 0; |
| 1710 | int flags = 0; | ||
| 1687 | 1711 | ||
| 1688 | cifs_dbg(FYI, "SMB2 IOCTL\n"); | 1712 | cifs_dbg(FYI, "SMB2 IOCTL\n"); |
| 1689 | 1713 | ||
| @@ -1708,6 +1732,9 @@ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, | |||
| 1708 | if (rc) | 1732 | if (rc) |
| 1709 | return rc; | 1733 | return rc; |
| 1710 | 1734 | ||
| 1735 | if (encryption_required(tcon)) | ||
| 1736 | flags |= CIFS_TRANSFORM_REQ; | ||
| 1737 | |||
| 1711 | req->CtlCode = cpu_to_le32(opcode); | 1738 | req->CtlCode = cpu_to_le32(opcode); |
| 1712 | req->PersistentFileId = persistent_fid; | 1739 | req->PersistentFileId = persistent_fid; |
| 1713 | req->VolatileFileId = volatile_fid; | 1740 | req->VolatileFileId = volatile_fid; |
| @@ -1758,7 +1785,7 @@ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, | |||
| 1758 | iov[0].iov_len = get_rfc1002_length(req) + 4; | 1785 | iov[0].iov_len = get_rfc1002_length(req) + 4; |
| 1759 | 1786 | ||
| 1760 | 1787 | ||
| 1761 | rc = SendReceive2(xid, ses, iov, n_iov, &resp_buftype, 0, &rsp_iov); | 1788 | rc = SendReceive2(xid, ses, iov, n_iov, &resp_buftype, flags, &rsp_iov); |
| 1762 | cifs_small_buf_release(req); | 1789 | cifs_small_buf_release(req); |
| 1763 | rsp = (struct smb2_ioctl_rsp *)rsp_iov.iov_base; | 1790 | rsp = (struct smb2_ioctl_rsp *)rsp_iov.iov_base; |
| 1764 | 1791 | ||
| @@ -1847,6 +1874,7 @@ SMB2_close(const unsigned int xid, struct cifs_tcon *tcon, | |||
| 1847 | struct kvec rsp_iov; | 1874 | struct kvec rsp_iov; |
| 1848 | int resp_buftype; | 1875 | int resp_buftype; |
| 1849 | int rc = 0; | 1876 | int rc = 0; |
| 1877 | int flags = 0; | ||
| 1850 | 1878 | ||
| 1851 | cifs_dbg(FYI, "Close\n"); | 1879 | cifs_dbg(FYI, "Close\n"); |
| 1852 | 1880 | ||
| @@ -1859,6 +1887,9 @@ SMB2_close(const unsigned int xid, struct cifs_tcon *tcon, | |||
| 1859 | if (rc) | 1887 | if (rc) |
| 1860 | return rc; | 1888 | return rc; |
| 1861 | 1889 | ||
| 1890 | if (encryption_required(tcon)) | ||
| 1891 | flags |= CIFS_TRANSFORM_REQ; | ||
| 1892 | |||
| 1862 | req->PersistentFileId = persistent_fid; | 1893 | req->PersistentFileId = persistent_fid; |
| 1863 | req->VolatileFileId = volatile_fid; | 1894 | req->VolatileFileId = volatile_fid; |
| 1864 | 1895 | ||
| @@ -1866,7 +1897,7 @@ SMB2_close(const unsigned int xid, struct cifs_tcon *tcon, | |||
| 1866 | /* 4 for rfc1002 length field */ | 1897 | /* 4 for rfc1002 length field */ |
| 1867 | iov[0].iov_len = get_rfc1002_length(req) + 4; | 1898 | iov[0].iov_len = get_rfc1002_length(req) + 4; |
| 1868 | 1899 | ||
| 1869 | rc = SendReceive2(xid, ses, iov, 1, &resp_buftype, 0, &rsp_iov); | 1900 | rc = SendReceive2(xid, ses, iov, 1, &resp_buftype, flags, &rsp_iov); |
| 1870 | cifs_small_buf_release(req); | 1901 | cifs_small_buf_release(req); |
| 1871 | rsp = (struct smb2_close_rsp *)rsp_iov.iov_base; | 1902 | rsp = (struct smb2_close_rsp *)rsp_iov.iov_base; |
| 1872 | 1903 | ||
| @@ -1952,6 +1983,7 @@ query_info(const unsigned int xid, struct cifs_tcon *tcon, | |||
| 1952 | int resp_buftype; | 1983 | int resp_buftype; |
| 1953 | struct TCP_Server_Info *server; | 1984 | struct TCP_Server_Info *server; |
| 1954 | struct cifs_ses *ses = tcon->ses; | 1985 | struct cifs_ses *ses = tcon->ses; |
| 1986 | int flags = 0; | ||
| 1955 | 1987 | ||
| 1956 | cifs_dbg(FYI, "Query Info\n"); | 1988 | cifs_dbg(FYI, "Query Info\n"); |
| 1957 | 1989 | ||
| @@ -1964,6 +1996,9 @@ query_info(const unsigned int xid, struct cifs_tcon *tcon, | |||
| 1964 | if (rc) | 1996 | if (rc) |
| 1965 | return rc; | 1997 | return rc; |
| 1966 | 1998 | ||
| 1999 | if (encryption_required(tcon)) | ||
| 2000 | flags |= CIFS_TRANSFORM_REQ; | ||
| 2001 | |||
| 1967 | req->InfoType = SMB2_O_INFO_FILE; | 2002 | req->InfoType = SMB2_O_INFO_FILE; |
| 1968 | req->FileInfoClass = info_class; | 2003 | req->FileInfoClass = info_class; |
| 1969 | req->PersistentFileId = persistent_fid; | 2004 | req->PersistentFileId = persistent_fid; |
| @@ -1977,7 +2012,7 @@ query_info(const unsigned int xid, struct cifs_tcon *tcon, | |||
| 1977 | /* 4 for rfc1002 length field */ | 2012 | /* 4 for rfc1002 length field */ |
| 1978 | iov[0].iov_len = get_rfc1002_length(req) + 4; | 2013 | iov[0].iov_len = get_rfc1002_length(req) + 4; |
| 1979 | 2014 | ||
| 1980 | rc = SendReceive2(xid, ses, iov, 1, &resp_buftype, 0, &rsp_iov); | 2015 | rc = SendReceive2(xid, ses, iov, 1, &resp_buftype, flags, &rsp_iov); |
| 1981 | cifs_small_buf_release(req); | 2016 | cifs_small_buf_release(req); |
| 1982 | rsp = (struct smb2_query_info_rsp *)rsp_iov.iov_base; | 2017 | rsp = (struct smb2_query_info_rsp *)rsp_iov.iov_base; |
| 1983 | 2018 | ||
| @@ -2137,6 +2172,7 @@ SMB2_flush(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, | |||
| 2137 | struct kvec rsp_iov; | 2172 | struct kvec rsp_iov; |
| 2138 | int resp_buftype; | 2173 | int resp_buftype; |
| 2139 | int rc = 0; | 2174 | int rc = 0; |
| 2175 | int flags = 0; | ||
| 2140 | 2176 | ||
| 2141 | cifs_dbg(FYI, "Flush\n"); | 2177 | cifs_dbg(FYI, "Flush\n"); |
| 2142 | 2178 | ||
| @@ -2149,6 +2185,9 @@ SMB2_flush(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, | |||
| 2149 | if (rc) | 2185 | if (rc) |
| 2150 | return rc; | 2186 | return rc; |
| 2151 | 2187 | ||
| 2188 | if (encryption_required(tcon)) | ||
| 2189 | flags |= CIFS_TRANSFORM_REQ; | ||
| 2190 | |||
| 2152 | req->PersistentFileId = persistent_fid; | 2191 | req->PersistentFileId = persistent_fid; |
| 2153 | req->VolatileFileId = volatile_fid; | 2192 | req->VolatileFileId = volatile_fid; |
| 2154 | 2193 | ||
| @@ -2156,7 +2195,7 @@ SMB2_flush(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, | |||
| 2156 | /* 4 for rfc1002 length field */ | 2195 | /* 4 for rfc1002 length field */ |
| 2157 | iov[0].iov_len = get_rfc1002_length(req) + 4; | 2196 | iov[0].iov_len = get_rfc1002_length(req) + 4; |
| 2158 | 2197 | ||
| 2159 | rc = SendReceive2(xid, ses, iov, 1, &resp_buftype, 0, &rsp_iov); | 2198 | rc = SendReceive2(xid, ses, iov, 1, &resp_buftype, flags, &rsp_iov); |
| 2160 | cifs_small_buf_release(req); | 2199 | cifs_small_buf_release(req); |
| 2161 | 2200 | ||
| 2162 | if (rc != 0) | 2201 | if (rc != 0) |
| @@ -2326,6 +2365,9 @@ smb2_async_readv(struct cifs_readdata *rdata) | |||
| 2326 | return rc; | 2365 | return rc; |
| 2327 | } | 2366 | } |
| 2328 | 2367 | ||
| 2368 | if (encryption_required(io_parms.tcon)) | ||
| 2369 | flags |= CIFS_TRANSFORM_REQ; | ||
| 2370 | |||
| 2329 | req_len = cpu_to_be32(total_len); | 2371 | req_len = cpu_to_be32(total_len); |
| 2330 | 2372 | ||
| 2331 | rdata->iov[0].iov_base = &req_len; | 2373 | rdata->iov[0].iov_base = &req_len; |
| @@ -2344,7 +2386,7 @@ smb2_async_readv(struct cifs_readdata *rdata) | |||
| 2344 | le16_to_cpu(shdr->CreditCharge); | 2386 | le16_to_cpu(shdr->CreditCharge); |
| 2345 | spin_unlock(&server->req_lock); | 2387 | spin_unlock(&server->req_lock); |
| 2346 | wake_up(&server->request_q); | 2388 | wake_up(&server->request_q); |
| 2347 | flags = CIFS_HAS_CREDITS; | 2389 | flags |= CIFS_HAS_CREDITS; |
| 2348 | } | 2390 | } |
| 2349 | 2391 | ||
| 2350 | kref_get(&rdata->refcount); | 2392 | kref_get(&rdata->refcount); |
| @@ -2374,12 +2416,17 @@ SMB2_read(const unsigned int xid, struct cifs_io_parms *io_parms, | |||
| 2374 | __be32 req_len; | 2416 | __be32 req_len; |
| 2375 | struct smb_rqst rqst = { .rq_iov = iov, | 2417 | struct smb_rqst rqst = { .rq_iov = iov, |
| 2376 | .rq_nvec = 2 }; | 2418 | .rq_nvec = 2 }; |
| 2419 | int flags = CIFS_LOG_ERROR; | ||
| 2420 | struct cifs_ses *ses = io_parms->tcon->ses; | ||
| 2377 | 2421 | ||
| 2378 | *nbytes = 0; | 2422 | *nbytes = 0; |
| 2379 | rc = smb2_new_read_req((void **)&req, &total_len, io_parms, 0, 0); | 2423 | rc = smb2_new_read_req((void **)&req, &total_len, io_parms, 0, 0); |
| 2380 | if (rc) | 2424 | if (rc) |
| 2381 | return rc; | 2425 | return rc; |
| 2382 | 2426 | ||
| 2427 | if (encryption_required(io_parms->tcon)) | ||
| 2428 | flags |= CIFS_TRANSFORM_REQ; | ||
| 2429 | |||
| 2383 | req_len = cpu_to_be32(total_len); | 2430 | req_len = cpu_to_be32(total_len); |
| 2384 | 2431 | ||
| 2385 | iov[0].iov_base = &req_len; | 2432 | iov[0].iov_base = &req_len; |
| @@ -2387,8 +2434,7 @@ SMB2_read(const unsigned int xid, struct cifs_io_parms *io_parms, | |||
| 2387 | iov[1].iov_base = req; | 2434 | iov[1].iov_base = req; |
| 2388 | iov[1].iov_len = total_len; | 2435 | iov[1].iov_len = total_len; |
| 2389 | 2436 | ||
| 2390 | rc = cifs_send_recv(xid, io_parms->tcon->ses, &rqst, &resp_buftype, | 2437 | rc = cifs_send_recv(xid, ses, &rqst, &resp_buftype, flags, &rsp_iov); |
| 2391 | CIFS_LOG_ERROR, &rsp_iov); | ||
| 2392 | cifs_small_buf_release(req); | 2438 | cifs_small_buf_release(req); |
| 2393 | 2439 | ||
| 2394 | rsp = (struct smb2_read_rsp *)rsp_iov.iov_base; | 2440 | rsp = (struct smb2_read_rsp *)rsp_iov.iov_base; |
| @@ -2507,6 +2553,9 @@ smb2_async_writev(struct cifs_writedata *wdata, | |||
| 2507 | goto async_writev_out; | 2553 | goto async_writev_out; |
| 2508 | } | 2554 | } |
| 2509 | 2555 | ||
| 2556 | if (encryption_required(tcon)) | ||
| 2557 | flags |= CIFS_TRANSFORM_REQ; | ||
| 2558 | |||
| 2510 | shdr = get_sync_hdr(req); | 2559 | shdr = get_sync_hdr(req); |
| 2511 | shdr->ProcessId = cpu_to_le32(wdata->cfile->pid); | 2560 | shdr->ProcessId = cpu_to_le32(wdata->cfile->pid); |
| 2512 | 2561 | ||
| @@ -2550,7 +2599,7 @@ smb2_async_writev(struct cifs_writedata *wdata, | |||
| 2550 | le16_to_cpu(shdr->CreditCharge); | 2599 | le16_to_cpu(shdr->CreditCharge); |
| 2551 | spin_unlock(&server->req_lock); | 2600 | spin_unlock(&server->req_lock); |
| 2552 | wake_up(&server->request_q); | 2601 | wake_up(&server->request_q); |
| 2553 | flags = CIFS_HAS_CREDITS; | 2602 | flags |= CIFS_HAS_CREDITS; |
| 2554 | } | 2603 | } |
| 2555 | 2604 | ||
| 2556 | kref_get(&wdata->refcount); | 2605 | kref_get(&wdata->refcount); |
| @@ -2582,6 +2631,7 @@ SMB2_write(const unsigned int xid, struct cifs_io_parms *io_parms, | |||
| 2582 | struct smb2_write_rsp *rsp = NULL; | 2631 | struct smb2_write_rsp *rsp = NULL; |
| 2583 | int resp_buftype; | 2632 | int resp_buftype; |
| 2584 | struct kvec rsp_iov; | 2633 | struct kvec rsp_iov; |
| 2634 | int flags = 0; | ||
| 2585 | 2635 | ||
| 2586 | *nbytes = 0; | 2636 | *nbytes = 0; |
| 2587 | 2637 | ||
| @@ -2595,6 +2645,9 @@ SMB2_write(const unsigned int xid, struct cifs_io_parms *io_parms, | |||
| 2595 | if (io_parms->tcon->ses->server == NULL) | 2645 | if (io_parms->tcon->ses->server == NULL) |
| 2596 | return -ECONNABORTED; | 2646 | return -ECONNABORTED; |
| 2597 | 2647 | ||
| 2648 | if (encryption_required(io_parms->tcon)) | ||
| 2649 | flags |= CIFS_TRANSFORM_REQ; | ||
| 2650 | |||
| 2598 | req->hdr.sync_hdr.ProcessId = cpu_to_le32(io_parms->pid); | 2651 | req->hdr.sync_hdr.ProcessId = cpu_to_le32(io_parms->pid); |
| 2599 | 2652 | ||
| 2600 | req->PersistentFileId = io_parms->persistent_fid; | 2653 | req->PersistentFileId = io_parms->persistent_fid; |
| @@ -2617,7 +2670,7 @@ SMB2_write(const unsigned int xid, struct cifs_io_parms *io_parms, | |||
| 2617 | inc_rfc1001_len(req, io_parms->length - 1 /* Buffer */); | 2670 | inc_rfc1001_len(req, io_parms->length - 1 /* Buffer */); |
| 2618 | 2671 | ||
| 2619 | rc = SendReceive2(xid, io_parms->tcon->ses, iov, n_vec + 1, | 2672 | rc = SendReceive2(xid, io_parms->tcon->ses, iov, n_vec + 1, |
| 2620 | &resp_buftype, 0, &rsp_iov); | 2673 | &resp_buftype, flags, &rsp_iov); |
| 2621 | cifs_small_buf_release(req); | 2674 | cifs_small_buf_release(req); |
| 2622 | rsp = (struct smb2_write_rsp *)rsp_iov.iov_base; | 2675 | rsp = (struct smb2_write_rsp *)rsp_iov.iov_base; |
| 2623 | 2676 | ||
| @@ -2693,6 +2746,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon, | |||
| 2693 | char *end_of_smb; | 2746 | char *end_of_smb; |
| 2694 | unsigned int output_size = CIFSMaxBufSize; | 2747 | unsigned int output_size = CIFSMaxBufSize; |
| 2695 | size_t info_buf_size; | 2748 | size_t info_buf_size; |
| 2749 | int flags = 0; | ||
| 2696 | 2750 | ||
| 2697 | if (ses && (ses->server)) | 2751 | if (ses && (ses->server)) |
| 2698 | server = ses->server; | 2752 | server = ses->server; |
| @@ -2703,6 +2757,9 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon, | |||
| 2703 | if (rc) | 2757 | if (rc) |
| 2704 | return rc; | 2758 | return rc; |
| 2705 | 2759 | ||
| 2760 | if (encryption_required(tcon)) | ||
| 2761 | flags |= CIFS_TRANSFORM_REQ; | ||
| 2762 | |||
| 2706 | switch (srch_inf->info_level) { | 2763 | switch (srch_inf->info_level) { |
| 2707 | case SMB_FIND_FILE_DIRECTORY_INFO: | 2764 | case SMB_FIND_FILE_DIRECTORY_INFO: |
| 2708 | req->FileInformationClass = FILE_DIRECTORY_INFORMATION; | 2765 | req->FileInformationClass = FILE_DIRECTORY_INFORMATION; |
| @@ -2747,7 +2804,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon, | |||
| 2747 | 2804 | ||
| 2748 | inc_rfc1001_len(req, len - 1 /* Buffer */); | 2805 | inc_rfc1001_len(req, len - 1 /* Buffer */); |
| 2749 | 2806 | ||
| 2750 | rc = SendReceive2(xid, ses, iov, 2, &resp_buftype, 0, &rsp_iov); | 2807 | rc = SendReceive2(xid, ses, iov, 2, &resp_buftype, flags, &rsp_iov); |
| 2751 | cifs_small_buf_release(req); | 2808 | cifs_small_buf_release(req); |
| 2752 | rsp = (struct smb2_query_directory_rsp *)rsp_iov.iov_base; | 2809 | rsp = (struct smb2_query_directory_rsp *)rsp_iov.iov_base; |
| 2753 | 2810 | ||
| @@ -2815,6 +2872,7 @@ send_set_info(const unsigned int xid, struct cifs_tcon *tcon, | |||
| 2815 | unsigned int i; | 2872 | unsigned int i; |
| 2816 | struct TCP_Server_Info *server; | 2873 | struct TCP_Server_Info *server; |
| 2817 | struct cifs_ses *ses = tcon->ses; | 2874 | struct cifs_ses *ses = tcon->ses; |
| 2875 | int flags = 0; | ||
| 2818 | 2876 | ||
| 2819 | if (ses && (ses->server)) | 2877 | if (ses && (ses->server)) |
| 2820 | server = ses->server; | 2878 | server = ses->server; |
| @@ -2834,6 +2892,9 @@ send_set_info(const unsigned int xid, struct cifs_tcon *tcon, | |||
| 2834 | return rc; | 2892 | return rc; |
| 2835 | } | 2893 | } |
| 2836 | 2894 | ||
| 2895 | if (encryption_required(tcon)) | ||
| 2896 | flags |= CIFS_TRANSFORM_REQ; | ||
| 2897 | |||
| 2837 | req->hdr.sync_hdr.ProcessId = cpu_to_le32(pid); | 2898 | req->hdr.sync_hdr.ProcessId = cpu_to_le32(pid); |
| 2838 | 2899 | ||
| 2839 | req->InfoType = SMB2_O_INFO_FILE; | 2900 | req->InfoType = SMB2_O_INFO_FILE; |
| @@ -2861,7 +2922,7 @@ send_set_info(const unsigned int xid, struct cifs_tcon *tcon, | |||
| 2861 | iov[i].iov_len = size[i]; | 2922 | iov[i].iov_len = size[i]; |
| 2862 | } | 2923 | } |
| 2863 | 2924 | ||
| 2864 | rc = SendReceive2(xid, ses, iov, num, &resp_buftype, 0, &rsp_iov); | 2925 | rc = SendReceive2(xid, ses, iov, num, &resp_buftype, flags, &rsp_iov); |
| 2865 | cifs_small_buf_release(req); | 2926 | cifs_small_buf_release(req); |
| 2866 | rsp = (struct smb2_set_info_rsp *)rsp_iov.iov_base; | 2927 | rsp = (struct smb2_set_info_rsp *)rsp_iov.iov_base; |
| 2867 | 2928 | ||
| @@ -2991,19 +3052,22 @@ SMB2_oplock_break(const unsigned int xid, struct cifs_tcon *tcon, | |||
| 2991 | { | 3052 | { |
| 2992 | int rc; | 3053 | int rc; |
| 2993 | struct smb2_oplock_break *req = NULL; | 3054 | struct smb2_oplock_break *req = NULL; |
| 3055 | int flags = CIFS_OBREAK_OP; | ||
| 2994 | 3056 | ||
| 2995 | cifs_dbg(FYI, "SMB2_oplock_break\n"); | 3057 | cifs_dbg(FYI, "SMB2_oplock_break\n"); |
| 2996 | rc = small_smb2_init(SMB2_OPLOCK_BREAK, tcon, (void **) &req); | 3058 | rc = small_smb2_init(SMB2_OPLOCK_BREAK, tcon, (void **) &req); |
| 2997 | |||
| 2998 | if (rc) | 3059 | if (rc) |
| 2999 | return rc; | 3060 | return rc; |
| 3000 | 3061 | ||
| 3062 | if (encryption_required(tcon)) | ||
| 3063 | flags |= CIFS_TRANSFORM_REQ; | ||
| 3064 | |||
| 3001 | req->VolatileFid = volatile_fid; | 3065 | req->VolatileFid = volatile_fid; |
| 3002 | req->PersistentFid = persistent_fid; | 3066 | req->PersistentFid = persistent_fid; |
| 3003 | req->OplockLevel = oplock_level; | 3067 | req->OplockLevel = oplock_level; |
| 3004 | req->hdr.sync_hdr.CreditRequest = cpu_to_le16(1); | 3068 | req->hdr.sync_hdr.CreditRequest = cpu_to_le16(1); |
| 3005 | 3069 | ||
| 3006 | rc = SendReceiveNoRsp(xid, tcon->ses, (char *) req, CIFS_OBREAK_OP); | 3070 | rc = SendReceiveNoRsp(xid, tcon->ses, (char *) req, flags); |
| 3007 | cifs_small_buf_release(req); | 3071 | cifs_small_buf_release(req); |
| 3008 | 3072 | ||
| 3009 | if (rc) { | 3073 | if (rc) { |
| @@ -3069,6 +3133,7 @@ SMB2_QFS_info(const unsigned int xid, struct cifs_tcon *tcon, | |||
| 3069 | int resp_buftype; | 3133 | int resp_buftype; |
| 3070 | struct cifs_ses *ses = tcon->ses; | 3134 | struct cifs_ses *ses = tcon->ses; |
| 3071 | struct smb2_fs_full_size_info *info = NULL; | 3135 | struct smb2_fs_full_size_info *info = NULL; |
| 3136 | int flags = 0; | ||
| 3072 | 3137 | ||
| 3073 | rc = build_qfs_info_req(&iov, tcon, FS_FULL_SIZE_INFORMATION, | 3138 | rc = build_qfs_info_req(&iov, tcon, FS_FULL_SIZE_INFORMATION, |
| 3074 | sizeof(struct smb2_fs_full_size_info), | 3139 | sizeof(struct smb2_fs_full_size_info), |
| @@ -3076,7 +3141,10 @@ SMB2_QFS_info(const unsigned int xid, struct cifs_tcon *tcon, | |||
| 3076 | if (rc) | 3141 | if (rc) |
| 3077 | return rc; | 3142 | return rc; |
| 3078 | 3143 | ||
| 3079 | rc = SendReceive2(xid, ses, &iov, 1, &resp_buftype, 0, &rsp_iov); | 3144 | if (encryption_required(tcon)) |
| 3145 | flags |= CIFS_TRANSFORM_REQ; | ||
| 3146 | |||
| 3147 | rc = SendReceive2(xid, ses, &iov, 1, &resp_buftype, flags, &rsp_iov); | ||
| 3080 | cifs_small_buf_release(iov.iov_base); | 3148 | cifs_small_buf_release(iov.iov_base); |
| 3081 | if (rc) { | 3149 | if (rc) { |
| 3082 | cifs_stats_fail_inc(tcon, SMB2_QUERY_INFO_HE); | 3150 | cifs_stats_fail_inc(tcon, SMB2_QUERY_INFO_HE); |
| @@ -3108,6 +3176,7 @@ SMB2_QFS_attr(const unsigned int xid, struct cifs_tcon *tcon, | |||
| 3108 | int resp_buftype, max_len, min_len; | 3176 | int resp_buftype, max_len, min_len; |
| 3109 | struct cifs_ses *ses = tcon->ses; | 3177 | struct cifs_ses *ses = tcon->ses; |
| 3110 | unsigned int rsp_len, offset; | 3178 | unsigned int rsp_len, offset; |
| 3179 | int flags = 0; | ||
| 3111 | 3180 | ||
| 3112 | if (level == FS_DEVICE_INFORMATION) { | 3181 | if (level == FS_DEVICE_INFORMATION) { |
| 3113 | max_len = sizeof(FILE_SYSTEM_DEVICE_INFO); | 3182 | max_len = sizeof(FILE_SYSTEM_DEVICE_INFO); |
| @@ -3128,7 +3197,10 @@ SMB2_QFS_attr(const unsigned int xid, struct cifs_tcon *tcon, | |||
| 3128 | if (rc) | 3197 | if (rc) |
| 3129 | return rc; | 3198 | return rc; |
| 3130 | 3199 | ||
| 3131 | rc = SendReceive2(xid, ses, &iov, 1, &resp_buftype, 0, &rsp_iov); | 3200 | if (encryption_required(tcon)) |
| 3201 | flags |= CIFS_TRANSFORM_REQ; | ||
| 3202 | |||
| 3203 | rc = SendReceive2(xid, ses, &iov, 1, &resp_buftype, flags, &rsp_iov); | ||
| 3132 | cifs_small_buf_release(iov.iov_base); | 3204 | cifs_small_buf_release(iov.iov_base); |
| 3133 | if (rc) { | 3205 | if (rc) { |
| 3134 | cifs_stats_fail_inc(tcon, SMB2_QUERY_INFO_HE); | 3206 | cifs_stats_fail_inc(tcon, SMB2_QUERY_INFO_HE); |
| @@ -3173,6 +3245,7 @@ smb2_lockv(const unsigned int xid, struct cifs_tcon *tcon, | |||
| 3173 | struct kvec rsp_iov; | 3245 | struct kvec rsp_iov; |
| 3174 | int resp_buf_type; | 3246 | int resp_buf_type; |
| 3175 | unsigned int count; | 3247 | unsigned int count; |
| 3248 | int flags = CIFS_NO_RESP; | ||
| 3176 | 3249 | ||
| 3177 | cifs_dbg(FYI, "smb2_lockv num lock %d\n", num_lock); | 3250 | cifs_dbg(FYI, "smb2_lockv num lock %d\n", num_lock); |
| 3178 | 3251 | ||
| @@ -3180,6 +3253,9 @@ smb2_lockv(const unsigned int xid, struct cifs_tcon *tcon, | |||
| 3180 | if (rc) | 3253 | if (rc) |
| 3181 | return rc; | 3254 | return rc; |
| 3182 | 3255 | ||
| 3256 | if (encryption_required(tcon)) | ||
| 3257 | flags |= CIFS_TRANSFORM_REQ; | ||
| 3258 | |||
| 3183 | req->hdr.sync_hdr.ProcessId = cpu_to_le32(pid); | 3259 | req->hdr.sync_hdr.ProcessId = cpu_to_le32(pid); |
| 3184 | req->LockCount = cpu_to_le16(num_lock); | 3260 | req->LockCount = cpu_to_le16(num_lock); |
| 3185 | 3261 | ||
| @@ -3196,7 +3272,7 @@ smb2_lockv(const unsigned int xid, struct cifs_tcon *tcon, | |||
| 3196 | iov[1].iov_len = count; | 3272 | iov[1].iov_len = count; |
| 3197 | 3273 | ||
| 3198 | cifs_stats_inc(&tcon->stats.cifs_stats.num_locks); | 3274 | cifs_stats_inc(&tcon->stats.cifs_stats.num_locks); |
| 3199 | rc = SendReceive2(xid, tcon->ses, iov, 2, &resp_buf_type, CIFS_NO_RESP, | 3275 | rc = SendReceive2(xid, tcon->ses, iov, 2, &resp_buf_type, flags, |
| 3200 | &rsp_iov); | 3276 | &rsp_iov); |
| 3201 | cifs_small_buf_release(req); | 3277 | cifs_small_buf_release(req); |
| 3202 | if (rc) { | 3278 | if (rc) { |
| @@ -3230,13 +3306,16 @@ SMB2_lease_break(const unsigned int xid, struct cifs_tcon *tcon, | |||
| 3230 | { | 3306 | { |
| 3231 | int rc; | 3307 | int rc; |
| 3232 | struct smb2_lease_ack *req = NULL; | 3308 | struct smb2_lease_ack *req = NULL; |
| 3309 | int flags = CIFS_OBREAK_OP; | ||
| 3233 | 3310 | ||
| 3234 | cifs_dbg(FYI, "SMB2_lease_break\n"); | 3311 | cifs_dbg(FYI, "SMB2_lease_break\n"); |
| 3235 | rc = small_smb2_init(SMB2_OPLOCK_BREAK, tcon, (void **) &req); | 3312 | rc = small_smb2_init(SMB2_OPLOCK_BREAK, tcon, (void **) &req); |
| 3236 | |||
| 3237 | if (rc) | 3313 | if (rc) |
| 3238 | return rc; | 3314 | return rc; |
| 3239 | 3315 | ||
| 3316 | if (encryption_required(tcon)) | ||
| 3317 | flags |= CIFS_TRANSFORM_REQ; | ||
| 3318 | |||
| 3240 | req->hdr.sync_hdr.CreditRequest = cpu_to_le16(1); | 3319 | req->hdr.sync_hdr.CreditRequest = cpu_to_le16(1); |
| 3241 | req->StructureSize = cpu_to_le16(36); | 3320 | req->StructureSize = cpu_to_le16(36); |
| 3242 | inc_rfc1001_len(req, 12); | 3321 | inc_rfc1001_len(req, 12); |
| @@ -3244,7 +3323,7 @@ SMB2_lease_break(const unsigned int xid, struct cifs_tcon *tcon, | |||
| 3244 | memcpy(req->LeaseKey, lease_key, 16); | 3323 | memcpy(req->LeaseKey, lease_key, 16); |
| 3245 | req->LeaseState = lease_state; | 3324 | req->LeaseState = lease_state; |
| 3246 | 3325 | ||
| 3247 | rc = SendReceiveNoRsp(xid, tcon->ses, (char *) req, CIFS_OBREAK_OP); | 3326 | rc = SendReceiveNoRsp(xid, tcon->ses, (char *) req, flags); |
| 3248 | cifs_small_buf_release(req); | 3327 | cifs_small_buf_release(req); |
| 3249 | 3328 | ||
| 3250 | if (rc) { | 3329 | if (rc) { |
