linux/lib/test_kprobes.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * test_kprobes.c - simple sanity test for k*probes
 *
 * Copyright IBM Corp. 2008
 */

#include <linux/kernel.h>
#include <linux/kprobes.h>
#include <linux/random.h>
#include <kunit/test.h>

#define div_factor

static u32 rand1, preh_val, posth_val;
static u32 (*target)(u32 value);
static u32 (*recursed_target)(u32 value);
static u32 (*target2)(u32 value);
static struct kunit *current_test;

static unsigned long (*internal_target)(void);
static unsigned long (*stacktrace_target)(void);
static unsigned long (*stacktrace_driver)(void);
static unsigned long target_return_address[2];

static noinline u32 kprobe_target(u32 value)
{}

static noinline u32 kprobe_recursed_target(u32 value)
{}

static int kp_pre_handler(struct kprobe *p, struct pt_regs *regs)
{}

static void kp_post_handler(struct kprobe *p, struct pt_regs *regs,
		unsigned long flags)
{}

static struct kprobe kp =;

static void test_kprobe(struct kunit *test)
{}

static noinline u32 kprobe_target2(u32 value)
{}

static noinline unsigned long kprobe_stacktrace_internal_target(void)
{}

static noinline unsigned long kprobe_stacktrace_target(void)
{}

static noinline unsigned long kprobe_stacktrace_driver(void)
{}

static int kp_pre_handler2(struct kprobe *p, struct pt_regs *regs)
{}

static void kp_post_handler2(struct kprobe *p, struct pt_regs *regs,
		unsigned long flags)
{}

static struct kprobe kp2 =;

static void test_kprobes(struct kunit *test)
{}

static struct kprobe kp_missed =;

static void test_kprobe_missed(struct kunit *test)
{}

#ifdef CONFIG_KRETPROBES
static u32 krph_val;

static int entry_handler(struct kretprobe_instance *ri, struct pt_regs *regs)
{}

static int return_handler(struct kretprobe_instance *ri, struct pt_regs *regs)
{}

static struct kretprobe rp =;

static void test_kretprobe(struct kunit *test)
{}

static int return_handler2(struct kretprobe_instance *ri, struct pt_regs *regs)
{}

static struct kretprobe rp2 =;

static void test_kretprobes(struct kunit *test)
{}

#ifdef CONFIG_ARCH_CORRECT_STACKTRACE_ON_KRETPROBE
#define STACK_BUF_SIZE
static unsigned long stack_buf[STACK_BUF_SIZE];

static int stacktrace_return_handler(struct kretprobe_instance *ri, struct pt_regs *regs)
{}

static struct kretprobe rp3 =;

static void test_stacktrace_on_kretprobe(struct kunit *test)
{}

static int stacktrace_internal_return_handler(struct kretprobe_instance *ri, struct pt_regs *regs)
{}

static struct kretprobe rp4 =;

static void test_stacktrace_on_nested_kretprobe(struct kunit *test)
{}
#endif /* CONFIG_ARCH_CORRECT_STACKTRACE_ON_KRETPROBE */

#endif /* CONFIG_KRETPROBES */

static int kprobes_test_init(struct kunit *test)
{}

static struct kunit_case kprobes_testcases[] =;

static struct kunit_suite kprobes_test_suite =;

kunit_test_suites();

MODULE_DESCRIPTION();
MODULE_LICENSE();