From: "Rao, Nikhil" <nikhirao@amd.com>
To: Simon Horman <horms@kernel.org>
Cc: netdev@vger.kernel.org, kuba@kernel.org, brett.creeley@amd.com,
eric.joyner@amd.com, andrew+netdev@lunn.ch, davem@davemloft.net,
edumazet@google.com, pabeni@redhat.com, jacob.e.keller@intel.com,
nikhil.rao@amd.com
Subject: Re: [PATCH 4/6] pds_core: add PLDM component info display
Date: Sat, 18 Jul 2026 16:06:49 -0700 [thread overview]
Message-ID: <321585a9-551e-4b5b-aa96-3fbc29aa65e6@amd.com> (raw)
In-Reply-To: <20260716072248.190353-2-horms@kernel.org>
On 7/16/2026 12:22 AM, Simon Horman wrote:
> This is an AI-generated review of your patch. The human sending this
> email has considered the AI review valid, or at least plausible.
> Full review at: https://sashiko.dev
> ---
> --- Patch [4]: [PATCH 4/6] pds_core: add PLDM component info display ---
> commit 4d0cc8aef76c7e2e30f98535495312200941b646
> Author: Brett Creeley <brett.creeley@amd.com>
>
> pds_core: add PLDM component info display
>
> Add detailed component information display via devlink info. This
> allows users to see individual firmware components and their versions.
> Components are reported as fixed, running, or stored based on their
> firmware-provided flags.
>
>> diff --git a/drivers/net/ethernet/amd/pds_core/devlink.c b/drivers/net/ethernet/amd/pds_core/devlink.c
>> index 3b763ee1715ee..63fe45e91f710 100644
>> --- a/drivers/net/ethernet/amd/pds_core/devlink.c
>> +++ b/drivers/net/ethernet/amd/pds_core/devlink.c
>
> [ ... ]
>
>> +static int pdsc_dl_component_info_get(struct devlink *dl,
>> + struct devlink_info_req *req,
>> + struct netlink_ext_ack *extack)
>> +{
>> + struct pdsc *pdsc = devlink_priv(dl);
>> + u8 num_components;
>> + int err;
>> + int i;
>> +
>> + /* Pairs with WRITE_ONCE in pdsc_fw_components_invalidate().
>> + * Use READ_ONCE to get a consistent snapshot of num_components.
>> + * pdsc_fw_components_invalidate() can zero it concurrently during
>> + * firmware recovery; using the local copy avoids iterating zero
>> + * times when we already decided the cache was valid.
>> + */
>> + num_components = READ_ONCE(pdsc->fw_components.num_components);
>> + if (!num_components) {
>> + err = pdsc_get_component_info(pdsc);
>
> [Severity: High]
> Does this code expose uninitialized memory to concurrent readers?
>
> If two threads execute this concurrently after the firmware component list
> has been invalidated, one thread could enter pdsc_get_component_info(),
> which updates the count before the array is populated:
>
> drivers/net/ethernet/amd/pds_core/fw.c:pdsc_get_component_info() {
> ...
> pdsc->fw_components.num_components = num_components;
> for (i = 0; i < num_components; i++) {
> struct pds_core_fw_component_info *info =
> &pdsc->fw_components.info[i];
>
> memcpy(info, &list_info->info[i], sizeof(*info));
> ...
> }
>
> A second thread could concurrently execute pdsc_dl_component_info_get(), see
> num_components > 0 via READ_ONCE(), and proceed to iterate over the array
> while the first thread is still executing memcpy() into the array.
>
> Could this be addressed by moving the update of num_components to after the
> array population is complete, perhaps using smp_store_release() and
> smp_load_acquire() to ensure proper ordering?
>
>> + if (err)
>> + return pdsc_dl_report_fw_ver(req,
>> + pdsc->dev_info.fw_version);
>> + num_components = READ_ONCE(pdsc->fw_components.num_components);
>> + if (!num_components)
>> + return pdsc_dl_report_fw_ver(req,
>> + pdsc->dev_info.fw_version);
>> + }
>> +
>> + num_components = min_t(u16, num_components,
>> + le16_to_cpu(pdsc->dev_ident.max_fw_slots));
>> + for (i = 0; i < num_components; i++) {
>> + err = pdsc_dl_report_component(req,
>> + &pdsc->fw_components.info[i]);
>> + if (err)
>> + return err;
>> + }
>> +
>> + return 0;
>> +}
Not a bug. devl_lock serializes the .info_get
ops on the instance, so the two concurrent executions of
pdsc_dl_component_info_get described above cannot occur
Thanks,
Nikhil
next prev parent reply other threads:[~2026-07-18 23:06 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-08 21:22 [PATCH net-next v7 0/6] pds_core: Add PLDM firmware update and host backed memory support Nikhil P. Rao
2026-07-08 21:22 ` [PATCH 1/6] pds_core: add support for quiet devcmd failures Nikhil P. Rao
2026-07-16 7:17 ` Simon Horman
2026-07-18 22:21 ` Rao, Nikhil
2026-07-08 21:22 ` [PATCH 2/6] pds_core: add support for identity version 2 Nikhil P. Rao
2026-07-08 21:22 ` [PATCH 3/6] pds_core: add PLDM firmware update support via devlink flash Nikhil P. Rao
2026-07-16 7:20 ` Simon Horman
2026-07-18 22:34 ` Rao, Nikhil
2026-07-08 21:22 ` [PATCH 4/6] pds_core: add PLDM component info display Nikhil P. Rao
2026-07-16 7:22 ` Simon Horman
2026-07-18 23:06 ` Rao, Nikhil [this message]
2026-07-08 21:22 ` [PATCH 5/6] pds_core: add host backed memory support for firmware Nikhil P. Rao
2026-07-16 7:23 ` Simon Horman
2026-07-18 23:16 ` Rao, Nikhil
2026-07-16 7:23 ` Simon Horman
2026-07-08 21:22 ` [PATCH 6/6] pds_core: add debugfs support for host backed memory Nikhil P. Rao
-- strict thread matches above, loose matches on Subject: below --
2026-04-29 7:58 [PATCH 0/6] pds_core: Add PLDM firmware update and host backed memory support Nikhil P. Rao
2026-04-29 7:58 ` [PATCH 4/6] pds_core: add PLDM component info display Nikhil P. Rao
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=321585a9-551e-4b5b-aa96-3fbc29aa65e6@amd.com \
--to=nikhirao@amd.com \
--cc=andrew+netdev@lunn.ch \
--cc=brett.creeley@amd.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=eric.joyner@amd.com \
--cc=horms@kernel.org \
--cc=jacob.e.keller@intel.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nikhil.rao@amd.com \
--cc=pabeni@redhat.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