https://github.com/torvalds/linux
Revision d7f06bdd6ee87fbefa05af5f57361d85e7715b11 authored by Phil Auld on 06 September 2022, 20:35:42 UTC, committed by Greg Kroah-Hartman on 22 September 2022, 11:13:12 UTC
As PAGE_SIZE is unsigned long, -1 > PAGE_SIZE when NR_CPUS <= 3.
This leads to very large file sizes:

topology$ ls -l
total 0
-r--r--r-- 1 root root 18446744073709551615 Sep  5 11:59 core_cpus
-r--r--r-- 1 root root                 4096 Sep  5 11:59 core_cpus_list
-r--r--r-- 1 root root                 4096 Sep  5 10:58 core_id
-r--r--r-- 1 root root 18446744073709551615 Sep  5 10:10 core_siblings
-r--r--r-- 1 root root                 4096 Sep  5 11:59 core_siblings_list
-r--r--r-- 1 root root 18446744073709551615 Sep  5 11:59 die_cpus
-r--r--r-- 1 root root                 4096 Sep  5 11:59 die_cpus_list
-r--r--r-- 1 root root                 4096 Sep  5 11:59 die_id
-r--r--r-- 1 root root 18446744073709551615 Sep  5 11:59 package_cpus
-r--r--r-- 1 root root                 4096 Sep  5 11:59 package_cpus_list
-r--r--r-- 1 root root                 4096 Sep  5 10:58 physical_package_id
-r--r--r-- 1 root root 18446744073709551615 Sep  5 10:10 thread_siblings
-r--r--r-- 1 root root                 4096 Sep  5 11:59 thread_siblings_list

Adjust the inequality to catch the case when NR_CPUS is configured
to a small value.

Fixes: 7ee951acd31a ("drivers/base: fix userspace break from using bin_attributes for cpumap and cpulist")
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Yury Norov <yury.norov@gmail.com>
Cc: stable@vger.kernel.org
Cc: feng xiangjun <fengxj325@gmail.com>
Reported-by: feng xiangjun <fengxj325@gmail.com>
Signed-off-by: Phil Auld <pauld@redhat.com>
Signed-off-by: Yury Norov <yury.norov@gmail.com>
Link: https://lore.kernel.org/r/20220906203542.1796629-1-pauld@redhat.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent d8ab468
History
Tip revision: d7f06bdd6ee87fbefa05af5f57361d85e7715b11 authored by Phil Auld on 06 September 2022, 20:35:42 UTC
drivers/base: Fix unsigned comparison to -1 in CPUMAP_FILE_MAX_BYTES
Tip revision: d7f06bd
File Mode Size
Kconfig -rw-r--r-- 6.3 KB
Makefile -rw-r--r-- 450 bytes
coherent.c -rw-r--r-- 10.9 KB
contiguous.c -rw-r--r-- 12.6 KB
debug.c -rw-r--r-- 41.3 KB
debug.h -rw-r--r-- 3.6 KB
direct.c -rw-r--r-- 17.7 KB
direct.h -rw-r--r-- 4.1 KB
dummy.c -rw-r--r-- 946 bytes
map_benchmark.c -rw-r--r-- 8.6 KB
mapping.c -rw-r--r-- 23.9 KB
ops_helpers.c -rw-r--r-- 2.5 KB
pool.c -rw-r--r-- 7.5 KB
remap.c -rw-r--r-- 1.6 KB
swiotlb.c -rw-r--r-- 28.6 KB

back to top