Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: lirongqing <lirongqing@baidu.com>
Cc: linux-rdma@vger.kernel.org
Subject: Re: [PATCH] RDMA/iser: Unmap Data-Out header DMA on send failure
Date: Mon, 21 Sep 2026 03:57:27 +0000	[thread overview]
Message-ID: <20260921035728.111E81F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260921033949.1803-1-lirongqing@baidu.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] iser: NULL pointer dereference in iser_send_data_out error path
--

commit 3d250519caf840438453e72597d8f3c0e0bcd912
Author: Li RongQing <lirongqing@baidu.com>

RDMA/iser: Unmap Data-Out header DMA on send failure

This commit fixes a DMA mapping leak in iser_send_data_out() by unmapping
the header DMA in the error path if the transmit descriptor was mapped.

> diff --git a/drivers/infiniband/ulp/iser/iser_initiator.c b/drivers/infiniband/ulp/iser/iser_initiator.c
> index 12a2d12fef070..1cdc8f389919f 100644
> --- a/drivers/infiniband/ulp/iser/iser_initiator.c
> +++ b/drivers/infiniband/ulp/iser/iser_initiator.c
> @@ -464,6 +464,10 @@ int iser_send_data_out(struct iscsi_conn *conn, struct iscsi_task *task,
>  		return 0;
>  
>  send_data_out_error:
> +	if (tx_desc->mapped)
> +		ib_dma_unmap_single(iser_conn->ib_conn.device->ib_device,

[Severity: High]
Can this result in a NULL pointer dereference if a DEVICE_REMOVAL CM event
occurs concurrently?

If a target sends a malformed R2T that fails the bounds check, execution jumps
to send_data_out_error. If a DEVICE_REMOVAL event occurs simultaneously,
the CM thread handles the removal asynchronously and sets
iser_conn->ib_conn.device = NULL.

Since iser_send_data_out() does not hold state_mutex or otherwise
synchronize with DEVICE_REMOVAL, iser_conn->ib_conn.device can be evaluated
as NULL here. 

The commit message mentions mirroring iscsi_iser_cleanup_task(), which uses a
safety check for this exact race. Does this new error path need a similar
check before dereferencing the device?

> +				    tx_desc->dma_addr, ISER_HEADERS_LEN,
> +				    DMA_TO_DEVICE);
>  	kmem_cache_free(ig.desc_cache, tx_desc);
>  	iser_err("conn %p failed err %d\n", conn, err);
>  	return err;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260921033949.1803-1-lirongqing@baidu.com?part=1

      reply	other threads:[~2026-09-21  3:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-21  3:39 [PATCH] RDMA/iser: Unmap Data-Out header DMA on send failure lirongqing
2026-09-21  3:57 ` sashiko-bot [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=20260921035728.111E81F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=lirongqing@baidu.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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