Commit 7a8c4dd9 authored by Dave Watson's avatar Dave Watson Committed by David S. Miller

tls: Correct length of scatterlist in tls_sw_sendpage

The scatterlist is reused by both sendmsg and sendfile.
If a sendmsg of smaller number of pages is followed by a sendfile
of larger number of pages, the scatterlist may be too short, resulting
in a crash in gcm_encrypt.

Add sg_unmark_end to make the list the correct length.

tls_sw_sendmsg already calls sg_unmark_end correctly when it allocates
memory in alloc_sg, or in zerocopy_from_iter.
Signed-off-by: default avatarDave Watson <>
Signed-off-by: default avatarDavid S. Miller <>
parent 52acf064
......@@ -577,6 +577,8 @@ int tls_sw_sendpage(struct sock *sk, struct page *page,
sg = ctx->sg_plaintext_data + ctx->sg_plaintext_num_elem;
sg_set_page(sg, page, copy, offset);
sk_mem_charge(sk, copy);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment