Skip to content

Commit 2200aa7

Browse files
committed
arm64: mte: ptrace: Add NT_ARM_TAGGED_ADDR_CTRL regset
This regset allows read/write access to a ptraced process prctl(PR_SET_TAGGED_ADDR_CTRL) setting. Signed-off-by: Catalin Marinas <[email protected]> Cc: Will Deacon <[email protected]> Cc: Alan Hayward <[email protected]> Cc: Luis Machado <[email protected]> Cc: Omair Javaid <[email protected]>
1 parent 18ddbaa commit 2200aa7

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

arch/arm64/kernel/ptrace.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,35 @@ static int pac_generic_keys_set(struct task_struct *target,
10331033
#endif /* CONFIG_CHECKPOINT_RESTORE */
10341034
#endif /* CONFIG_ARM64_PTR_AUTH */
10351035

1036+
#ifdef CONFIG_ARM64_TAGGED_ADDR_ABI
1037+
static int tagged_addr_ctrl_get(struct task_struct *target,
1038+
const struct user_regset *regset,
1039+
struct membuf to)
1040+
{
1041+
long ctrl = get_tagged_addr_ctrl(target);
1042+
1043+
if (IS_ERR_VALUE(ctrl))
1044+
return ctrl;
1045+
1046+
return membuf_write(&to, &ctrl, sizeof(ctrl));
1047+
}
1048+
1049+
static int tagged_addr_ctrl_set(struct task_struct *target, const struct
1050+
user_regset *regset, unsigned int pos,
1051+
unsigned int count, const void *kbuf, const
1052+
void __user *ubuf)
1053+
{
1054+
int ret;
1055+
long ctrl;
1056+
1057+
ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &ctrl, 0, -1);
1058+
if (ret)
1059+
return ret;
1060+
1061+
return set_tagged_addr_ctrl(target, ctrl);
1062+
}
1063+
#endif
1064+
10361065
enum aarch64_regset {
10371066
REGSET_GPR,
10381067
REGSET_FPR,
@@ -1052,6 +1081,9 @@ enum aarch64_regset {
10521081
REGSET_PACG_KEYS,
10531082
#endif
10541083
#endif
1084+
#ifdef CONFIG_ARM64_TAGGED_ADDR_ABI
1085+
REGSET_TAGGED_ADDR_CTRL,
1086+
#endif
10551087
};
10561088

10571089
static const struct user_regset aarch64_regsets[] = {
@@ -1149,6 +1181,16 @@ static const struct user_regset aarch64_regsets[] = {
11491181
},
11501182
#endif
11511183
#endif
1184+
#ifdef CONFIG_ARM64_TAGGED_ADDR_ABI
1185+
[REGSET_TAGGED_ADDR_CTRL] = {
1186+
.core_note_type = NT_ARM_TAGGED_ADDR_CTRL,
1187+
.n = 1,
1188+
.size = sizeof(long),
1189+
.align = sizeof(long),
1190+
.regset_get = tagged_addr_ctrl_get,
1191+
.set = tagged_addr_ctrl_set,
1192+
},
1193+
#endif
11521194
};
11531195

11541196
static const struct user_regset_view user_aarch64_view = {

include/uapi/linux/elf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ typedef struct elf64_shdr {
425425
#define NT_ARM_PAC_MASK 0x406 /* ARM pointer authentication code masks */
426426
#define NT_ARM_PACA_KEYS 0x407 /* ARM pointer authentication address keys */
427427
#define NT_ARM_PACG_KEYS 0x408 /* ARM pointer authentication generic key */
428+
#define NT_ARM_TAGGED_ADDR_CTRL 0x409 /* arm64 tagged address control (prctl()) */
428429
#define NT_ARC_V2 0x600 /* ARCv2 accumulator/extra registers */
429430
#define NT_VMCOREDD 0x700 /* Vmcore Device Dump Note */
430431
#define NT_MIPS_DSP 0x800 /* MIPS DSP ASE registers */

0 commit comments

Comments
 (0)