Skip to content

Commit 6d502b6

Browse files
Suzuki K Poulosewilldeacon
authored andcommitted
arm64: signal: nofpsimd: Handle fp/simd context for signal frames
Make sure we try to save/restore the vfp/fpsimd context for signal handling only when the fp/simd support is available. Otherwise, skip the frames. Cc: Will Deacon <[email protected]> Cc: Mark Rutland <[email protected]> Reviewed-by: Ard Biesheuvel <[email protected]> Reviewed-by: Catalin Marinas <[email protected]> Signed-off-by: Suzuki K Poulose <[email protected]> Signed-off-by: Will Deacon <[email protected]>
1 parent c9d6699 commit 6d502b6

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

arch/arm64/kernel/signal.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,8 @@ static int parse_user_sigframe(struct user_ctxs *user,
371371
goto done;
372372

373373
case FPSIMD_MAGIC:
374+
if (!system_supports_fpsimd())
375+
goto invalid;
374376
if (user->fpsimd)
375377
goto invalid;
376378

@@ -506,7 +508,7 @@ static int restore_sigframe(struct pt_regs *regs,
506508
if (err == 0)
507509
err = parse_user_sigframe(&user, sf);
508510

509-
if (err == 0) {
511+
if (err == 0 && system_supports_fpsimd()) {
510512
if (!user.fpsimd)
511513
return -EINVAL;
512514

@@ -623,7 +625,7 @@ static int setup_sigframe(struct rt_sigframe_user_layout *user,
623625

624626
err |= __copy_to_user(&sf->uc.uc_sigmask, set, sizeof(*set));
625627

626-
if (err == 0) {
628+
if (err == 0 && system_supports_fpsimd()) {
627629
struct fpsimd_context __user *fpsimd_ctx =
628630
apply_user_offset(user, user->fpsimd_offset);
629631
err |= preserve_fpsimd_context(fpsimd_ctx);

arch/arm64/kernel/signal32.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ static int compat_restore_sigframe(struct pt_regs *regs,
223223
err |= !valid_user_regs(&regs->user_regs, current);
224224

225225
aux = (struct compat_aux_sigframe __user *) sf->uc.uc_regspace;
226-
if (err == 0)
226+
if (err == 0 && system_supports_fpsimd())
227227
err |= compat_restore_vfp_context(&aux->vfp);
228228

229229
return err;
@@ -419,7 +419,7 @@ static int compat_setup_sigframe(struct compat_sigframe __user *sf,
419419

420420
aux = (struct compat_aux_sigframe __user *) sf->uc.uc_regspace;
421421

422-
if (err == 0)
422+
if (err == 0 && system_supports_fpsimd())
423423
err |= compat_preserve_vfp_context(&aux->vfp);
424424
__put_user_error(0, &aux->end_magic, err);
425425

0 commit comments

Comments
 (0)