OSDN Git Service

tls: Return type of non-data records retrieved using MSG_PEEK in recvmsg
authorVakul Garg <vakul.garg@nxp.com>
Sat, 23 Feb 2019 08:42:37 +0000 (08:42 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 25 Feb 2019 05:58:38 +0000 (21:58 -0800)
commit2b794c4098b525836e37d16045abee3091fdfe18
tree476aca6dc1cebe77ab8f602b3f3427cbc5b6eb28
parent2bdeb8e5bd7b63cb6a5e341178840fd92f61c4de
tls: Return type of non-data records retrieved using MSG_PEEK in recvmsg

The patch enables returning 'type' in msghdr for records that are
retrieved with MSG_PEEK in recvmsg. Further it prevents records peeked
from socket from getting clubbed with any other record of different
type when records are subsequently dequeued from strparser.

For each record, we now retain its type in sk_buff's control buffer
cb[]. Inside control buffer, record's full length and offset are already
stored by strparser in 'struct strp_msg'. We store record type after
'struct strp_msg' inside 'struct tls_msg'. For tls1.2, the type is
stored just after record dequeue. For tls1.3, the type is stored after
record has been decrypted.

Inside process_rx_list(), before processing a non-data record, we check
that we must be able to return back the record type to the user
application. If not, the decrypted records in tls context's rx_list is
left there without consuming any data.

Fixes: 692d7b5d1f912 ("tls: Fix recvmsg() to be able to peek across multiple records")
Signed-off-by: Vakul Garg <vakul.garg@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/tls.h
net/tls/tls_sw.c