Skip to content

Commit b854b4e

Browse files
Paulo AlcantaraSteve French
authored andcommitted
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: a4e430c ("cifs: replace kfree() with kfree_sensitive() for sensitive data") Reviewed-by: Enzo Matsumiya <[email protected]> Signed-off-by: Paulo Alcantara (SUSE) <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent a9e17d3 commit b854b4e

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

fs/cifs/sess.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,16 +1208,18 @@ sess_alloc_buffer(struct sess_data *sess_data, int wct)
12081208
static void
12091209
sess_free_buffer(struct sess_data *sess_data)
12101210
{
1211-
int i;
1211+
struct kvec *iov = sess_data->iov;
12121212

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);
12171219

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);
12191221
sess_data->buf0_type = CIFS_NO_BUFFER;
1220-
kfree(sess_data->iov[2].iov_base);
1222+
kfree_sensitive(iov[2].iov_base);
12211223
}
12221224

12231225
static int

0 commit comments

Comments
 (0)