From: sashiko-bot@kernel.org
To: shao.mingyin@zte.com.cn, linux-nvme@lists.infradead.org
Subject: Re: [PATCH 4/5] nvme: decode the FDP Get Features result as a dword
Date: Sat, 14 Nov 2026 17:37:29 +0000 [thread overview]
Message-ID: <sashiko-outbox-214846@kernel.org> (raw)
In-Reply-To: <202611150127572887TC7vHzVUFLZ6nyW1NuhU@zte.com.cn>
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Medium] nvme: uninitialized stack memory use in
nvme_query_fdp_granularity() [1]
--
commit 37e4c911db178216572cd8ee6fd19cfc2f58c7f0
Author: Shao Mingyin <shao.mingyin@zte.com.cn>
nvme: decode the FDP Get Features result as a dword
This commit changes nvme_query_fdp_info() to read the NVME_FEAT_FDP Get
Features result as a u32 and decode the flags and FDP configuration index
manually so that FDP probing works on big-endian hosts.
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index a7a4d09644c13..45feafa003257 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -2339,8 +2339,8 @@ static int nvme_query_fdp_info(struct nvme_ns *ns, struct nvme_ns_info *info)
> struct nvme_ns_head *head = ns->head;
> struct nvme_ctrl *ctrl = ns->ctrl;
> struct nvme_fdp_ruh_status *ruhs;
> - struct nvme_fdp_config fdp;
> struct nvme_command c = {};
> + u32 fdp;
> size_t size;
> int i, ret;
>
> @@ -2351,10 +2351,10 @@ static int nvme_query_fdp_info(struct nvme_ns *ns, struct nvme_ns_info *info)
> return ret;
> }
>
> - if (!(fdp.flags & FDPCFG_FDPE))
> + if (!(fdp & FDPCFG_FDPE))
> return 0;
>
> - ret = nvme_query_fdp_granularity(ctrl, info, fdp.fdpcidx);
> + ret = nvme_query_fdp_granularity(ctrl, info, (fdp >> 8) & 0xff);
[Severity: Medium]
This problem wasn't introduced by this patch, but can
nvme_query_fdp_granularity() read uninitialized stack memory from hdr.sze
[1]?
drivers/nvme/host/core.c:nvme_query_fdp_granularity() {
struct nvme_fdp_config_log hdr, *h;
...
ret = nvme_get_log_lsi(ctrl, 0, NVME_LOG_FDP_CONFIGS, 0,
NVME_CSI_NVM, &hdr, size, 0, info->endgid);
if (ret) {
...
return ret;
}
size = le32_to_cpu(hdr.sze);
...
h = kvzalloc(size, GFP_KERNEL);
}
hdr is allocated on the stack without zero-initialization. If the
controller completes the log page command with a short data transfer,
hdr.sze remains uninitialized and is passed as the allocation size to
kvzalloc().
[1] https://sashiko.dev/#/bug/linux-1cda5d44-a6cc-40a9-bd2b-cbed1b364093
--
Sashiko AI review · https://sashiko.dev/#/patchset/202611150127512368BGQ07ZNIRAIwClkam-8u@zte.com.cn?part=4
prev parent reply other threads:[~2026-11-14 17:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-14 17:27 [PATCH 0/5] nvme: validate and decode controller supplied values shao.mingyin
[not found] ` <202611150127572887TC7vHzVUFLZ6nyW1NuhU@zte.com.cn>
2026-11-14 17:37 ` 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=sashiko-outbox-214846@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=shao.mingyin@zte.com.cn \
/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