OSDN Git Service

net/tls: Mark the end in scatterlist table
authorVakul Garg <vakul.garg@nxp.com>
Thu, 2 Aug 2018 15:13:10 +0000 (20:43 +0530)
committerDavid S. Miller <davem@davemloft.net>
Mon, 6 Aug 2018 00:13:58 +0000 (17:13 -0700)
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>
net/tls/tls_sw.c

index ff3a690..83d67df 100644 (file)
@@ -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);