@@ -884,7 +884,6 @@ smb2_set_ea(const unsigned int xid, struct cifs_tcon *tcon,
884
884
struct cifs_sb_info * cifs_sb )
885
885
{
886
886
struct cifs_ses * ses = tcon -> ses ;
887
- struct TCP_Server_Info * server = ses -> server ;
888
887
__le16 * utf16_path = NULL ;
889
888
int ea_name_len = strlen (ea_name );
890
889
int flags = 0 ;
@@ -936,7 +935,7 @@ smb2_set_ea(const unsigned int xid, struct cifs_tcon *tcon,
936
935
rc = SMB2_open_init (tcon , & rqst [0 ], & oplock , & oparms , utf16_path );
937
936
if (rc )
938
937
goto sea_exit ;
939
- smb2_set_next_command (ses -> server , & rqst [0 ], 0 );
938
+ smb2_set_next_command (tcon , & rqst [0 ]);
940
939
941
940
942
941
/* Set Info */
@@ -963,7 +962,7 @@ smb2_set_ea(const unsigned int xid, struct cifs_tcon *tcon,
963
962
COMPOUND_FID , current -> tgid ,
964
963
FILE_FULL_EA_INFORMATION ,
965
964
SMB2_O_INFO_FILE , 0 , data , size );
966
- smb2_set_next_command (server , & rqst [1 ], 0 );
965
+ smb2_set_next_command (tcon , & rqst [1 ]);
967
966
smb2_set_related (& rqst [1 ]);
968
967
969
968
@@ -1222,7 +1221,7 @@ smb2_ioctl_query_info(const unsigned int xid,
1222
1221
rc = SMB2_open_init (tcon , & rqst [0 ], & oplock , & oparms , path );
1223
1222
if (rc )
1224
1223
goto iqinf_exit ;
1225
- smb2_set_next_command (ses -> server , & rqst [0 ], 0 );
1224
+ smb2_set_next_command (tcon , & rqst [0 ]);
1226
1225
1227
1226
/* Query */
1228
1227
memset (& qi_iov , 0 , sizeof (qi_iov ));
@@ -1236,7 +1235,7 @@ smb2_ioctl_query_info(const unsigned int xid,
1236
1235
qi .output_buffer_length , buffer );
1237
1236
if (rc )
1238
1237
goto iqinf_exit ;
1239
- smb2_set_next_command (ses -> server , & rqst [1 ], 0 );
1238
+ smb2_set_next_command (tcon , & rqst [1 ]);
1240
1239
smb2_set_related (& rqst [1 ]);
1241
1240
1242
1241
/* Close */
@@ -1789,26 +1788,53 @@ smb2_set_related(struct smb_rqst *rqst)
1789
1788
char smb2_padding [7 ] = {0 , 0 , 0 , 0 , 0 , 0 , 0 };
1790
1789
1791
1790
void
1792
- smb2_set_next_command (struct TCP_Server_Info * server , struct smb_rqst * rqst ,
1793
- bool has_space_for_padding )
1791
+ smb2_set_next_command (struct cifs_tcon * tcon , struct smb_rqst * rqst )
1794
1792
{
1795
1793
struct smb2_sync_hdr * shdr ;
1794
+ struct cifs_ses * ses = tcon -> ses ;
1795
+ struct TCP_Server_Info * server = ses -> server ;
1796
1796
unsigned long len = smb_rqst_len (server , rqst );
1797
+ int i , num_padding ;
1797
1798
1798
1799
/* SMB headers in a compound are 8 byte aligned. */
1799
- if (len & 7 ) {
1800
- if (has_space_for_padding ) {
1801
- len = rqst -> rq_iov [rqst -> rq_nvec - 1 ].iov_len ;
1802
- rqst -> rq_iov [rqst -> rq_nvec - 1 ].iov_len =
1803
- (len + 7 ) & ~7 ;
1804
- } else {
1805
- rqst -> rq_iov [rqst -> rq_nvec ].iov_base = smb2_padding ;
1806
- rqst -> rq_iov [rqst -> rq_nvec ].iov_len = 8 - (len & 7 );
1807
- rqst -> rq_nvec ++ ;
1800
+
1801
+ /* No padding needed */
1802
+ if (!(len & 7 ))
1803
+ goto finished ;
1804
+
1805
+ num_padding = 8 - (len & 7 );
1806
+ if (!smb3_encryption_required (tcon )) {
1807
+ /*
1808
+ * If we do not have encryption then we can just add an extra
1809
+ * iov for the padding.
1810
+ */
1811
+ rqst -> rq_iov [rqst -> rq_nvec ].iov_base = smb2_padding ;
1812
+ rqst -> rq_iov [rqst -> rq_nvec ].iov_len = num_padding ;
1813
+ rqst -> rq_nvec ++ ;
1814
+ len += num_padding ;
1815
+ } else {
1816
+ /*
1817
+ * We can not add a small padding iov for the encryption case
1818
+ * because the encryption framework can not handle the padding
1819
+ * iovs.
1820
+ * We have to flatten this into a single buffer and add
1821
+ * the padding to it.
1822
+ */
1823
+ for (i = 1 ; i < rqst -> rq_nvec ; i ++ ) {
1824
+ memcpy (rqst -> rq_iov [0 ].iov_base +
1825
+ rqst -> rq_iov [0 ].iov_len ,
1826
+ rqst -> rq_iov [i ].iov_base ,
1827
+ rqst -> rq_iov [i ].iov_len );
1828
+ rqst -> rq_iov [0 ].iov_len += rqst -> rq_iov [i ].iov_len ;
1808
1829
}
1809
- len = smb_rqst_len (server , rqst );
1830
+ memset (rqst -> rq_iov [0 ].iov_base + rqst -> rq_iov [0 ].iov_len ,
1831
+ 0 , num_padding );
1832
+ rqst -> rq_iov [0 ].iov_len += num_padding ;
1833
+ len += num_padding ;
1834
+ rqst -> rq_nvec = 1 ;
1810
1835
}
1811
1836
1837
+ finished :
1812
1838
shdr = (struct smb2_sync_hdr * )(rqst -> rq_iov [0 ].iov_base );
1813
1839
shdr -> NextCommand = cpu_to_le32 (len );
1814
1840
}
@@ -1825,7 +1851,6 @@ smb2_query_info_compound(const unsigned int xid, struct cifs_tcon *tcon,
1825
1851
struct cifs_sb_info * cifs_sb )
1826
1852
{
1827
1853
struct cifs_ses * ses = tcon -> ses ;
1828
- struct TCP_Server_Info * server = ses -> server ;
1829
1854
int flags = 0 ;
1830
1855
struct smb_rqst rqst [3 ];
1831
1856
int resp_buftype [3 ];
@@ -1862,7 +1887,7 @@ smb2_query_info_compound(const unsigned int xid, struct cifs_tcon *tcon,
1862
1887
rc = SMB2_open_init (tcon , & rqst [0 ], & oplock , & oparms , utf16_path );
1863
1888
if (rc )
1864
1889
goto qic_exit ;
1865
- smb2_set_next_command (server , & rqst [0 ], 0 );
1890
+ smb2_set_next_command (tcon , & rqst [0 ]);
1866
1891
1867
1892
memset (& qi_iov , 0 , sizeof (qi_iov ));
1868
1893
rqst [1 ].rq_iov = qi_iov ;
@@ -1874,7 +1899,7 @@ smb2_query_info_compound(const unsigned int xid, struct cifs_tcon *tcon,
1874
1899
NULL );
1875
1900
if (rc )
1876
1901
goto qic_exit ;
1877
- smb2_set_next_command (server , & rqst [1 ], 0 );
1902
+ smb2_set_next_command (tcon , & rqst [1 ]);
1878
1903
smb2_set_related (& rqst [1 ]);
1879
1904
1880
1905
memset (& close_iov , 0 , sizeof (close_iov ));
@@ -2806,7 +2831,7 @@ init_sg(int num_rqst, struct smb_rqst *rqst, u8 *sign)
2806
2831
smb2_sg_set_buf (& sg [idx ++ ],
2807
2832
rqst [i ].rq_iov [j ].iov_base + skip ,
2808
2833
rqst [i ].rq_iov [j ].iov_len - skip );
2809
- }
2834
+ }
2810
2835
2811
2836
for (j = 0 ; j < rqst [i ].rq_npages ; j ++ ) {
2812
2837
unsigned int len , offset ;
0 commit comments