Skip to content

Commit ad678be

Browse files
brooniectmarinas
authored andcommitted
arm64/signal: Only read new data when parsing the ZT context
When we parse the ZT signal context we read the entire context from userspace, including the generic signal context header which was already read by parse_user_sigframe() and padding bytes that we ignore. Avoid the possibility of relying on the second read of the data read twice by only reading the data which we are actually going to use. Signed-off-by: Mark Brown <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]>
1 parent 24d6834 commit ad678be

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

arch/arm64/kernel/signal.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ static int preserve_zt_context(struct zt_context __user *ctx)
521521
static int restore_zt_context(struct user_ctxs *user)
522522
{
523523
int err;
524-
struct zt_context zt;
524+
u16 nregs;
525525

526526
/* ZA must be restored first for this check to be valid */
527527
if (!thread_za_enabled(&current->thread))
@@ -530,10 +530,10 @@ static int restore_zt_context(struct user_ctxs *user)
530530
if (user->zt_size != ZT_SIG_CONTEXT_SIZE(1))
531531
return -EINVAL;
532532

533-
if (__copy_from_user(&zt, user->zt, sizeof(zt)))
533+
if (__copy_from_user(&nregs, &(user->zt->nregs), sizeof(nregs)))
534534
return -EFAULT;
535535

536-
if (zt.nregs != 1)
536+
if (nregs != 1)
537537
return -EINVAL;
538538

539539
/*

0 commit comments

Comments
 (0)