Skip to content

Commit

Permalink
net/tls: Mark the end in scatterlist table
Browse files Browse the repository at this point in the history
Function zerocopy_from_iter() unmarks the 'end' in input sgtable while
adding new entries in it. The last entry in sgtable remained unmarked.
This results in KASAN error report on using apis like sg_nents(). Before
returning, the function needs to mark the 'end' in the last entry it
adds.

Signed-off-by: Vakul Garg <vakul.garg@nxp.com>
Acked-by: Dave Watson <davejwatson@fb.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Vakul Garg authored and David S. Miller committed Aug 6, 2018
1 parent 5f379ef commit cfb4099
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions net/tls/tls_sw.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,9 @@ static int zerocopy_from_iter(struct sock *sk, struct iov_iter *from,
}
}

/* Mark the end in the last sg entry if newly added */
if (num_elem > *pages_used)
sg_mark_end(&to[num_elem - 1]);
out:
if (rc)
iov_iter_revert(from, size - *size_used);
Expand Down

0 comments on commit cfb4099

Please sign in to comment.