lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230809214741.n4k5rmnw7an4dfdr@desk>
Date:   Wed, 9 Aug 2023 14:47:41 -0700
From:   Pawan Gupta <pawan.kumar.gupta@...ux.intel.com>
To:     Borislav Petkov <bp@...en8.de>
Cc:     X86 ML <x86@...nel.org>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        LKML <linux-kernel@...r.kernel.org>,
        Linus Torvalds <torvalds@...ux-foundation.org>
Subject: Re: [PATCH 2/3] driver core: cpu: Unify redundant silly stubs

On Wed, Aug 09, 2023 at 12:26:59PM +0200, Borislav Petkov wrote:
> From: "Borislav Petkov (AMD)" <bp@...en8.de>
> 
> Make them all a weak function, aliasing to a single function which
> issues the "Not affected" string.
> 
> No functional changes.
> 
> Suggested-by: Linus Torvalds <torvalds@...ux-foundation.org>
> Signed-off-by: Borislav Petkov (AMD) <bp@...en8.de>
> ---
>  drivers/base/cpu.c | 86 ++++++++++------------------------------------
>  1 file changed, 18 insertions(+), 68 deletions(-)
> 
> diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
> index 52df435eecf8..971771347aa6 100644
> --- a/drivers/base/cpu.c
> +++ b/drivers/base/cpu.c
> @@ -509,79 +509,29 @@ static void __init cpu_dev_register_generic(void)
>  }
>  
>  #ifdef CONFIG_GENERIC_CPU_VULNERABILITIES
> -
> -ssize_t __weak cpu_show_meltdown(struct device *dev,
> -				 struct device_attribute *attr, char *buf)
> -{
> -	return sysfs_emit(buf, "Not affected\n");
> -}
> -
> -ssize_t __weak cpu_show_spectre_v1(struct device *dev,
> -				   struct device_attribute *attr, char *buf)
> -{
> -	return sysfs_emit(buf, "Not affected\n");
> -}
> -
> -ssize_t __weak cpu_show_spectre_v2(struct device *dev,
> -				   struct device_attribute *attr, char *buf)
> -{
> -	return sysfs_emit(buf, "Not affected\n");
> -}
> -
> -ssize_t __weak cpu_show_spec_store_bypass(struct device *dev,
> -					  struct device_attribute *attr, char *buf)
> -{
> -	return sysfs_emit(buf, "Not affected\n");
> -}
> -
> -ssize_t __weak cpu_show_l1tf(struct device *dev,
> -			     struct device_attribute *attr, char *buf)
> -{
> -	return sysfs_emit(buf, "Not affected\n");
> -}
> -
> -ssize_t __weak cpu_show_mds(struct device *dev,
> -			    struct device_attribute *attr, char *buf)
> -{
> -	return sysfs_emit(buf, "Not affected\n");
> -}
> -
> -ssize_t __weak cpu_show_tsx_async_abort(struct device *dev,
> -					struct device_attribute *attr,
> -					char *buf)
> -{
> -	return sysfs_emit(buf, "Not affected\n");
> -}
> -
> -ssize_t __weak cpu_show_itlb_multihit(struct device *dev,
> -				      struct device_attribute *attr, char *buf)
> -{
> -	return sysfs_emit(buf, "Not affected\n");
> -}
> -
> -ssize_t __weak cpu_show_srbds(struct device *dev,
> +ssize_t cpu_show_not_affected(struct device *dev,
>  			      struct device_attribute *attr, char *buf)
>  {
>  	return sysfs_emit(buf, "Not affected\n");
>  }
>  
> -ssize_t __weak cpu_show_mmio_stale_data(struct device *dev,
> -					struct device_attribute *attr, char *buf)
> -{
> -	return sysfs_emit(buf, "Not affected\n");
> -}
> -
> -ssize_t __weak cpu_show_retbleed(struct device *dev,
> -				 struct device_attribute *attr, char *buf)
> -{
> -	return sysfs_emit(buf, "Not affected\n");
> -}
> -
> -ssize_t __weak cpu_show_spec_rstack_overflow(struct device *dev,
> -					     struct device_attribute *attr, char *buf)
> -{
> -	return sysfs_emit(buf, "Not affected\n");
> -}
> +#define CPU_VULN_FALLBACK(func)						\

Nit, its not actually a vulnerability fallback, does
CPU_SHOW_VULN_FALLBACK() sound better?

> +	ssize_t cpu_show_##func(struct device *,			\
> +				  struct device_attribute *, char *)	\
> +		 __attribute__((weak, alias("cpu_show_not_affected")))
> +
> +CPU_VULN_FALLBACK(meltdown);
> +CPU_VULN_FALLBACK(spectre_v1);
> +CPU_VULN_FALLBACK(spectre_v2);
> +CPU_VULN_FALLBACK(spec_store_bypass);
> +CPU_VULN_FALLBACK(l1tf);
> +CPU_VULN_FALLBACK(mds);
> +CPU_VULN_FALLBACK(tsx_async_abort);
> +CPU_VULN_FALLBACK(itlb_multihit);
> +CPU_VULN_FALLBACK(srbds);
> +CPU_VULN_FALLBACK(mmio_stale_data);
> +CPU_VULN_FALLBACK(retbleed);
> +CPU_VULN_FALLBACK(spec_rstack_overflow);
>  
>  ssize_t __weak cpu_show_gds(struct device *dev,
>  			    struct device_attribute *attr, char *buf)

Do you want me to send a separate patch for this?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ