kernel_samsung_a53x/arch/arm64
Mark Rutland 7c89a371b2 arm64: ptrace: fix partial SETREGSET for NT_ARM_TAGGED_ADDR_CTRL
commit ca62d90085f4af36de745883faab9f8a7cbb45d3 upstream.

Currently tagged_addr_ctrl_set() doesn't initialize the temporary 'ctrl'
variable, and a SETREGSET call with a length of zero will leave this
uninitialized. Consequently tagged_addr_ctrl_set() will consume an
arbitrary value, potentially leaking up to 64 bits of memory from the
kernel stack. The read is limited to a specific slot on the stack, and
the issue does not provide a write mechanism.

As set_tagged_addr_ctrl() only accepts values where bits [63:4] zero and
rejects other values, a partial SETREGSET attempt will randomly succeed
or fail depending on the value of the uninitialized value, and the
exposure is significantly limited.

Fix this by initializing the temporary value before copying the regset
from userspace, as for other regsets (e.g. NT_PRSTATUS, NT_PRFPREG,
NT_ARM_SYSTEM_CALL). In the case of a zero-length write, the existing
value of the tagged address ctrl will be retained.

The NT_ARM_TAGGED_ADDR_CTRL regset is only visible in the
user_aarch64_view used by a native AArch64 task to manipulate another
native AArch64 task. As get_tagged_addr_ctrl() only returns an error
value when called for a compat task, tagged_addr_ctrl_get() and
tagged_addr_ctrl_set() should never observe an error value from
get_tagged_addr_ctrl(). Add a WARN_ON_ONCE() to both to indicate that
such an error would be unexpected, and error handlnig is not missing in
either case.

Fixes: 2200aa7154cb ("arm64: mte: ptrace: Add NT_ARM_TAGGED_ADDR_CTRL regset")
Cc: <stable@vger.kernel.org> # 5.10.x
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Will Deacon <will@kernel.org>
Reviewed-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20241205121655.1824269-2-mark.rutland@arm.com
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-12-17 13:24:28 +01:00
..
boot ARM64: dts/s5e8825: make GPU lean more towards 702 MHz 2024-11-24 19:21:47 +01:00
configs defconfig: s5e8825-a53xxx: Readded 2024-11-24 19:52:41 +00:00
crypto Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
include mm: refactor arch_calc_vm_flag_bits() and arm64 MTE handling 2024-12-17 13:23:57 +01:00
kernel arm64: ptrace: fix partial SETREGSET for NT_ARM_TAGGED_ADDR_CTRL 2024-12-17 13:24:28 +01:00
kvm KVM: arm64: Ignore PMCNTENSET_EL0 while checking for overflow status 2024-12-17 13:24:18 +01:00
lib arm64: Align __arch_clear_user() to 16 bytes as per upstream 2024-11-19 17:54:00 +01:00
mm Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
net Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
xen Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Kbuild Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Kconfig arm64: Restrict CPU_BIG_ENDIAN to GNU as or LLVM IAS 15.x or newer 2024-11-18 11:43:21 +01:00
Kconfig.debug Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Kconfig.platforms Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Makefile arm64: Force position-independent veneers 2024-11-23 23:22:00 +01:00
Makefile.postlink Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00