From: Sridhar Markonda <sridharm@linux.ibm.com>
To: Gautam Menghani <gautam@linux.ibm.com>
Cc: linuxppc-dev@lists.ozlabs.org, maddy@linux.ibm.com,
mpe@ellerman.id.au, npiggin@gmail.com, chleroy@kernel.org,
ritesh.list@gmail.com, sshegde@linux.ibm.com,
ravi.bangoria@linux.ibm.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] powerpc/hw_breakpoint: Fix NULL pointer dereference in thread_change_pc()
Date: Fri, 4 Dec 2026 12:51:54 +0530 [thread overview]
Message-ID: <705355bb-89ac-4971-b32f-b8088f9d7f15@linux.ibm.com> (raw)
In-Reply-To: <awlKzM0YWWrCueMi@li-fbf77acc-29ba-11b2-a85c-e8e934f50a46.ibm.com>
This issue was found by a local syzkaller instance running on
qemu-system-ppc64 (POWER10), not by upstream syzbot, so there is no
public syzbot report or Closes tag.
Syzkaller did not generate a standalone reproducer. Based on the crash
trace, I created the reproducer below. It installs a single hardware
watchpoint using perf_event_open() and repeatedly triggers it, while a
second thread continuously sends SIGUSR1 to the watched thread.
This exercises the thread_change_pc() reset path while a watchpoint is
in perf_single_step state.
On a POWER10 LPAR running an unpatched kernel, it crashes immediately
with the NULL pointer dereference. With the proposed fix applied, it
runs to completion.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include <pthread.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <linux/perf_event.h>
#include <linux/hw_breakpoint.h>
static volatile int watch_target = 0;
static volatile int running = 1;
/* Signal handler: its delivery forces arch_do_signal_or_restart ->
thread_change_pc */
static void sig_handler(int sig)
{
/* Handled */
}
/* Thread that rapidly fires signals at the main thread */
static void *signal_flooder(void *arg)
{
pthread_t target_thread = *(pthread_t *)arg;
while (running) {
pthread_kill(target_thread, SIGUSR1);
usleep(10);
}
return NULL;
}
int main(void)
{
struct sigaction sa;
struct perf_event_attr pe;
pthread_t flooder;
pthread_t main_thread = pthread_self();
int fd;
/* 1. Register signal handler */
memset(&sa, 0, sizeof(sa));
sa.sa_handler = sig_handler;
sigaction(SIGUSR1, &sa, NULL);
/* 2. Configure 1 hardware watchpoint (slot 0) */
memset(&pe, 0, sizeof(pe));
pe.type = PERF_TYPE_BREAKPOINT;
pe.size = sizeof(struct perf_event_attr);
pe.bp_type = HW_BREAKPOINT_W;
pe.bp_addr = (unsigned long)&watch_target;
pe.bp_len = sizeof(int);
pe.disabled = 0;
fd = syscall(__NR_perf_event_open, &pe, 0, -1, -1, 0);
if (fd < 0) {
perror("perf_event_open");
return 1;
}
printf("[+] HW Watchpoint installed on %p (fd=%d)\n",
&watch_target, fd);
printf("[+] Flooding signals to trigger thread_change_pc() race...\n");
/* 3. Start signal flooding thread */
pthread_create(&flooder, NULL, signal_flooder, &main_thread);
/* 4. Trigger watchpoint writes repeatedly */
for (int i = 0; i < 1000000; i++) {
watch_target = i; /* Triggers watchpoint exception & single-step */
}
running = 0;
pthread_join(flooder, NULL);
close(fd);
printf("[-] Finished without crash (kernel likely patched).\n");
return 0;
}
Thanks,
Sridhar
On 27/11/26 2:49 pm, Gautam Menghani wrote:
> Do you also have the reproducer for this issue? Also if this was
> reported by upstream syzkaller, you have to put the Reported-by and
> Closes tags.
>
> Thanks,
> Gautam
prev parent reply other threads:[~2026-12-04 7:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 23:04 Sridhar Markonda
2026-11-27 9:19 ` Gautam Menghani
2026-12-04 7:21 ` Sridhar Markonda [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=705355bb-89ac-4971-b32f-b8088f9d7f15@linux.ibm.com \
--to=sridharm@linux.ibm.com \
--cc=chleroy@kernel.org \
--cc=gautam@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.com \
--cc=ravi.bangoria@linux.ibm.com \
--cc=ritesh.list@gmail.com \
--cc=sshegde@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®