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] [day] [month] [year] [list]
Message-ID: <61db29bc-2c95-49e3-8ecc-fa5485b8919d@nvidia.com>
Date: Thu, 20 Mar 2025 18:46:59 +0200
From: Shahar Shitrit <shshitrit@...dia.com>
To: Jakub Kicinski <kuba@...nel.org>, davem@...emloft.net
Cc: netdev@...r.kernel.org, edumazet@...gle.com, pabeni@...hat.com,
 borisp@...dia.com, john.fastabend@...il.com, Gal Pressman <gal@...dia.com>,
 Tariq Toukan <tariqt@...dia.com>
Subject: Re: [PATCH net] tls: strp: make sure the TCP skbs do not have
 overlapping data



On 13/10/2022 1:55, Jakub Kicinski wrote:
> TLS tries to get away with using the TCP input queue directly.
> This does not work if there is duplicated data (multiple skbs
> holding bytes for the same seq number range due to retransmits).
> Check for this condition and fall back to copy mode, it should
> be rare.
> 
> Fixes: 84c61fe1a75b ("tls: rx: do not use the standard strparser")
> Signed-off-by: Jakub Kicinski <kuba@...nel.org>
> ---
>  net/tls/tls_strp.c | 32 ++++++++++++++++++++++++++++----
>  1 file changed, 28 insertions(+), 4 deletions(-)
> 
> diff --git a/net/tls/tls_strp.c b/net/tls/tls_strp.c
> index 9b79e334dbd9..955ac3e0bf4d 100644
> --- a/net/tls/tls_strp.c
> +++ b/net/tls/tls_strp.c
> @@ -273,7 +273,7 @@ static int tls_strp_read_copyin(struct tls_strparser *strp)
>  	return desc.error;
>  }
>  
> -static int tls_strp_read_short(struct tls_strparser *strp)
> +static int tls_strp_read_copy(struct tls_strparser *strp, bool qshort)
>  {
>  	struct skb_shared_info *shinfo;
>  	struct page *page;
> @@ -283,7 +283,7 @@ static int tls_strp_read_short(struct tls_strparser *strp)
>  	 * to read the data out. Otherwise the connection will stall.
>  	 * Without pressure threshold of INT_MAX will never be ready.
>  	 */
> -	if (likely(!tcp_epollin_ready(strp->sk, INT_MAX)))
> +	if (likely(qshort && !tcp_epollin_ready(strp->sk, INT_MAX)))
>  		return 0;
>  
>  	shinfo = skb_shinfo(strp->anchor);
> @@ -315,6 +315,27 @@ static int tls_strp_read_short(struct tls_strparser *strp)
>  	return 0;
>  }
>  
> +static bool tls_strp_check_no_dup(struct tls_strparser *strp)
> +{
> +	unsigned int len = strp->stm.offset + strp->stm.full_len;
> +	struct sk_buff *skb;
> +	u32 seq;
> +
> +	skb = skb_shinfo(strp->anchor)->frag_list;

Our regression tests identified a null pointer dereference in this line.
It has reproduced only once so far. Upon reviewing the code, I noticed
that the frag_list is assigned the next skb that TCP receives (in
tls_strp_load_anchor_with_queue()). This could explain why there is no
null check before accessing the frag_list.

I would like to confirm please that frag_list  == NULL is never expected
here (hence no need for a NULL check), i.e. the tls_strp anchor should
always have the frag_list at this point, and any frag_list == NULL is
considered a bug.

> +	seq = TCP_SKB_CB(skb)->seq;
> +
> +	while (skb->len < len) {
> +		seq += skb->len;
> +		len -= skb->len;
> +		skb = skb->next;
> +
> +		if (TCP_SKB_CB(skb)->seq != seq)
> +			return false;
> +	}
> +
> +	return true;
> +}
> +
>  static void tls_strp_load_anchor_with_queue(struct tls_strparser *strp, int len)
>  {
>  	struct tcp_sock *tp = tcp_sk(strp->sk);
> @@ -373,7 +394,7 @@ static int tls_strp_read_sock(struct tls_strparser *strp)
>  		return tls_strp_read_copyin(strp);
>  
>  	if (inq < strp->stm.full_len)
> -		return tls_strp_read_short(strp);
> +		return tls_strp_read_copy(strp, true);
>  
>  	if (!strp->stm.full_len) {
>  		tls_strp_load_anchor_with_queue(strp, inq);
> @@ -387,9 +408,12 @@ static int tls_strp_read_sock(struct tls_strparser *strp)
>  		strp->stm.full_len = sz;
>  
>  		if (!strp->stm.full_len || inq < strp->stm.full_len)
> -			return tls_strp_read_short(strp);
> +			return tls_strp_read_copy(strp, true);
>  	}
>  
> +	if (!tls_strp_check_no_dup(strp))
> +		return tls_strp_read_copy(strp, false);
> +
>  	strp->msg_ready = 1;
>  	tls_rx_msg_ready(strp);
>  

Thank you
Shahar Shitrit

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ