lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 28 May 2020 09:03:07 +0300
From:   Boris Pismenny <borisp@...lanox.com>
To:     Jakub Kicinski <kuba@...nel.org>,
        Tariq Toukan <tariqt@...lanox.com>
Cc:     "David S. Miller" <davem@...emloft.net>, netdev@...r.kernel.org,
        Saeed Mahameed <saeedm@...lanox.com>
Subject: Re: [PATCH net] net/tls: Fix driver request resync


On 20/05/2020 23:34, Jakub Kicinski wrote:
> On Wed, 20 May 2020 18:14:08 +0300 Tariq Toukan wrote:
>> From: Boris Pismenny <borisp@...lanox.com>
>>
>> In driver request resync, the hardware requests a resynchronization
>> request at some TCP sequence number. If that TCP sequence number does
>> not point to a TLS record header, then the resync attempt has failed.
>>
>> Failed resync should reset the resync request to avoid spurious resyncs
>> after the TCP sequence number has wrapped around.
>>
>> Fix this by resetting the resync request when the TLS record header
>> sequence number is not before the requested sequence number.
>> As a result, drivers may be called with a sequence number that is not
>> equal to the requested sequence number.
>>
>> Fixes: f953d33ba122 ("net/tls: add kernel-driven TLS RX resync")
>> Signed-off-by: Boris Pismenny <borisp@...lanox.com>
>> Signed-off-by: Tariq Toukan <tariqt@...lanox.com>
>> Reviewed-by: Saeed Mahameed <saeedm@...lanox.com>
>> ---
>>  net/tls/tls_device.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/net/tls/tls_device.c b/net/tls/tls_device.c
>> index a562ebaaa33c..cbb13001b4a9 100644
>> --- a/net/tls/tls_device.c
>> +++ b/net/tls/tls_device.c
>> @@ -714,7 +714,7 @@ void tls_device_rx_resync_new_rec(struct sock *sk, u32 rcd_len, u32 seq)
>>  		seq += TLS_HEADER_SIZE - 1;
>>  		is_req_pending = resync_req;
>>  
>> -		if (likely(!is_req_pending) || req_seq != seq ||
>> +		if (likely(!is_req_pending) || before(seq, req_seq) ||
> So the kernel is going to send the sync message to the device with at
> sequence number the device never asked about? 

Yes, although I would phrase it differently: the kernel would indicate to the driver,
that the resync request is wrong, and that it can go back to searching for a header.
If there are any drivers that need an extra check, then we can add it in the driver itself.

>
> Kernel usually can't guarantee that the notification will happen,
> (memory allocation errors, etc.) so the device needs to do the
> restarting itself. The notification should not be necessary.
>

Usually, all is best effort, but in principle, reliability should be guaranteed by higher layers to simplify the design.
On the one hand, resync depends on packet arrival, which may take a while, and implementing different heuristics in each driver to timeout is complex.
On the other hand, assuming the user reads the record data eventually, ktls will be able to deliver the resync request, so implementing this in the tls layer is simple.

In this case, I see no reason for the tls layer to fail --- did you have a specific flow in mind?
AFAICT, there are no memory allocation/error flows that will prevent the driver to receive a resync without an error on the socket (bad tls header).
If tls received the header, then the driver will receive the resync call, and it will take responsibility for reliably delivering it to HW.

Boris

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ