mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-09 07:23:14 +00:00
1b9c3ddcec
checker_stack_use_t32strd() and kprobe_handler() can be made static since they are not used from other files, while coverage_start_registers() and __kprobes_test_case() are used from assembler code, and just need a declaration to avoid a warning with the global definition. arch/arm/probes/kprobes/checkers-common.c:43:18: error: no previous prototype for 'checker_stack_use_t32strd' arch/arm/probes/kprobes/core.c:236:16: error: no previous prototype for 'kprobe_handler' arch/arm/probes/kprobes/test-core.c:723:10: error: no previous prototype for 'coverage_start_registers' arch/arm/probes/kprobes/test-core.c:918:14: error: no previous prototype for '__kprobes_test_case_start' arch/arm/probes/kprobes/test-core.c:952:14: error: no previous prototype for '__kprobes_test_case_end_16' arch/arm/probes/kprobes/test-core.c:967:14: error: no previous prototype for '__kprobes_test_case_end_32' Fixes:6624cf651f
("ARM: kprobes: collects stack consumption for store instructions") Fixes:454f3e132d
("ARM/kprobes: Remove jprobe arm implementation") Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Reviewed-by: Kees Cook <keescook@chromium.org> Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
94 lines
2.4 KiB
C
94 lines
2.4 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* arch/arm/probes/kprobes/checkers-common.c
|
|
*
|
|
* Copyright (C) 2014 Huawei Inc.
|
|
*/
|
|
|
|
#include <linux/kernel.h>
|
|
#include "../decode.h"
|
|
#include "../decode-arm.h"
|
|
#include "checkers.h"
|
|
|
|
enum probes_insn checker_stack_use_none(probes_opcode_t insn,
|
|
struct arch_probes_insn *asi,
|
|
const struct decode_header *h)
|
|
{
|
|
asi->stack_space = 0;
|
|
return INSN_GOOD_NO_SLOT;
|
|
}
|
|
|
|
enum probes_insn checker_stack_use_unknown(probes_opcode_t insn,
|
|
struct arch_probes_insn *asi,
|
|
const struct decode_header *h)
|
|
{
|
|
asi->stack_space = -1;
|
|
return INSN_GOOD_NO_SLOT;
|
|
}
|
|
|
|
#ifdef CONFIG_THUMB2_KERNEL
|
|
enum probes_insn checker_stack_use_imm_0xx(probes_opcode_t insn,
|
|
struct arch_probes_insn *asi,
|
|
const struct decode_header *h)
|
|
{
|
|
int imm = insn & 0xff;
|
|
asi->stack_space = imm;
|
|
return INSN_GOOD_NO_SLOT;
|
|
}
|
|
|
|
/*
|
|
* Different from other insn uses imm8, the real addressing offset of
|
|
* STRD in T32 encoding should be imm8 * 4. See ARMARM description.
|
|
*/
|
|
static enum probes_insn checker_stack_use_t32strd(probes_opcode_t insn,
|
|
struct arch_probes_insn *asi,
|
|
const struct decode_header *h)
|
|
{
|
|
int imm = insn & 0xff;
|
|
asi->stack_space = imm << 2;
|
|
return INSN_GOOD_NO_SLOT;
|
|
}
|
|
#else
|
|
enum probes_insn checker_stack_use_imm_x0x(probes_opcode_t insn,
|
|
struct arch_probes_insn *asi,
|
|
const struct decode_header *h)
|
|
{
|
|
int imm = ((insn & 0xf00) >> 4) + (insn & 0xf);
|
|
asi->stack_space = imm;
|
|
return INSN_GOOD_NO_SLOT;
|
|
}
|
|
#endif
|
|
|
|
enum probes_insn checker_stack_use_imm_xxx(probes_opcode_t insn,
|
|
struct arch_probes_insn *asi,
|
|
const struct decode_header *h)
|
|
{
|
|
int imm = insn & 0xfff;
|
|
asi->stack_space = imm;
|
|
return INSN_GOOD_NO_SLOT;
|
|
}
|
|
|
|
enum probes_insn checker_stack_use_stmdx(probes_opcode_t insn,
|
|
struct arch_probes_insn *asi,
|
|
const struct decode_header *h)
|
|
{
|
|
unsigned int reglist = insn & 0xffff;
|
|
int pbit = insn & (1 << 24);
|
|
asi->stack_space = (hweight32(reglist) - (!pbit ? 1 : 0)) * 4;
|
|
|
|
return INSN_GOOD_NO_SLOT;
|
|
}
|
|
|
|
const union decode_action stack_check_actions[] = {
|
|
[STACK_USE_NONE] = {.decoder = checker_stack_use_none},
|
|
[STACK_USE_UNKNOWN] = {.decoder = checker_stack_use_unknown},
|
|
#ifdef CONFIG_THUMB2_KERNEL
|
|
[STACK_USE_FIXED_0XX] = {.decoder = checker_stack_use_imm_0xx},
|
|
[STACK_USE_T32STRD] = {.decoder = checker_stack_use_t32strd},
|
|
#else
|
|
[STACK_USE_FIXED_X0X] = {.decoder = checker_stack_use_imm_x0x},
|
|
#endif
|
|
[STACK_USE_FIXED_XXX] = {.decoder = checker_stack_use_imm_xxx},
|
|
[STACK_USE_STMDX] = {.decoder = checker_stack_use_stmdx},
|
|
};
|