From: Baokun Li <libaokun@linux.alibaba.com>
To: sashiko-reviews@lists.linux.dev
Cc: linux-ext4@vger.kernel.org, linux-fscrypt@vger.kernel.org,
tytso@mit.edu, linux-fscrypt@vger.kernel.org,
linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-xfs@vger.kernel.org, ebiggers@kernel.org,
jaegeuk@kernel.org, axboe@kernel.dk, hch@lst.de,
djwong@kernel.org, brauner@kernel.org, tytso@mit.edu,
berto@igalia.com, adilger.kernel@dilger.ca, jack@suse.cz,
yi.zhang@huawei.com, ojaswin@linux.ibm.com,
ritesh.list@gmail.com, stable@vger.kernel.org
Subject: Re: [PATCH 03/13] blk-crypto: reject fallback data unit sizes it can't handle
Date: Mon, 12 Oct 2026 15:50:15 +0800 [thread overview]
Message-ID: <bda10a43-5ff3-4f8d-b9a7-e63161e0fb4b@linux.alibaba.com> (raw)
In-Reply-To: <sashiko-outbox-167341@kernel.org>
On 2026/10/12 01:20, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [High] block: NULL pointer deref in blk_crypto_fallback_evict_key() on setup failure
[...]
> [Severity: High]
> Does this early return bypass blk_crypto_fallback_init() and leave
> blk_crypto_fallback_profile as NULL?
>
> If this is the first fallback usage, returning here means we haven't
> initialized the profile. If downstream callers (like dm-inlinecrypt) handle
> this -EOPNOTSUPP error by attempting to evict the partially initialized key,
> can it lead to a NULL pointer dereference?
>
> When target teardown calls blk_crypto_evict_key(), it will eventually call
> blk_crypto_fallback_evict_key(), which passes the uninitialized profile
> directly:
>
> block/blk-crypto-fallback.c:blk_crypto_fallback_evict_key() {
> return __blk_crypto_evict_key(blk_crypto_fallback_profile, key);
> }
>
> This unvalidated profile pointer is then dereferenced when checking the number
> of slots:
>
> block/blk-crypto-profile.c:__blk_crypto_evict_key() {
> ...
> if (profile->num_slots == 0) {
> ...
> }
>
> Could this cause a kernel panic if a user with device mapper access requests
> an unsupported data unit size?
>
The early return does leave blk_crypto_fallback_profile uninitialized,
but the NULL dereference that follows is a pre-existing issue, unrelated
to this series: the same eviction path is reachable on the base tree,
and the two flows below trigger a NULL dereference or a use-after-free:
dm-inlinecrypt ctor # first use of the fallback
├─ blk_crypto_init_key() # succeeds, ctx->key.size != 0
├─ blk_crypto_start_using_key()
│ ├─ return -EOPNOTSUPP # uninit profile, will NULL deref
│ └─ blk_crypto_fallback_start_using_key()
│ └─ blk_crypto_fallback_init() fails
│ └─ kfree(profile) # not NULLed, will UAF
├─ goto bad
└─ inlinecrypt_dtr() # evicts whenever key.size is set
└─ blk_crypto_evict_key()
└─ blk_crypto_config_supported_natively() = false
└─ blk_crypto_fallback_evict_key()
└─ __blk_crypto_evict_key(blk_crypto_fallback_profile)
└─ profile->num_slots # BOOM!!!
If this series doesn't need a V2, I'll send the fix as a standalone
bugfix. If a V2 is needed, I'll include it in the series before this
patch.
Thanks,
Baokun
next prev parent reply other threads:[~2026-10-12 7:50 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-11 17:09 [PATCH 00/13] block, ext4: allow encryption with a block size larger than the page size Baokun Li
2026-10-11 17:09 ` [PATCH 01/13] ext4: refuse encryption when block size > " Baokun Li
2026-10-11 17:26 ` sashiko-bot
2026-10-11 17:09 ` [PATCH 02/13] ext4: reject encrypted inodes " Baokun Li
2026-10-11 17:16 ` sashiko-bot
2026-10-11 17:09 ` [PATCH 03/13] blk-crypto: reject fallback data unit sizes it can't handle Baokun Li
2026-10-11 17:20 ` sashiko-bot
2026-10-12 7:50 ` Baokun Li [this message]
2026-10-11 17:09 ` [PATCH 04/13] blk-crypto: decrypt one data unit per crypto request Baokun Li
2026-10-11 17:19 ` sashiko-bot
2026-10-11 17:09 ` [PATCH 05/13] blk-crypto: encrypt " Baokun Li
2026-10-11 17:26 ` sashiko-bot
2026-10-11 17:09 ` [PATCH 06/13] blk-crypto: support data units larger than a page Baokun Li
2026-10-11 17:27 ` sashiko-bot
2026-10-11 17:09 ` [PATCH 07/13] iomap: align the direct I/O bios of encrypted files to the block size Baokun Li
2026-10-11 17:25 ` sashiko-bot
2026-10-11 17:09 ` [PATCH 08/13] block: split encrypted bios at data unit boundaries Baokun Li
2026-10-11 17:20 ` sashiko-bot
2026-10-11 17:09 ` [PATCH 09/13] block: warn about bios that can't be split Baokun Li
2026-10-11 17:18 ` sashiko-bot
2026-10-11 17:09 ` [PATCH 10/13] block: don't require data unit aligned bio_vecs for encrypted bios Baokun Li
2026-10-11 17:24 ` sashiko-bot
2026-10-12 8:09 ` Baokun Li
2026-10-11 17:09 ` [PATCH 11/13] ext4: allow encryption with a block size larger than the page size Baokun Li
2026-10-11 17:30 ` sashiko-bot
2026-10-11 17:09 ` [PATCH 12/13] ext4: send folios that cover a wraparound to the buffer_head path Baokun Li
2026-10-11 17:22 ` sashiko-bot
2026-10-11 17:09 ` [PATCH 13/13] ext4: allow large folios for encrypted files Baokun Li
2026-10-11 17:23 ` 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=bda10a43-5ff3-4f8d-b9a7-e63161e0fb4b@linux.alibaba.com \
--to=libaokun@linux.alibaba.com \
--cc=adilger.kernel@dilger.ca \
--cc=axboe@kernel.dk \
--cc=berto@igalia.com \
--cc=brauner@kernel.org \
--cc=djwong@kernel.org \
--cc=ebiggers@kernel.org \
--cc=hch@lst.de \
--cc=jack@suse.cz \
--cc=jaegeuk@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fscrypt@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=ojaswin@linux.ibm.com \
--cc=ritesh.list@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=stable@vger.kernel.org \
--cc=tytso@mit.edu \
--cc=yi.zhang@huawei.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.