Skip to content

Commit 7a8c4dd

Browse files
Dave Watsondavem330
Dave Watson
authored andcommitted
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: Dave Watson <davejwatson@fb.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 52acf06 commit 7a8c4dd

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

net/tls/tls_sw.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,8 @@ int tls_sw_sendpage(struct sock *sk, struct page *page,
577577
get_page(page);
578578
sg = ctx->sg_plaintext_data + ctx->sg_plaintext_num_elem;
579579
sg_set_page(sg, page, copy, offset);
580+
sg_unmark_end(sg);
581+
580582
ctx->sg_plaintext_num_elem++;
581583

582584
sk_mem_charge(sk, copy);

0 commit comments

Comments
 (0)