Revision 72cd652b73dd77df6f26bd450e804ee29232669f authored by Athira Rajeev on 05 September 2022, 14:19:28 UTC, committed by Arnaldo Carvalho de Melo on 06 September 2022, 12:45:23 UTC
The affinity code in "affinity_set" function access array named
"sched_cpus". The size for this array is allocated in affinity_setup
function which is nothing but value from get_cpu_set_size. This is used
to contain the cpumask value for each cpu.

While setting bit for each cpu, it calls "set_bit" function which access
index in sched_cpus array.  If we provide a command-line option to -C
which is more than the number of CPU's present in the system, the
set_bit could access an array member which is out-of the array size.
This is because currently, there is no boundary check for the CPU.  This
will result in seg fault:

<<>>
   ./perf stat -C 12323431 ls
  Perf can support 2048 CPUs. Consider raising MAX_NR_CPUS
  Segmentation fault (core dumped)
<<>>

Fix this by adding boundary check for the array.

After the fix from powerpc system:

<<>>
  ./perf stat -C 12323431 ls 1>out
  Perf can support 2048 CPUs. Consider raising MAX_NR_CPUS

   Performance counter stats for 'CPU(s) 12323431':

     <not supported> msec cpu-clock
     <not supported>      context-switches
     <not supported>      cpu-migrations
     <not supported>      page-faults
     <not supported>      cycles
     <not supported>      instructions
     <not supported>      branches
     <not supported>      branch-misses

         0.001192373 seconds time elapsed
<<>>

Reported-by: Nageswara R Sastry <rnsastry@linux.ibm.com>
Signed-off-by: Athira Jajeev <atrajeev@linux.vnet.ibm.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Nageswara R Sastry <rnsastry@linux.ibm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: linuxppc-dev@lists.ozlabs.org
Link: https://lore.kernel.org/r/20220905141929.7171-1-atrajeev@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent f0c86a2
History
File Mode Size
damon
kasan
kfence
Kconfig -rw-r--r-- 34.9 KB
Kconfig.debug -rw-r--r-- 7.7 KB
Makefile -rw-r--r-- 4.9 KB
backing-dev.c -rw-r--r-- 24.7 KB
balloon_compaction.c -rw-r--r-- 8.2 KB
bootmem_info.c -rw-r--r-- 3.4 KB
cma.c -rw-r--r-- 15.5 KB
cma.h -rw-r--r-- 1.4 KB
cma_debug.c -rw-r--r-- 4.5 KB
cma_sysfs.c -rw-r--r-- 2.4 KB
compaction.c -rw-r--r-- 84.1 KB
debug.c -rw-r--r-- 6.8 KB
debug_page_ref.c -rw-r--r-- 1.4 KB
debug_vm_pgtable.c -rw-r--r-- 38.8 KB
dmapool.c -rw-r--r-- 13.6 KB
early_ioremap.c -rw-r--r-- 6.7 KB
fadvise.c -rw-r--r-- 5.5 KB
failslab.c -rw-r--r-- 1.4 KB
filemap.c -rw-r--r-- 110.7 KB
folio-compat.c -rw-r--r-- 3.3 KB
frontswap.c -rw-r--r-- 7.9 KB
gup.c -rw-r--r-- 90.6 KB
gup_test.c -rw-r--r-- 5.6 KB
gup_test.h -rw-r--r-- 938 bytes
highmem.c -rw-r--r-- 19.5 KB
hmm.c -rw-r--r-- 16.7 KB
huge_memory.c -rw-r--r-- 86.2 KB
hugetlb.c -rw-r--r-- 201.1 KB
hugetlb_cgroup.c -rw-r--r-- 24.6 KB
hugetlb_vmemmap.c -rw-r--r-- 15.8 KB
hugetlb_vmemmap.h -rw-r--r-- 1.6 KB
hwpoison-inject.c -rw-r--r-- 2.7 KB
init-mm.c -rw-r--r-- 1.6 KB
internal.h -rw-r--r-- 27.6 KB
interval_tree.c -rw-r--r-- 3.1 KB
io-mapping.c -rw-r--r-- 993 bytes
ioremap.c -rw-r--r-- 1.4 KB
khugepaged.c -rw-r--r-- 59.1 KB
kmemleak.c -rw-r--r-- 59.9 KB
ksm.c -rw-r--r-- 89.2 KB
list_lru.c -rw-r--r-- 13.8 KB
maccess.c -rw-r--r-- 5.8 KB
madvise.c -rw-r--r-- 37.6 KB
mapping_dirty_helpers.c -rw-r--r-- 10.5 KB
memblock.c -rw-r--r-- 61.1 KB
memcontrol.c -rw-r--r-- 197.8 KB
memfd.c -rw-r--r-- 8.2 KB
memory-failure.c -rw-r--r-- 68.3 KB
memory.c -rw-r--r-- 158.3 KB
memory_hotplug.c -rw-r--r-- 64.0 KB
mempolicy.c -rw-r--r-- 77.8 KB
mempool.c -rw-r--r-- 15.8 KB
memremap.c -rw-r--r-- 14.4 KB
memtest.c -rw-r--r-- 2.8 KB
migrate.c -rw-r--r-- 68.4 KB
migrate_device.c -rw-r--r-- 23.4 KB
mincore.c -rw-r--r-- 7.1 KB
mlock.c -rw-r--r-- 19.0 KB
mm_init.c -rw-r--r-- 5.3 KB
mmap.c -rw-r--r-- 100.4 KB
mmap_lock.c -rw-r--r-- 6.2 KB
mmu_gather.c -rw-r--r-- 8.8 KB
mmu_notifier.c -rw-r--r-- 35.3 KB
mmzone.c -rw-r--r-- 2.5 KB
mprotect.c -rw-r--r-- 22.3 KB
mremap.c -rw-r--r-- 28.1 KB
msync.c -rw-r--r-- 2.8 KB
nommu.c -rw-r--r-- 44.4 KB
oom_kill.c -rw-r--r-- 33.5 KB
page-writeback.c -rw-r--r-- 93.0 KB
page_alloc.c -rw-r--r-- 267.8 KB
page_counter.c -rw-r--r-- 6.7 KB
page_ext.c -rw-r--r-- 11.2 KB
page_idle.c -rw-r--r-- 5.2 KB
page_io.c -rw-r--r-- 12.7 KB
page_isolation.c -rw-r--r-- 20.7 KB
page_owner.c -rw-r--r-- 16.9 KB
page_poison.c -rw-r--r-- 2.5 KB
page_reporting.c -rw-r--r-- 10.3 KB
page_reporting.h -rw-r--r-- 1.6 KB
page_table_check.c -rw-r--r-- 5.8 KB
page_vma_mapped.c -rw-r--r-- 8.6 KB
pagewalk.c -rw-r--r-- 15.5 KB
percpu-internal.h -rw-r--r-- 7.0 KB
percpu-km.c -rw-r--r-- 3.2 KB
percpu-stats.c -rw-r--r-- 5.8 KB
percpu-vm.c -rw-r--r-- 11.7 KB
percpu.c -rw-r--r-- 102.5 KB
pgalloc-track.h -rw-r--r-- 1.3 KB
pgtable-generic.c -rw-r--r-- 5.8 KB
process_vm_access.c -rw-r--r-- 8.2 KB
ptdump.c -rw-r--r-- 4.2 KB
readahead.c -rw-r--r-- 25.3 KB
rmap.c -rw-r--r-- 72.7 KB
rodata_test.c -rw-r--r-- 1.3 KB
secretmem.c -rw-r--r-- 6.4 KB
shmem.c -rw-r--r-- 110.6 KB
shrinker_debug.c -rw-r--r-- 6.2 KB
shuffle.c -rw-r--r-- 4.7 KB
shuffle.h -rw-r--r-- 1.2 KB
slab.c -rw-r--r-- 105.6 KB
slab.h -rw-r--r-- 22.4 KB
slab_common.c -rw-r--r-- 32.7 KB
slob.c -rw-r--r-- 18.8 KB
slub.c -rw-r--r-- 154.9 KB
sparse-vmemmap.c -rw-r--r-- 10.2 KB
sparse.c -rw-r--r-- 25.6 KB
swap.c -rw-r--r-- 30.3 KB
swap.h -rw-r--r-- 4.0 KB
swap_cgroup.c -rw-r--r-- 5.1 KB
swap_slots.c -rw-r--r-- 9.2 KB
swap_state.c -rw-r--r-- 23.9 KB
swapfile.c -rw-r--r-- 92.2 KB
truncate.c -rw-r--r-- 26.2 KB
usercopy.c -rw-r--r-- 8.1 KB
userfaultfd.c -rw-r--r-- 18.8 KB
util.c -rw-r--r-- 30.5 KB
vmacache.c -rw-r--r-- 2.7 KB
vmalloc.c -rw-r--r-- 107.5 KB
vmpressure.c -rw-r--r-- 13.9 KB
vmscan.c -rw-r--r-- 139.4 KB
vmstat.c -rw-r--r-- 55.1 KB
workingset.c -rw-r--r-- 21.8 KB
z3fold.c -rw-r--r-- 44.6 KB
zbud.c -rw-r--r-- 18.4 KB
zpool.c -rw-r--r-- 11.2 KB
zsmalloc.c -rw-r--r-- 57.0 KB
zswap.c -rw-r--r-- 39.9 KB

back to top