All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "周伟江 (Weijiang Zhou)" <weijiang.zhou@unisoc.com>,
	"Eric Biggers" <ebiggers@kernel.org>,
	"Mikulas Patocka" <mpatocka@redhat.com>
Cc: "dm-devel@lists.linux.dev" <dm-devel@lists.linux.dev>,
	"samitolvanen@google.com" <samitolvanen@google.com>,
	"agk@redhat.com" <agk@redhat.com>,
	"snitzer@kernel.org" <snitzer@kernel.org>,
	"bmarzins@redhat.com" <bmarzins@redhat.com>,
	"金红宇 (Hongyu Jin)" <hongyu.jin@unisoc.com>,
	"吴祥禄 (Xianglu Wu)" <Xianglu.Wu@unisoc.com>,
	"吴周镜 (Justin Wu)" <Justin.Wu@unisoc.com>,
	"耿慈熙 (Cixi Geng/10039)" <Cixi.Geng1@unisoc.com>
Subject: Re: [RFC PATCH v3 1/3] dm-bufio: support atomic publication of pre-filled buffers
Date: Fri, 04 Dec 2026 05:34:41 +0000	[thread overview]
Message-ID: <sashiko-outbox-249149@kernel.org> (raw)
In-Reply-To: <617ee359326e4d033d876d4d3ef85c8d@zeshmbx08.spreadtrum.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Low] dm-bufio: dm_bufio_new_filled() comment falsely claims
  unconditional release
- [Low] dm-bufio: dm_bufio_new_filled() comment allows unsafe
  post-publish mutation
--

commit 683375cb0012c1144d366252380e409571565027
Author: 周伟江 (Weijiang Zhou) <weijiang.zhou@unisoc.com>

dm-bufio: support atomic publication of pre-filled buffers

This commit adds NF_FILLED and dm_bufio_new_filled() to copy caller data
into a new buffer before inserting it into the cache.

> diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c
> index 3b66cf1cb9319..6cd81aaf8bd77 100644
> --- a/drivers/md/dm-bufio.c
> +++ b/drivers/md/dm-bufio.c

[ ... ]

> @@ -1962,10 +1972,38 @@ void *dm_bufio_new(struct dm_bufio_client *c, sector_t block,
>  	if (WARN_ON_ONCE(dm_bufio_in_request()))
>  		return ERR_PTR(-EINVAL);
>  
> -	return new_read(c, block, NF_FRESH, bp, IOPRIO_DEFAULT);
> +	return new_read(c, block, NF_FRESH, bp, IOPRIO_DEFAULT, NULL);
>  }
>  EXPORT_SYMBOL_GPL(dm_bufio_new);
>  
> +/*
> + * Publish a fully prepared block into the cache.  Unlike dm_bufio_new(),
> + * the buffer is populated with @data before it becomes visible to other
> + * readers, so no one can observe uninitialized contents.  If the block is
> + * already cached, the existing buffer is returned and @data is not used.
> + *
> + * The returned buffer is held and must be released with dm_bufio_release().
> + * The caller may inspect or modify the data, but must not mark it dirty
> + * unless it intends to write the block back to the device.

[Severity: Low]
Is it safe for this comment to tell callers they may modify the returned
data?

When dm_bufio_new_filled() returns, the buffer is already published in the
cache with B_READING clear (or is an existing shared buffer), with no
per-buffer lock held.  Modifying b->data in place without external locking
races with concurrent dm_bufio_get() and dm_bufio_read() readers.

> + *
> + * @data must not be NULL.  On failure ERR_PTR is returned and *bp is set to
> + * NULL, so that callers can release unconditionally.

[Severity: Low]
Can callers actually call dm_bufio_release() unconditionally when *bp is
NULL?

dm_bufio_release() immediately dereferences b->c without checking for NULL,
so passing a NULL *bp on failure triggers a NULL pointer dereference.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/f55322e3a71277d927476ddb372064e0@zeshmbx08.spreadtrum.com?part=1

  reply	other threads:[~2026-12-04  5:34 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-10 13:06 [RFC PATCH 0/2] dm-verity: don't let FEC decode into a dm_bufio page that is already in the cache 周伟江 (Weijiang Zhou)
2026-11-10 13:06 ` [RFC PATCH 1/2] dm-verity: don't decode FEC " 周伟江 (Weijiang Zhou)
2026-11-10 21:08   ` Mikulas Patocka
2026-11-11  3:14     ` 周伟江 (Weijiang Zhou)
2026-11-11 23:33       ` Mikulas Patocka
2026-11-12  0:38     ` Sami Tolvanen
2026-11-13  5:36     ` Eric Biggers
2026-11-19 13:22       ` 周伟江 (Weijiang Zhou)
2026-12-02 13:05         ` 周伟江 (Weijiang Zhou)
2026-12-02 19:04           ` Eric Biggers
2026-12-03  8:51             ` [RFC PATCH v2 0/4] dm-verity: fix FEC turning I/O errors into corruption reports 周伟江 (Weijiang Zhou)
2026-12-03  8:51               ` [RFC PATCH v2 1/4] dm-verity: don't restart or panic on errors during system shutdown 周伟江 (Weijiang Zhou)
2026-12-03  8:51               ` [RFC PATCH v2 2/4] dm-bufio: support atomic publication of pre-filled buffers 周伟江 (Weijiang Zhou)
2026-12-03  8:51               ` [RFC PATCH v2 3/4] dm-verity: prevent FEC from publishing uninitialized hash blocks 周伟江 (Weijiang Zhou)
2026-12-03  8:51               ` [RFC PATCH v2 4/4] dm-verity: avoid corruption policy during FEC erasure lookup 周伟江 (Weijiang Zhou)
2026-12-03 11:07               ` [RFC PATCH v2 0/4] dm-verity: fix FEC turning I/O errors into corruption reports 周伟江 (Weijiang Zhou)
2026-12-03 18:41                 ` Eric Biggers
2026-12-04  5:19                   ` [RFC PATCH v3 0/3] dm-verity: fix FEC recovery of hash blocks and spurious corruption policy 周伟江 (Weijiang Zhou)
2026-12-04  5:19                     ` [RFC PATCH v3 1/3] dm-bufio: support atomic publication of pre-filled buffers 周伟江 (Weijiang Zhou)
2026-12-04  5:34                       ` sashiko-bot [this message]
2026-12-04  5:19                     ` [RFC PATCH v3 2/3] dm-verity: prevent FEC from publishing uninitialized hash blocks 周伟江 (Weijiang Zhou)
2026-12-04  5:36                       ` sashiko-bot
2026-12-04  5:19                     ` [RFC PATCH v3 3/3] dm-verity: avoid corruption policy during FEC erasure lookup 周伟江 (Weijiang Zhou)
2026-12-04  5:33                       ` sashiko-bot
2026-11-10 13:06 ` [RFC PATCH 2/2] dm-verity: don't restart or panic on errors during system shutdown 周伟江 (Weijiang Zhou)
2026-11-10 21:13   ` Mikulas Patocka
2026-11-11  3:14     ` 周伟江 (Weijiang Zhou)
2026-11-11 22:48       ` Mikulas Patocka
2026-11-13  5:55   ` Eric Biggers
2026-11-13  7:40     ` 回复: " 周伟江 (Weijiang Zhou)

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-249149@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Cixi.Geng1@unisoc.com \
    --cc=Justin.Wu@unisoc.com \
    --cc=Xianglu.Wu@unisoc.com \
    --cc=agk@redhat.com \
    --cc=bmarzins@redhat.com \
    --cc=dm-devel@lists.linux.dev \
    --cc=ebiggers@kernel.org \
    --cc=hongyu.jin@unisoc.com \
    --cc=mpatocka@redhat.com \
    --cc=samitolvanen@google.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=snitzer@kernel.org \
    --cc=weijiang.zhou@unisoc.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.