cifs: fix double-fault crash during ntlmssp

The crash occurred because we were calling memzero_explicit() on an
already freed sess_data::iov[1] (ntlmsspblob) in sess_free_buffer().

Fix this by not calling memzero_explicit() on sess_data::iov[1] as
it's already by handled by callers.

Fixes: a4e430c8c8ba ("cifs: replace kfree() with kfree_sensitive() for sensitive data")
Reviewed-by: Enzo Matsumiya <ematsumiya@suse.de>
Signed-off-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
Signed-off-by: Steve French <stfrench@microsoft.com>

authored by

Paulo Alcantara and committed by
Steve French
b854b4ee a9e17d3d

+9 -7
+9 -7
fs/cifs/sess.c
··· 1208 1208 static void 1209 1209 sess_free_buffer(struct sess_data *sess_data) 1210 1210 { 1211 - int i; 1211 + struct kvec *iov = sess_data->iov; 1212 1212 1213 - /* zero the session data before freeing, as it might contain sensitive info (keys, etc) */ 1214 - for (i = 0; i < 3; i++) 1215 - if (sess_data->iov[i].iov_base) 1216 - memzero_explicit(sess_data->iov[i].iov_base, sess_data->iov[i].iov_len); 1213 + /* 1214 + * Zero the session data before freeing, as it might contain sensitive info (keys, etc). 1215 + * Note that iov[1] is already freed by caller. 1216 + */ 1217 + if (sess_data->buf0_type != CIFS_NO_BUFFER && iov[0].iov_base) 1218 + memzero_explicit(iov[0].iov_base, iov[0].iov_len); 1217 1219 1218 - free_rsp_buf(sess_data->buf0_type, sess_data->iov[0].iov_base); 1220 + free_rsp_buf(sess_data->buf0_type, iov[0].iov_base); 1219 1221 sess_data->buf0_type = CIFS_NO_BUFFER; 1220 - kfree(sess_data->iov[2].iov_base); 1222 + kfree_sensitive(iov[2].iov_base); 1221 1223 } 1222 1224 1223 1225 static int