perf/core: Fix perf_mmap fail when CONFIG_PERF_USE_VMALLOC enabled
Zhipeng Xie authored
[ Upstream commit 60490e79 ]

This problem can be reproduced with CONFIG_PERF_USE_VMALLOC enabled on
both x86_64 and aarch64 arch when using sysdig -B(using ebpf)[1].
sysdig -B works fine after rebuilding the kernel with
CONFIG_PERF_USE_VMALLOC disabled.

I tracked it down to the if condition event->rb->nr_pages != nr_pages
in perf_mmap is true when CONFIG_PERF_USE_VMALLOC is enabled where
event->rb->nr_pages = 1 and nr_pages = 2048 resulting perf_mmap to
return -EINVAL. This is because when CONFIG_PERF_USE_VMALLOC is
enabled, rb->nr_pages is always equal to 1.

Arch with CONFIG_PERF_USE_VMALLOC enabled by default:
	arc/arm/csky/mips/sh/sparc/xtensa

Arch with CONFIG_PERF_USE_VMALLOC disabled by default:
	x86_64/aarch64/...

Fix this problem by using data_page_nr()

[1] https://github.com/draios/sysdig

Fixes: 906010b2 ("perf_event: Provide vmalloc() based mmap() backing")
Signed-off-by: Zhipeng Xie <xie...
9c7fd841
Name Last commit Last update
Documentation dt-bindings: net: snps: remove duplicate name
LICENSES LICENSES/LGPL-2.1: Add LGPL-2.1-or-later as valid identifiers
arch stat: fix inconsistency between struct stat and struct compat_stat
block block/compat_ioctl: fix range check in BLKGETSIZE
certs certs: Fix build error when CONFIG_MODULE_SIG_KEY is empty
crypto crypto: xts - Add softdep on ecb
drivers scsi: sr: Do not leak information in ioctl
fs io_uring: free iovec if file assignment fails
include oom_kill.c: futex: delay the OOM reaper to allow time for proper futex cleanup
init init/main.c: return 1 from handled __setup() functions
ipc ipc/sem: do not sleep with a spin lock held
kernel perf/core: Fix perf_mmap fail when CONFIG_PERF_USE_VMALLOC enabled
lib XArray: Disallow sibling entries of nodes
mm mm/mmu_notifier.c: fix race in mmu_interval_notifier_remove()
net netlink: reset network and mac headers in netlink_dump()
samples samples/bpf, xdpsock: Fix race when running for fix duration of time
scripts gcc-plugins: latent_entropy: use /dev/urandom
security Fix incorrect type in assignment of ipv6 port for audit
sound ALSA: hda: intel-dsp-config: update AlderLake PCI IDs
tools selftests: KVM: Free the GIC FD when cleaning up in arch_timer
usr kbuild: remove include/linux/cyclades.h from header file check
virt KVM: avoid NULL pointer dereference in kvm_dirty_ring_push
.clang-format genirq/msi: Make interrupt allocation less convoluted
.cocciconfig scripts: add Linux .cocciconfig for coccinelle
.get_maintainer.ignore Opt out of scripts/get_maintainer.pl
.gitattributes .gitattributes: use 'dts' diff driver for dts files
.gitignore .gitignore: ignore only top-level modules.builtin
.mailmap MAINTAINERS: Update Jisheng's email address
COPYING COPYING: state that all contributions really are covered by this file
CREDITS MAINTAINERS: replace a Microchip AT91 maintainer
Kbuild kbuild: rename hostprogs-y/always to hostprogs/always-y
Kconfig kbuild: ensure full rebuild when the compiler is updated
MAINTAINERS net: dsa: realtek-smi: move to subdirectory
Makefile Linux 5.17.4
README Drop all 00-INDEX files from Documentation/
Linux kernel
============

There are several guides for kernel developers and users. These guides can
be rendered in a number of formats, like HTML and PDF. Please read
Documentation/admin-guide/README.rst first.

In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``.  The formatted documentation can also be read online at:

    https://www.kernel.org/doc/html/latest/

There are various text files in the Documentation/ subdirectory,
several of them using the Restructured Text markup notation.

Please read the Documentation/process/changes.rst file, as it contains the
requirements for building and running the kernel, and information about
the problems which may result by upgrading your kernel.