From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 26DB221FF46; Thu, 15 May 2025 12:15:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747311319; cv=none; b=QafkGZo/qyVARNyB5htJs3qzoiJAZLLr9TQR3lfjJJ0IXG0zS/urH1cfBFvVqoDkN+zQkypzaPJ4ZbfCBF8z+Qh59BMuTPhzPIeJgactCXm68q+hiFt2y52gXmQ2HvFLE6Z8tWivQlPaXYPXXdP3CtAekXqZ8fCv1kJVq18ZqQ4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747311319; c=relaxed/simple; bh=NLfinYtj/70z5hk7+uSvdjIGEQMY3Ex4U02Dmsr/O+0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KytHNqm6TB2qHJj0EEcrCDTSCNkDZquVQAhckPcrTHUgixlWkJo+rhYCkBjzEwUNmtR7T/yH5yZdnyuZ+dMVyF5/bGCm0x8i4ZErsW9hfrw30bNbgoYAgW3mtXIJ33c9T5wB89J5XaFRzMzDFLfFOTfJBK9UokQf6ASw7vphWdo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nf6im2aM; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nf6im2aM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 66659C4CEE7; Thu, 15 May 2025 12:15:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1747311316; bh=NLfinYtj/70z5hk7+uSvdjIGEQMY3Ex4U02Dmsr/O+0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nf6im2aM0/6A5jBfsxj6iyKU7cUFyAseC3RmIXQTcxrwFRFq6qBj31KEIVZiFvIA0 3cZQ5zAwtTvuN/fd5Fg/f5ASocV2r55M2BAsW2ukZvHMZW0kXmb4G6bnJOfF2Ac2MD 5RCAlBXjb6wrKZiqIXMmO5Q4ux99l2vybCPWnz8+/h/iK12JI6Qr+uTpHKRc+/icne 41vK/AZcahN/Omh2pmx/85FYqxEbAnmStz7aiCHYrNmdi7+QwxKVqlLoOh3Yp7miYS Ht51G/hM2ubsBfzhhfzQ4xwpXBYjdtoq/S0VmkOT0ip8Aak488ViWlnF3/N4kd/r9W ZFJCLEkJNIvTQ== From: Jiri Olsa To: Oleg Nesterov , Peter Zijlstra , Andrii Nakryiko Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, x86@kernel.org, Song Liu , Yonghong Song , John Fastabend , Hao Luo , Steven Rostedt , Masami Hiramatsu , Alan Maguire , David Laight , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , Ingo Molnar Subject: [PATCHv2 perf/core 16/22] selftests/bpf: Add uprobe syscall sigill signal test Date: Thu, 15 May 2025 14:11:13 +0200 Message-ID: <20250515121121.2332905-17-jolsa@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250515121121.2332905-1-jolsa@kernel.org> References: <20250515121121.2332905-1-jolsa@kernel.org> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Make sure that calling uprobe syscall from outside uprobe trampoline results in sigill signal. Signed-off-by: Jiri Olsa --- .../selftests/bpf/prog_tests/uprobe_syscall.c | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tools/testing/selftests/bpf/prog_tests/uprobe_syscall.c b/tools/testing/selftests/bpf/prog_tests/uprobe_syscall.c index a83abbe91b01..fa0ee813472f 100644 --- a/tools/testing/selftests/bpf/prog_tests/uprobe_syscall.c +++ b/tools/testing/selftests/bpf/prog_tests/uprobe_syscall.c @@ -726,6 +726,40 @@ static void test_uprobe_race(void) ASSERT_FALSE(USDT_SEMA_IS_ACTIVE(race), "race_semaphore"); } +#ifndef __NR_uprobe +#define __NR_uprobe 336 +#endif + +static void test_uprobe_sigill(void) +{ + int status, err, pid; + + pid = fork(); + if (!ASSERT_GE(pid, 0, "fork")) + return; + /* child */ + if (pid == 0) { + asm volatile ( + "pushq %rax\n" + "pushq %rcx\n" + "pushq %r11\n" + "movq $" __stringify(__NR_uprobe) ", %rax\n" + "syscall\n" + "popq %r11\n" + "popq %rcx\n" + "retq\n" + ); + exit(0); + } + + err = waitpid(pid, &status, 0); + ASSERT_EQ(err, pid, "waitpid"); + + /* verify the child got killed with SIGILL */ + ASSERT_EQ(WIFSIGNALED(status), 1, "WIFSIGNALED"); + ASSERT_EQ(WTERMSIG(status), SIGILL, "WTERMSIG"); +} + static void __test_uprobe_syscall(void) { if (test__start_subtest("uretprobe_regs_equal")) @@ -746,6 +780,8 @@ static void __test_uprobe_syscall(void) test_uprobe_usdt(); if (test__start_subtest("uprobe_race")) test_uprobe_race(); + if (test__start_subtest("uprobe_sigill")) + test_uprobe_sigill(); } #else static void __test_uprobe_syscall(void) -- 2.49.0