Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

arm64: ptrace: Use USER_REGSET_NOTE_TYPE() to specify regset note names

Instead of having the core code guess the note name for each regset,
use USER_REGSET_NOTE_TYPE() to pick the correct name from elf.h.

This does not affect the correctness of switch(note_type) and similar
code, since note type values known to Linux for coredump purposes were
already required to be unique.

Signed-off-by: Dave Martin <Dave.Martin@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Kees Cook <kees@kernel.org>
Cc: Akihiko Odaki <akihiko.odaki@daynix.com>
Cc: linux-arm-kernel@lists.infradead.org
Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Link: https://lore.kernel.org/r/20250701135616.29630-7-Dave.Martin@arm.com
Signed-off-by: Kees Cook <kees@kernel.org>

authored by

Dave Martin and committed by
Kees Cook
87b0d081 49b849d1

+26 -26
+26 -26
arch/arm64/kernel/ptrace.c
··· 1586 1586 1587 1587 static const struct user_regset aarch64_regsets[] = { 1588 1588 [REGSET_GPR] = { 1589 - .core_note_type = NT_PRSTATUS, 1589 + USER_REGSET_NOTE_TYPE(PRSTATUS), 1590 1590 .n = sizeof(struct user_pt_regs) / sizeof(u64), 1591 1591 .size = sizeof(u64), 1592 1592 .align = sizeof(u64), ··· 1594 1594 .set = gpr_set 1595 1595 }, 1596 1596 [REGSET_FPR] = { 1597 - .core_note_type = NT_PRFPREG, 1597 + USER_REGSET_NOTE_TYPE(PRFPREG), 1598 1598 .n = sizeof(struct user_fpsimd_state) / sizeof(u32), 1599 1599 /* 1600 1600 * We pretend we have 32-bit registers because the fpsr and ··· 1607 1607 .set = fpr_set 1608 1608 }, 1609 1609 [REGSET_TLS] = { 1610 - .core_note_type = NT_ARM_TLS, 1610 + USER_REGSET_NOTE_TYPE(ARM_TLS), 1611 1611 .n = 2, 1612 1612 .size = sizeof(void *), 1613 1613 .align = sizeof(void *), ··· 1616 1616 }, 1617 1617 #ifdef CONFIG_HAVE_HW_BREAKPOINT 1618 1618 [REGSET_HW_BREAK] = { 1619 - .core_note_type = NT_ARM_HW_BREAK, 1619 + USER_REGSET_NOTE_TYPE(ARM_HW_BREAK), 1620 1620 .n = sizeof(struct user_hwdebug_state) / sizeof(u32), 1621 1621 .size = sizeof(u32), 1622 1622 .align = sizeof(u32), ··· 1624 1624 .set = hw_break_set, 1625 1625 }, 1626 1626 [REGSET_HW_WATCH] = { 1627 - .core_note_type = NT_ARM_HW_WATCH, 1627 + USER_REGSET_NOTE_TYPE(ARM_HW_WATCH), 1628 1628 .n = sizeof(struct user_hwdebug_state) / sizeof(u32), 1629 1629 .size = sizeof(u32), 1630 1630 .align = sizeof(u32), ··· 1633 1633 }, 1634 1634 #endif 1635 1635 [REGSET_SYSTEM_CALL] = { 1636 - .core_note_type = NT_ARM_SYSTEM_CALL, 1636 + USER_REGSET_NOTE_TYPE(ARM_SYSTEM_CALL), 1637 1637 .n = 1, 1638 1638 .size = sizeof(int), 1639 1639 .align = sizeof(int), ··· 1641 1641 .set = system_call_set, 1642 1642 }, 1643 1643 [REGSET_FPMR] = { 1644 - .core_note_type = NT_ARM_FPMR, 1644 + USER_REGSET_NOTE_TYPE(ARM_FPMR), 1645 1645 .n = 1, 1646 1646 .size = sizeof(u64), 1647 1647 .align = sizeof(u64), ··· 1650 1650 }, 1651 1651 #ifdef CONFIG_ARM64_SVE 1652 1652 [REGSET_SVE] = { /* Scalable Vector Extension */ 1653 - .core_note_type = NT_ARM_SVE, 1653 + USER_REGSET_NOTE_TYPE(ARM_SVE), 1654 1654 .n = DIV_ROUND_UP(SVE_PT_SIZE(ARCH_SVE_VQ_MAX, 1655 1655 SVE_PT_REGS_SVE), 1656 1656 SVE_VQ_BYTES), ··· 1662 1662 #endif 1663 1663 #ifdef CONFIG_ARM64_SME 1664 1664 [REGSET_SSVE] = { /* Streaming mode SVE */ 1665 - .core_note_type = NT_ARM_SSVE, 1665 + USER_REGSET_NOTE_TYPE(ARM_SSVE), 1666 1666 .n = DIV_ROUND_UP(SVE_PT_SIZE(SME_VQ_MAX, SVE_PT_REGS_SVE), 1667 1667 SVE_VQ_BYTES), 1668 1668 .size = SVE_VQ_BYTES, ··· 1671 1671 .set = ssve_set, 1672 1672 }, 1673 1673 [REGSET_ZA] = { /* SME ZA */ 1674 - .core_note_type = NT_ARM_ZA, 1674 + USER_REGSET_NOTE_TYPE(ARM_ZA), 1675 1675 /* 1676 1676 * ZA is a single register but it's variably sized and 1677 1677 * the ptrace core requires that the size of any data ··· 1687 1687 .set = za_set, 1688 1688 }, 1689 1689 [REGSET_ZT] = { /* SME ZT */ 1690 - .core_note_type = NT_ARM_ZT, 1690 + USER_REGSET_NOTE_TYPE(ARM_ZT), 1691 1691 .n = 1, 1692 1692 .size = ZT_SIG_REG_BYTES, 1693 1693 .align = sizeof(u64), ··· 1697 1697 #endif 1698 1698 #ifdef CONFIG_ARM64_PTR_AUTH 1699 1699 [REGSET_PAC_MASK] = { 1700 - .core_note_type = NT_ARM_PAC_MASK, 1700 + USER_REGSET_NOTE_TYPE(ARM_PAC_MASK), 1701 1701 .n = sizeof(struct user_pac_mask) / sizeof(u64), 1702 1702 .size = sizeof(u64), 1703 1703 .align = sizeof(u64), ··· 1705 1705 /* this cannot be set dynamically */ 1706 1706 }, 1707 1707 [REGSET_PAC_ENABLED_KEYS] = { 1708 - .core_note_type = NT_ARM_PAC_ENABLED_KEYS, 1708 + USER_REGSET_NOTE_TYPE(ARM_PAC_ENABLED_KEYS), 1709 1709 .n = 1, 1710 1710 .size = sizeof(long), 1711 1711 .align = sizeof(long), ··· 1714 1714 }, 1715 1715 #ifdef CONFIG_CHECKPOINT_RESTORE 1716 1716 [REGSET_PACA_KEYS] = { 1717 - .core_note_type = NT_ARM_PACA_KEYS, 1717 + USER_REGSET_NOTE_TYPE(ARM_PACA_KEYS), 1718 1718 .n = sizeof(struct user_pac_address_keys) / sizeof(__uint128_t), 1719 1719 .size = sizeof(__uint128_t), 1720 1720 .align = sizeof(__uint128_t), ··· 1722 1722 .set = pac_address_keys_set, 1723 1723 }, 1724 1724 [REGSET_PACG_KEYS] = { 1725 - .core_note_type = NT_ARM_PACG_KEYS, 1725 + USER_REGSET_NOTE_TYPE(ARM_PACG_KEYS), 1726 1726 .n = sizeof(struct user_pac_generic_keys) / sizeof(__uint128_t), 1727 1727 .size = sizeof(__uint128_t), 1728 1728 .align = sizeof(__uint128_t), ··· 1733 1733 #endif 1734 1734 #ifdef CONFIG_ARM64_TAGGED_ADDR_ABI 1735 1735 [REGSET_TAGGED_ADDR_CTRL] = { 1736 - .core_note_type = NT_ARM_TAGGED_ADDR_CTRL, 1736 + USER_REGSET_NOTE_TYPE(ARM_TAGGED_ADDR_CTRL), 1737 1737 .n = 1, 1738 1738 .size = sizeof(long), 1739 1739 .align = sizeof(long), ··· 1743 1743 #endif 1744 1744 #ifdef CONFIG_ARM64_POE 1745 1745 [REGSET_POE] = { 1746 - .core_note_type = NT_ARM_POE, 1746 + USER_REGSET_NOTE_TYPE(ARM_POE), 1747 1747 .n = 1, 1748 1748 .size = sizeof(long), 1749 1749 .align = sizeof(long), ··· 1753 1753 #endif 1754 1754 #ifdef CONFIG_ARM64_GCS 1755 1755 [REGSET_GCS] = { 1756 - .core_note_type = NT_ARM_GCS, 1756 + USER_REGSET_NOTE_TYPE(ARM_GCS), 1757 1757 .n = sizeof(struct user_gcs) / sizeof(u64), 1758 1758 .size = sizeof(u64), 1759 1759 .align = sizeof(u64), ··· 1943 1943 1944 1944 static const struct user_regset aarch32_regsets[] = { 1945 1945 [REGSET_COMPAT_GPR] = { 1946 - .core_note_type = NT_PRSTATUS, 1946 + USER_REGSET_NOTE_TYPE(PRSTATUS), 1947 1947 .n = COMPAT_ELF_NGREG, 1948 1948 .size = sizeof(compat_elf_greg_t), 1949 1949 .align = sizeof(compat_elf_greg_t), ··· 1951 1951 .set = compat_gpr_set 1952 1952 }, 1953 1953 [REGSET_COMPAT_VFP] = { 1954 - .core_note_type = NT_ARM_VFP, 1954 + USER_REGSET_NOTE_TYPE(ARM_VFP), 1955 1955 .n = VFP_STATE_SIZE / sizeof(compat_ulong_t), 1956 1956 .size = sizeof(compat_ulong_t), 1957 1957 .align = sizeof(compat_ulong_t), ··· 1968 1968 1969 1969 static const struct user_regset aarch32_ptrace_regsets[] = { 1970 1970 [REGSET_GPR] = { 1971 - .core_note_type = NT_PRSTATUS, 1971 + USER_REGSET_NOTE_TYPE(PRSTATUS), 1972 1972 .n = COMPAT_ELF_NGREG, 1973 1973 .size = sizeof(compat_elf_greg_t), 1974 1974 .align = sizeof(compat_elf_greg_t), ··· 1976 1976 .set = compat_gpr_set 1977 1977 }, 1978 1978 [REGSET_FPR] = { 1979 - .core_note_type = NT_ARM_VFP, 1979 + USER_REGSET_NOTE_TYPE(ARM_VFP), 1980 1980 .n = VFP_STATE_SIZE / sizeof(compat_ulong_t), 1981 1981 .size = sizeof(compat_ulong_t), 1982 1982 .align = sizeof(compat_ulong_t), ··· 1984 1984 .set = compat_vfp_set 1985 1985 }, 1986 1986 [REGSET_TLS] = { 1987 - .core_note_type = NT_ARM_TLS, 1987 + USER_REGSET_NOTE_TYPE(ARM_TLS), 1988 1988 .n = 1, 1989 1989 .size = sizeof(compat_ulong_t), 1990 1990 .align = sizeof(compat_ulong_t), ··· 1993 1993 }, 1994 1994 #ifdef CONFIG_HAVE_HW_BREAKPOINT 1995 1995 [REGSET_HW_BREAK] = { 1996 - .core_note_type = NT_ARM_HW_BREAK, 1996 + USER_REGSET_NOTE_TYPE(ARM_HW_BREAK), 1997 1997 .n = sizeof(struct user_hwdebug_state) / sizeof(u32), 1998 1998 .size = sizeof(u32), 1999 1999 .align = sizeof(u32), ··· 2001 2001 .set = hw_break_set, 2002 2002 }, 2003 2003 [REGSET_HW_WATCH] = { 2004 - .core_note_type = NT_ARM_HW_WATCH, 2004 + USER_REGSET_NOTE_TYPE(ARM_HW_WATCH), 2005 2005 .n = sizeof(struct user_hwdebug_state) / sizeof(u32), 2006 2006 .size = sizeof(u32), 2007 2007 .align = sizeof(u32), ··· 2010 2010 }, 2011 2011 #endif 2012 2012 [REGSET_SYSTEM_CALL] = { 2013 - .core_note_type = NT_ARM_SYSTEM_CALL, 2013 + USER_REGSET_NOTE_TYPE(ARM_SYSTEM_CALL), 2014 2014 .n = 1, 2015 2015 .size = sizeof(int), 2016 2016 .align = sizeof(int),