Go to file
Arnaldo Carvalho de Melo c1748a6d6c perf top: Don't pass an ERR_PTR() directly to perf_session__delete()
BugLink: https://bugs.launchpad.net/bugs/2040284

[ Upstream commit ef23cb593304bde0cc046fd4cc83ae7ea2e24f16 ]

While debugging a segfault on 'perf lock contention' without an
available perf.data file I noticed that it was basically calling:

	perf_session__delete(ERR_PTR(-1))

Resulting in:

  (gdb) run lock contention
  Starting program: /root/bin/perf lock contention
  [Thread debugging using libthread_db enabled]
  Using host libthread_db library "/lib64/libthread_db.so.1".
  failed to open perf.data: No such file or directory  (try 'perf record' first)
  Initializing perf session failed

  Program received signal SIGSEGV, Segmentation fault.
  0x00000000005e7515 in auxtrace__free (session=0xffffffffffffffff) at util/auxtrace.c:2858
  2858		if (!session->auxtrace)
  (gdb) p session
  $1 = (struct perf_session *) 0xffffffffffffffff
  (gdb) bt
  #0  0x00000000005e7515 in auxtrace__free (session=0xffffffffffffffff) at util/auxtrace.c:2858
  #1  0x000000000057bb4d in perf_session__delete (session=0xffffffffffffffff) at util/session.c:300
  #2  0x000000000047c421 in __cmd_contention (argc=0, argv=0x7fffffffe200) at builtin-lock.c:2161
  #3  0x000000000047dc95 in cmd_lock (argc=0, argv=0x7fffffffe200) at builtin-lock.c:2604
  #4  0x0000000000501466 in run_builtin (p=0xe597a8 <commands+552>, argc=2, argv=0x7fffffffe200) at perf.c:322
  #5  0x00000000005016d5 in handle_internal_command (argc=2, argv=0x7fffffffe200) at perf.c:375
  #6  0x0000000000501824 in run_argv (argcp=0x7fffffffe02c, argv=0x7fffffffe020) at perf.c:419
  #7  0x0000000000501b11 in main (argc=2, argv=0x7fffffffe200) at perf.c:535
  (gdb)

So just set it to NULL after using PTR_ERR(session) to decode the error
as perf_session__delete(NULL) is supported.

The same problem was found in 'perf top' after an audit of all
perf_session__new() failure handling.

Fixes: 6ef81c55a2 ("perf session: Return error code for perf_session__new() function on failure")
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jeremie Galarneau <jeremie.galarneau@efficios.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kate Stewart <kstewart@linuxfoundation.org>
Cc: Mamatha Inamdar <mamatha4@linux.vnet.ibm.com>
Cc: Mukesh Ojha <mojha@codeaurora.org>
Cc: Nageswara R Sastry <rnsastry@linux.vnet.ibm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Cc: Shawn Landden <shawn@git.icu>
Cc: Song Liu <songliubraving@fb.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tzvetomir Stoyanov <tstoyanov@vmware.com>
Link: https://lore.kernel.org/lkml/ZN4Q2rxxsL08A8rd@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Roxana Nicolescu <roxana.nicolescu@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
2023-10-30 11:42:18 +01:00
Documentation Documentation/sysctl: document page_lock_unfairness 2023-10-30 11:42:03 +01:00
LICENSES
arch x86/virt: Drop unnecessary check on extended CPUID level in cpu_has_svm() 2023-10-30 11:42:18 +01:00
block block/partition: fix signedness issue for Amiga partitions 2023-10-02 12:12:10 +02:00
certs certs/blacklist_hashes.c: fix const confusion in certs blacklist 2022-08-26 11:10:49 +02:00
crypto X.509: if signature is unsupported skip validation 2023-10-30 11:42:17 +01:00
debian UBUNTU: [Packaging] update helper scripts 2023-10-30 11:13:19 +01:00
debian.master UBUNTU: [Config] Update annotations after CONFIG_IMA_TRUSTED_KEYRING removal 2023-10-30 11:42:11 +01:00
drivers soc: qcom: qmi_encdec: Restrict string length in decode 2023-10-30 11:42:18 +01:00
fs NFSv4/pnfs: minor fix for cleanup path in nfs4_get_device_info 2023-10-30 11:42:18 +01:00
include net: handle ARPHRD_PPP in dev_is_mac_header_xmit() 2023-10-30 11:42:17 +01:00
init init, x86: Move mem_encrypt_init() into arch_cpu_finalize_init() 2023-08-09 12:25:43 +02:00
ipc ipc: replace costly bailout check in sysvipc_find_ipc() 2023-02-24 14:01:18 +01:00
kernel tracing: Fix race issue between cpu buffer write and swap 2023-10-30 11:42:15 +01:00
lib lib/test_meminit: allocate pages up to order MAX_ORDER 2023-10-30 11:42:18 +01:00
mm tmpfs: verify {g,u}id mount options correctly 2023-10-30 11:42:07 +01:00
net net/ipv6: SKB symmetric hash should incorporate transport ports 2023-10-30 11:42:17 +01:00
samples samples/bpf: Fix buffer overflow in tcp_basertt 2023-10-02 12:12:01 +02:00
scripts kconfig: fix possible buffer overflow 2023-10-30 11:42:18 +01:00
security smackfs: Prevent underflow in smk_set_cipso() 2023-10-30 11:42:11 +01:00
sound ALSA: pcm: Fix missing fixup call in compat hw_refine ioctl 2023-10-30 11:42:16 +01:00
tools perf top: Don't pass an ERR_PTR() directly to perf_session__delete() 2023-10-30 11:42:18 +01:00
ubuntu
usr
virt KVM: Destroy target device if coalesced MMIO unregistration fails 2023-05-12 17:15:09 +02:00
.clang-format
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS iio: stx104: Move to addac subdirectory 2023-10-30 11:41:56 +01:00
Makefile Linux 5.4.256 2023-10-30 11:42:04 +01:00
README
Ubuntu.md UBUNTU: [Packaging] update Ubuntu.md 2021-11-05 16:43:42 +01:00
dropped.txt
snapcraft.yaml
update-dkms-versions UBUNTU: [Packaging] resync update-dkms-versions helper 2023-08-09 12:19:04 +02:00
update-version-dkms UBUNTU: [Packaging] switch to kernel-versions 2021-09-20 18:50:21 +02:00

README

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.