All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Nitesh Shetty" <nj.shetty@samsung.com>
Cc: dri-devel@lists.freedesktop.org, nvdimm@lists.linux.dev,
	linux-ext4@vger.kernel.org, tytso@mit.edu, media-ci@linuxtv.org
Subject: Re: [RFC PATCH v3 05/13] io_uring/dma-buf: switch to tag file filtering
Date: Tue, 01 Dec 2026 17:10:11 +0000	[thread overview]
Message-ID: <sashiko-outbox-243793@kernel.org> (raw)
In-Reply-To: <20261201155938.3028275-6-nj.shetty@samsung.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] io_uring/dma-buf: fput() in __io_register_dmabuf() unpins
  importer module
--

commit 2e02bfbc83fd62e0046f2d9e78bfc97e418c5fff
Author: Pavel Begunkov <asml.silence@gmail.com>

io_uring/dma-buf: switch to tag file filtering

This commit replaces the exact target_file check on registered dma-bufs
with tag-based file compatibility checking via dma_buf_io_file_compatible()
and drops the target_file reference at the end of __io_register_dmabuf().

> diff --git a/io_uring/dma-buf.c b/io_uring/dma-buf.c
> index fd9b8769818ad..fe735a8773b73 100644
> --- a/io_uring/dma-buf.c
> +++ b/io_uring/dma-buf.c
> @@ -4,7 +4,6 @@ static inline void io_release_dmabuf(void *priv)
>  {
>  	struct io_buf_dma *bd = io_priv_to_dmabuf(priv);
>  
> -	fput(bd->target_file);
>  	dma_buf_io_ctx_release(bd->ctx);
>  	kfree(bd);
>  }
> @@ -52,13 +51,13 @@ int __io_register_dmabuf(struct io_ring_ctx *ctx,
>  	if (ret)
>  		goto err;
>  
> -	bd->target_file = target_file;
>  	imu->len = dmabuf->size;
>  	imu->release = io_release_dmabuf;
>  	imu->priv = bd;
>  	imu->flags = IO_REGBUF_F_DMABUF;
>  	imu->dir = IO_BUF_DEST | IO_BUF_SOURCE;
>  	dma_buf_put(dmabuf);
> +	fput(target_file);
>  	return 0;

[Severity: High]
Can dropping target_file in __io_register_dmabuf() allow the importer
driver module to be unloaded while bd->ctx is still registered?

When userspace closes target_fd and no other files remain open on the
device (such as an NVMe namespace), nvme_ns_release() and bdev_release()
drop the module references on nvme.ko and nvme-core.ko.  Neither
dma_buf_io_ctx_create() nor nvme_init_io_ctx_locked() pins the importer
module; nvme_init_io_ctx_locked() only takes a kobject reference via
nvme_get_ctrl(ctrl) and sets ctx->dev_ops = &nvme_dma_buf_io_ops.

If nvme.ko is then unloaded while the buffer stays registered,
nvme_remove() detaches the dma-buf and drops the driver's ctrl reference,
and the later io_release_dmabuf() -> dma_buf_io_ctx_release() call invokes
ctx->dev_ops->release(ctx) and ctrl->ops->free_ctrl(ctrl) in unmapped
module memory.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261201155938.3028275-1-nj.shetty@samsung.com?part=5

  reply	other threads:[~2026-12-01 17:10 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20261201160117epcas5p2ec8720e93d2041c09b70d41eed40efd1@epcas5p2.samsung.com>
2026-12-01 15:59 ` [RFC PATCH v3 00/13] fs: dma-buf direct I/O for XFS and ext4 Nitesh Shetty
2026-12-01 15:59   ` [RFC PATCH v3 01/13] block: factor out bdev_init_dma_buf_io_ctx() Nitesh Shetty
2026-12-01 15:59   ` [RFC PATCH v3 02/13] dma-buf-io: add tags to share a context between files Nitesh Shetty
2026-12-01 15:59   ` [RFC PATCH v3 03/13] block: set dma-buf-io tag for block files Nitesh Shetty
2026-12-01 15:59   ` [RFC PATCH v3 04/13] io_uring: add data to dma-buf conversion helpers Nitesh Shetty
2026-12-01 15:59   ` [RFC PATCH v3 05/13] io_uring/dma-buf: switch to tag file filtering Nitesh Shetty
2026-12-01 17:10     ` sashiko-bot [this message]
2026-12-01 15:59   ` [RFC PATCH v3 06/13] dma-buf-io: require O_DIRECT and a tag in dma_buf_io_ctx_create() Nitesh Shetty
2026-12-01 15:59   ` [RFC PATCH v3 07/13] io_uring/dma-buf: get rid of struct io_buf_dma Nitesh Shetty
2026-12-01 15:59   ` [RFC PATCH v3 08/13] iomap: add dma-buf direct I/O guards Nitesh Shetty
2026-12-01 15:59   ` [RFC PATCH v3 09/13] iomap: don't ask for a buffered fallback for dma-buf iterators Nitesh Shetty
2026-12-01 17:16     ` sashiko-bot
2026-12-01 15:59   ` [RFC PATCH v3 10/13] blk-crypto: refuse dma-buf bios in the fallback path Nitesh Shetty
2026-12-01 15:59   ` [RFC PATCH v3 11/13] dax: refuse dma-buf iterators in dax_iomap_rw() Nitesh Shetty
2026-12-01 15:59   ` [RFC PATCH v3 12/13] xfs: support dma-buf registered buffers for direct I/O Nitesh Shetty
2026-12-01 17:20     ` sashiko-bot
2026-12-01 15:59   ` [RFC PATCH v3 13/13] ext4: " Nitesh Shetty
2026-12-01 17:20   ` [RFC PATCH v3 00/13] fs: dma-buf direct I/O for XFS and ext4 sashiko-bot

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=sashiko-outbox-243793@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=media-ci@linuxtv.org \
    --cc=nj.shetty@samsung.com \
    --cc=nvdimm@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tytso@mit.edu \
    /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.