Skip to content

Commit

Permalink
tls: Correct length of scatterlist in tls_sw_sendpage
Browse files Browse the repository at this point in the history
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: Dave Watson <davejwatson@fb.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Dave Watson authored and David S. Miller committed Jan 22, 2018
1 parent 52acf06 commit 7a8c4dd
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions net/tls/tls_sw.c
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,8 @@ int tls_sw_sendpage(struct sock *sk, struct page *page,
get_page(page);
sg = ctx->sg_plaintext_data + ctx->sg_plaintext_num_elem;
sg_set_page(sg, page, copy, offset);
sg_unmark_end(sg);

ctx->sg_plaintext_num_elem++;

sk_mem_charge(sk, copy);
Expand Down

0 comments on commit 7a8c4dd

Please sign in to comment.