All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Suma Hegde <suma.hegde@amd.com>
Cc: platform-driver-x86@vger.kernel.org,
	Hans de Goede <hdegoede@redhat.com>,
	 Naveen Krishna Chatradhi <naveenkrishna.chatradhi@amd.com>
Subject: Re: [v5 11/11] platform/x86/amd/hsmp: Fix potential spectre issue
Date: Fri, 23 Aug 2024 16:54:53 +0300 (EEST)	[thread overview]
Message-ID: <b26f3a01-7c5d-70f8-88fa-2128a8aa18ea@linux.intel.com> (raw)
In-Reply-To: <20240823075543.884265-11-suma.hegde@amd.com>

On Fri, 23 Aug 2024, Suma Hegde wrote:

> Fix below warning caused by smatch by using array_index_nospec()
> to clamp the index within the range.
> "warn: potential spectre issue 'plat_dev.sock' [r] (local cap)"

While the warning have always been bogus for these code paths because
those are not user controllable values, I suspect the warning might no 
longer trigger at all. I suspect the warning is tied to kstr*() which is 
no longer used.

Also, it should be hsmp_pdev but please retest if this patch can be 
dropped from this series (no need to resend the entire series because of 
that, just mention if this patch can be left out).

-- 
 i.


> 
> Signed-off-by: Suma Hegde <suma.hegde@amd.com>
> Reviewed-by: Naveen Krishna Chatradhi <naveenkrishna.chatradhi@amd.com>
> ---
> Changes since v4:
> None
> 
> Changes since v3:
> None
> 
> Changes since v2:
> None
> 
> Changes since v1:
> Change plat_dev to hsmp_pdev
> 
>  drivers/platform/x86/amd/hsmp/acpi.c | 3 +++
>  drivers/platform/x86/amd/hsmp/plat.c | 3 +++
>  2 files changed, 6 insertions(+)
> 
> diff --git a/drivers/platform/x86/amd/hsmp/acpi.c b/drivers/platform/x86/amd/hsmp/acpi.c
> index f2bfc5981590..16a82b8bce28 100644
> --- a/drivers/platform/x86/amd/hsmp/acpi.c
> +++ b/drivers/platform/x86/amd/hsmp/acpi.c
> @@ -18,6 +18,7 @@
>  #include <linux/ioport.h>
>  #include <linux/kstrtox.h>
>  #include <linux/module.h>
> +#include <linux/nospec.h>
>  #include <linux/platform_device.h>
>  #include <linux/sysfs.h>
>  #include <linux/uuid.h>
> @@ -272,6 +273,8 @@ static int init_acpi(struct device *dev)
>  	if (sock_ind >= hsmp_pdev.num_sockets)
>  		return -EINVAL;
>  
> +	sock_ind = array_index_nospec(sock_ind, hsmp_pdev.num_sockets);
> +
>  	ret = hsmp_parse_acpi_table(dev, sock_ind);
>  	if (ret) {
>  		dev_err(dev, "Failed to parse ACPI table\n");
> diff --git a/drivers/platform/x86/amd/hsmp/plat.c b/drivers/platform/x86/amd/hsmp/plat.c
> index d55c984a9a5a..8fb395e91806 100644
> --- a/drivers/platform/x86/amd/hsmp/plat.c
> +++ b/drivers/platform/x86/amd/hsmp/plat.c
> @@ -15,6 +15,7 @@
>  #include <linux/device.h>
>  #include <linux/module.h>
>  #include <linux/pci.h>
> +#include <linux/nospec.h>
>  #include <linux/platform_device.h>
>  #include <linux/sysfs.h>
>  
> @@ -79,6 +80,8 @@ static ssize_t hsmp_metric_tbl_read(struct file *filp, struct kobject *kobj,
>  	if (sock_ind >= hsmp_pdev.num_sockets)
>  		return -EINVAL;
>  
> +	sock_ind = array_index_nospec(sock_ind, hsmp_pdev.num_sockets);
> +
>  	sock = &hsmp_pdev.sock[sock_ind];
>  	if (!sock)
>  		return -EINVAL;
> 


  reply	other threads:[~2024-08-23 13:54 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-23  7:55 [v5 01/11] platform/x86/amd/hsmp: Create hsmp/ directory Suma Hegde
2024-08-23  7:55 ` [v5 02/11] platform/x86/amd/hsmp: Create wrapper function init_acpi() Suma Hegde
2024-08-23  7:55 ` [v5 03/11] platform/x86/amd/hsmp: Convert amd_hsmp_rdwr() to a function pointer Suma Hegde
2024-08-23  7:55 ` [v5 04/11] platform/x86/amd/hsmp: Move structure and macros to header file Suma Hegde
2024-08-23  7:55 ` [v5 05/11] platform/x86/amd/hsmp: Move platform device specific code to plat.c Suma Hegde
2024-08-23  7:55 ` [v5 06/11] platform/x86/amd/hsmp: Move ACPI code to acpi.c Suma Hegde
2024-08-23  7:55 ` [v5 07/11] platform/x86/amd/hsmp: Change generic plat_dev name to hsmp_pdev Suma Hegde
2024-08-23  7:55 ` [v5 08/11] platform/x86/amd/hsmp: Create mutually exclusive ACPI and plat drivers Suma Hegde
2024-08-26 13:47   ` Ilpo Järvinen
2024-08-23  7:55 ` [v5 09/11] platform/x86/amd/hsmp: Use name space while exporting module symbols Suma Hegde
2024-08-23  7:55 ` [v5 10/11] platform/x86/amd/hsmp: Use dev_groups in the driver structure Suma Hegde
2024-08-26 16:27   ` Ilpo Järvinen
2024-08-23  7:55 ` [v5 11/11] platform/x86/amd/hsmp: Fix potential spectre issue Suma Hegde
2024-08-23 13:54   ` Ilpo Järvinen [this message]
2024-08-26  5:38     ` Suma Hegde

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=b26f3a01-7c5d-70f8-88fa-2128a8aa18ea@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=hdegoede@redhat.com \
    --cc=naveenkrishna.chatradhi@amd.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=suma.hegde@amd.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.