All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bodo Stroesser <bostroesser@gmail.com>
To: Denis Plotnikov <den-plotnikov@yandex-team.ru>,
	linux-scsi@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, target-devel@vger.kernel.org,
	varun@chelsio.com, nab@linux-iscsi.org,
	martin.petersen@oracle.com
Subject: Re: [PATCH] scsi: target: cxgbit: check skb dequeue result
Date: Fri, 7 Apr 2023 21:16:18 +0200	[thread overview]
Message-ID: <2170fe67-2e65-630b-22dc-a8f6d3f7966f@gmail.com> (raw)
In-Reply-To: <20230406150405.300909-1-den-plotnikov@yandex-team.ru>

On 06.04.23 17:04, Denis Plotnikov wrote:
> On a couple of abort packet paths skb dequeuing may end up with
> returning NULL, which, in turn, may end up with further null
> pointer dereference.
> 
> Fix it by checking the return value of skb dequeuing.
> 
> Found by Linux Verification Center(linuxtesting.org) with SVACE.
> 
> Fixes: 9730ffcb8957 (cxgbit: add files for cxgbit.ko)
> Signed-off-by: Denis Plotnikov <den-plotnikov@yandex-team.ru>
> ---
>   drivers/target/iscsi/cxgbit/cxgbit_cm.c | 10 +++++++---
>   1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/target/iscsi/cxgbit/cxgbit_cm.c b/drivers/target/iscsi/cxgbit/cxgbit_cm.c
> index 518ded214e74..d43fd761c20a 100644
> --- a/drivers/target/iscsi/cxgbit/cxgbit_cm.c
> +++ b/drivers/target/iscsi/cxgbit/cxgbit_cm.c
> @@ -669,6 +669,9 @@ static int cxgbit_send_abort_req(struct cxgbit_sock *csk)
>   		cxgbit_send_tx_flowc_wr(csk);
>   
>   	skb = __skb_dequeue(&csk->skbq);
> +	if (!skb)
> +		return 0;
> +
>   	cxgb_mk_abort_req(skb, len, csk->tid, csk->txq_idx,
>   			  csk->com.cdev, cxgbit_abort_arp_failure);
>   
> @@ -1769,9 +1772,10 @@ static void cxgbit_abort_req_rss(struct cxgbit_sock *csk, struct sk_buff *skb)
>   		cxgbit_send_tx_flowc_wr(csk);
>   
>   	rpl_skb = __skb_dequeue(&csk->skbq);
> -
> -	cxgb_mk_abort_rpl(rpl_skb, len, csk->tid, csk->txq_idx);
> -	cxgbit_ofld_send(csk->com.cdev, rpl_skb);
> +	if (!rpl_skb) {

Honestly I have no clue about cxgbit, but to avoid null pointer
dereference, shouldn't it be "if (rpl_skb) {"?

Bodo


> +		cxgb_mk_abort_rpl(rpl_skb, len, csk->tid, csk->txq_idx);
> +		cxgbit_ofld_send(csk->com.cdev, rpl_skb);
> +	}
>   
>   	if (wakeup_thread) {
>   		cxgbit_queue_rx_skb(csk, skb);

  reply	other threads:[~2023-04-07 19:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-06 15:04 [PATCH] scsi: target: cxgbit: check skb dequeue result Denis Plotnikov
2023-04-07 19:16 ` Bodo Stroesser [this message]
2023-04-10  7:35   ` Denis Plotnikov
2023-04-10 11:45 ` Varun Prakash
2023-04-10 13:04   ` Denis Plotnikov

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=2170fe67-2e65-630b-22dc-a8f6d3f7966f@gmail.com \
    --to=bostroesser@gmail.com \
    --cc=den-plotnikov@yandex-team.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=nab@linux-iscsi.org \
    --cc=target-devel@vger.kernel.org \
    --cc=varun@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.