mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paolo Abeni <pabeni@redhat.com>
To: Aleksandr Mishin <amishin@t-argos.ru>,
	Atul Gupta <atul.gupta@chelsio.com>
Cc: Ayush Sawal <ayush.sawal@chelsio.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>,
	David Ahern <dsahern@kernel.org>,
	Michael Werner <werner@chelsio.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	lvc-project@linuxtesting.org
Subject: Re: [PATCH net] crypto: chtls: Fix possible null pointer dereferences
Date: Thu, 11 Apr 2024 08:20:23 +0200	[thread overview]
Message-ID: <504f49cd5322d14d7c0d23d90f1cd7cc41721cf8.camel@redhat.com> (raw)
In-Reply-To: <20240409090507.21441-1-amishin@t-argos.ru>

On Tue, 2024-04-09 at 12:05 +0300, Aleksandr Mishin wrote:
> In chtls_pass_accept_rpl() and chtls_select_mss() __sk_dst_get() may
> return NULL which is later dereferenced. Fix this bug by adding NULL check.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.

Indeed a more describing changelog would be better given the patch
needs to go much fourther then adding a missing check.

> Fixes: cc35c88ae4db ("crypto : chtls - CPL handler definition")
> Signed-off-by: Aleksandr Mishin <amishin@t-argos.ru>
> ---
>  .../chelsio/inline_crypto/chtls/chtls_cm.c    | 24 +++++++++++++------
>  1 file changed, 17 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_cm.c b/drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_cm.c
> index 6f6525983130..6d88cbc9fbb0 100644
> --- a/drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_cm.c
> +++ b/drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_cm.c
> @@ -939,15 +939,15 @@ static void chtls_accept_rpl_arp_failure(void *handle,
>  	sock_put(sk);
>  }
>  
> -static unsigned int chtls_select_mss(const struct chtls_sock *csk,
> +static bool chtls_select_mss(const struct chtls_sock *csk,
>  				     unsigned int pmtu,
> -				     struct cpl_pass_accept_req *req)
> +				     struct cpl_pass_accept_req *req,
> +					 unsigned int *mtu_idx)

Bad indentation above.

More importantly, what about returning a negative value on failure and
avoid the additional parameter? It should also generate a smaller
diffstat.

>  {
>  	struct chtls_dev *cdev;
>  	struct dst_entry *dst;
>  	unsigned int tcpoptsz;
>  	unsigned int iphdrsz;
> -	unsigned int mtu_idx;
>  	struct tcp_sock *tp;
>  	unsigned int mss;
>  	struct sock *sk;
> @@ -955,6 +955,9 @@ static unsigned int chtls_select_mss(const struct chtls_sock *csk,
>  	mss = ntohs(req->tcpopt.mss);
>  	sk = csk->sk;
>  	dst = __sk_dst_get(sk);
> +	if (!dst)
> +		return false;
> +
>  	cdev = csk->cdev;
>  	tp = tcp_sk(sk);
>  	tcpoptsz = 0;

[...]

>  static unsigned int select_rcv_wscale(int space, int wscale_ok, int win_clamp)
> @@ -1016,8 +1019,13 @@ static void chtls_pass_accept_rpl(struct sk_buff *skb,
>  	struct sock *sk;
>  	u32 opt2, hlen;
>  	u64 opt0;
> +	struct dst_entry *dst;

Please respect the reverst x-mass tree order.

>  	sk = skb->sk;
> +	dst = __sk_dst_get(sk);
> +	if (!dst)
> +		return;
> +
>  	tp = tcp_sk(sk);
>  	csk = sk->sk_user_data;
>  	csk->tid = tid;

Thanks,

Paolo


      parent reply	other threads:[~2024-04-11  6:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-09  9:05 Aleksandr Mishin
2024-04-10  0:08 ` Jacob Keller
2024-04-11  6:20 ` Paolo Abeni [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=504f49cd5322d14d7c0d23d90f1cd7cc41721cf8.camel@redhat.com \
    --to=pabeni@redhat.com \
    --cc=amishin@t-argos.ru \
    --cc=atul.gupta@chelsio.com \
    --cc=ayush.sawal@chelsio.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lvc-project@linuxtesting.org \
    --cc=netdev@vger.kernel.org \
    --cc=werner@chelsio.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®