Re: [PATCH v3 25/34] s390/diag: Unpoison diag224() output buffer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Dec 14, 2023 at 12:24:45AM +0100, Ilya Leoshkevich wrote:
> Diagnose 224 stores 4k bytes, which cannot be deduced from the inline
> assembly constraints. This leads to KMSAN false positives.
> 
> Unpoison the output buffer manually with kmsan_unpoison_memory().
> 
> Signed-off-by: Ilya Leoshkevich <iii@xxxxxxxxxxxxx>
> ---
>  arch/s390/kernel/diag.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/arch/s390/kernel/diag.c b/arch/s390/kernel/diag.c
> index 92fdc35f028c..fb83a21014d0 100644
> --- a/arch/s390/kernel/diag.c
> +++ b/arch/s390/kernel/diag.c
> @@ -9,6 +9,7 @@
>  #include <linux/export.h>
>  #include <linux/init.h>
>  #include <linux/cpu.h>
> +#include <linux/kmsan-checks.h>
>  #include <linux/seq_file.h>
>  #include <linux/debugfs.h>
>  #include <linux/vmalloc.h>
> @@ -255,6 +256,7 @@ int diag224(void *ptr)
>  		"1:\n"
>  		EX_TABLE(0b,1b)
>  		: "+d" (rc) :"d" (0), "d" (addr) : "memory");
> +	kmsan_unpoison_memory(ptr, PAGE_SIZE);

Wouldn't it be better to adjust the inline assembly instead?
Something like this:

diff --git a/arch/s390/kernel/diag.c b/arch/s390/kernel/diag.c
index 92fdc35f028c..b1b0acda50c6 100644
--- a/arch/s390/kernel/diag.c
+++ b/arch/s390/kernel/diag.c
@@ -247,14 +247,18 @@ int diag224(void *ptr)
 {
 	unsigned long addr = __pa(ptr);
 	int rc = -EOPNOTSUPP;
+	struct _d {
+		char _d[4096];
+	};
 
 	diag_stat_inc(DIAG_STAT_X224);
-	asm volatile(
-		"	diag	%1,%2,0x224\n"
-		"0:	lhi	%0,0x0\n"
+	asm volatile("\n"
+		"	diag	%[type],%[addr],0x224\n"
+		"0:	lhi	%[rc],0\n"
 		"1:\n"
 		EX_TABLE(0b,1b)
-		: "+d" (rc) :"d" (0), "d" (addr) : "memory");
+		: [rc] "+d" (rc), "=m" (*(struct _d *)ptr)
+		: [type] "d" (0), [addr] "d" (addr));
 	return rc;
 }
 EXPORT_SYMBOL(diag224);




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Kernel Development]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Info]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Linux Media]     [Device Mapper]

  Powered by Linux