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:
 <SN6PR02MB4157D73B5BF7161B3A5596EED43A2@SN6PR02MB4157.namprd02.prod.outlook.com>
Date: Fri, 29 Mar 2024 22:59:46 +0000
From: Michael Kelley <mhklinux@...look.com>
To: Dexuan Cui <decui@...rosoft.com>, "hch@....de" <hch@....de>,
	"m.szyprowski@...sung.com" <m.szyprowski@...sung.com>, "robin.murphy@....com"
	<robin.murphy@....com>, "zhangpeng362@...wei.com" <zhangpeng362@...wei.com>,
	"iommu@...ts.linux.dev" <iommu@...ts.linux.dev>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"stable@...r.kernel.org" <stable@...r.kernel.org>
Subject: RE: [PATCH] swiotlb: Do not set total_used to 0 in
 swiotlb_create_debugfs_files()

From: Dexuan Cui <decui@...rosoft.com> Sent: Friday, March 29, 2024 12:28 PM
> 
> Sometimes the readout of /sys/kernel/debug/swiotlb/io_tlb_used and
> io_tlb_used_hiwater can be a huge number (e.g. 18446744073709551615),
> which is actually a negative number if we use "%ld" to print the number.
> 
> When swiotlb_create_default_debugfs() is running from late_initcall,
> mem->total_used may already be non-zero, because the storage driver
> may have already started to perform I/O operations: if the storage
> driver is built-in, its probe() callback is called before late_initcall.
> 
> swiotlb_create_debugfs_files() should not blindly set mem->total_used
> and mem->used_hiwater to 0; actually it doesn't have to initialize the
> fields at all, because the fields, as part of the global struct
> io_tlb_default_mem, have been implicitly initialized to zero.
> 
> Also don't explicitly set mem->transient_nslabs to 0.
> 
> Fixes: 8b0977ecc8b3 ("swiotlb: track and report io_tlb_used high water marks in debugfs")
> Fixes: 02e765697038 ("swiotlb: add debugfs to track swiotlb transient pool usage")
> Cc: stable@...r.kernel.org
> Signed-off-by: Dexuan Cui <decui@...rosoft.com>
> ---
>  kernel/dma/swiotlb.c | 4 ----
>  1 file changed, 4 deletions(-)
> 
> diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c
> index 86fe172b5958..4a9f02c13da6 100644
> --- a/kernel/dma/swiotlb.c
> +++ b/kernel/dma/swiotlb.c
> @@ -1647,9 +1647,6 @@
> DEFINE_DEBUGFS_ATTRIBUTE(fops_io_tlb_hiwater, io_tlb_hiwater_get,
>  static void swiotlb_create_debugfs_files(struct io_tlb_mem *mem,
>  					 const char *dirname)
>  {
> -	atomic_long_set(&mem->total_used, 0);
> -	atomic_long_set(&mem->used_hiwater, 0);
> -
>  	mem->debugfs = debugfs_create_dir(dirname, io_tlb_default_mem.debugfs);
>  	if (!mem->nslabs)
>  		return;
> @@ -1660,7 +1657,6 @@ static void swiotlb_create_debugfs_files(struct io_tlb_mem *mem,
>  	debugfs_create_file("io_tlb_used_hiwater", 0600, mem->debugfs, mem,
>  			&fops_io_tlb_hiwater);
>  #ifdef CONFIG_SWIOTLB_DYNAMIC
> -	atomic_long_set(&mem->transient_nslabs, 0);
>  	debugfs_create_file("io_tlb_transient_nslabs", 0400, mem->debugfs,
>  			    mem, &fops_io_tlb_transient_used);
>  #endif
> --
> 2.34.1

Reviewed-by: Michael Kelley <mhklinux@...look.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ