From: Dave Jiang <dave.jiang@intel.com>
To: Murad Masimov <m.masimov@mt-integration.ru>,
Dan Williams <dan.j.williams@intel.com>
Cc: Vishal Verma <vishal.l.verma@intel.com>,
Ira Weiny <ira.weiny@intel.com>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Len Brown <lenb@kernel.org>,
nvdimm@lists.linux.dev, linux-acpi@vger.kernel.org,
linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org,
stable@vger.kernel.org,
syzbot+c80d8dc0d9fa81a3cd8c@syzkaller.appspotmail.com
Subject: Re: [PATCH] acpi: nfit: fix narrowing conversion in acpi_nfit_ctl
Date: Thu, 23 Jan 2025 16:43:21 -0700 [thread overview]
Message-ID: <649ed1bb-0686-42f0-802f-9f1909aeed8c@intel.com> (raw)
In-Reply-To: <20250123163945.251-1-m.masimov@mt-integration.ru>
On 1/23/25 9:39 AM, Murad Masimov wrote:
> Syzkaller has reported a warning in to_nfit_bus_uuid(): "only secondary
> bus families can be translated". This warning is emited if the argument
> is equal to NVDIMM_BUS_FAMILY_NFIT == 0. Function acpi_nfit_ctl() first
> verifies that a user-provided value call_pkg->nd_family of type u64 is
> not equal to 0. Then the value is converted to int, and only after that
> is compared to NVDIMM_BUS_FAMILY_MAX. This can lead to passing an invalid
> argument to acpi_nfit_ctl(), if call_pkg->nd_family is non-zero, while
> the lower 32 bits are zero.
>
> All checks of the input value should be applied to the original variable
> call_pkg->nd_family.
>
> Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
>
> Fixes: 6450ddbd5d8e ("ACPI: NFIT: Define runtime firmware activation commands")
> Cc: stable@vger.kernel.org
> Reported-by: syzbot+c80d8dc0d9fa81a3cd8c@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=c80d8dc0d9fa81a3cd8c
> Signed-off-by: Murad Masimov <m.masimov@mt-integration.ru>
While the change logically makes sense, the likelihood of nd_family > int_size is not ever likely. Given that NVDIMM_BUS_FAMILY_MAX is defined as 1, I don't think we care about values greater than that regardless of what is set in the upper 32bit of the u64. I'm leaning towards the fix is unnecessary.
> ---
> drivers/acpi/nfit/core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
> index a5d47819b3a4..ae035b93da08 100644
> --- a/drivers/acpi/nfit/core.c
> +++ b/drivers/acpi/nfit/core.c
> @@ -485,7 +485,7 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm,
> cmd_mask = nd_desc->cmd_mask;
> if (cmd == ND_CMD_CALL && call_pkg->nd_family) {
> family = call_pkg->nd_family;
> - if (family > NVDIMM_BUS_FAMILY_MAX ||
> + if (call_pkg->nd_family > NVDIMM_BUS_FAMILY_MAX ||
> !test_bit(family, &nd_desc->bus_family_mask))
> return -EINVAL;
> family = array_index_nospec(family,
> --
> 2.39.2
>
next prev parent reply other threads:[~2025-01-23 23:43 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-23 16:39 [PATCH] acpi: nfit: fix narrowing conversion in acpi_nfit_ctl Murad Masimov
2025-01-23 23:43 ` Dave Jiang [this message]
2025-01-24 14:17 ` Murad Masimov
2025-01-24 16:58 ` Alison Schofield
2025-01-24 18:53 ` Ira Weiny
2025-01-27 18:37 ` Murad Masimov
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=649ed1bb-0686-42f0-802f-9f1909aeed8c@intel.com \
--to=dave.jiang@intel.com \
--cc=dan.j.williams@intel.com \
--cc=ira.weiny@intel.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lvc-project@linuxtesting.org \
--cc=m.masimov@mt-integration.ru \
--cc=nvdimm@lists.linux.dev \
--cc=rafael@kernel.org \
--cc=stable@vger.kernel.org \
--cc=syzbot+c80d8dc0d9fa81a3cd8c@syzkaller.appspotmail.com \
--cc=vishal.l.verma@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox