From: linux@armlinux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [RESEND PATCH 5/8] ARM: signal: copy registers using __copy_to_user()
Date: Thu, 6 Sep 2018 13:49:26 +0100 [thread overview]
Message-ID: <20180906124926.GP30658@n2100.armlinux.org.uk> (raw)
In-Reply-To: <1535447316-32187-6-git-send-email-julien.thierry@arm.com>
Hi Julien,
I would much prefer these to be ordered before the patches changing
__put_user() etc. That would then allow patch 2 (which would become
the last patch) to get rid of __put_user_error() - __put_user_error()
is utterly pointless with the need to work around Spectre, and that
would reflect what was done in my series for Spectre variant 1.
In any case, removing it from signal handling, vfp and oabi compat
should mean that after your existing series, there are no users of
__put_user_error(), but it still remains.
Thanks.
On Tue, Aug 28, 2018 at 10:08:33AM +0100, Julien Thierry wrote:
> When saving the ARM integer registers, use __copy_to_user() to
> copy them into user signal frame, rather than __put_user_error().
> This has the benefit of disabling/enabling PAN once for the whole copy
> intead of once per write.
>
> Signed-off-by: Julien Thierry <julien.thierry@arm.com>
> ---
> arch/arm/kernel/signal.c | 49 ++++++++++++++++++++++++++----------------------
> 1 file changed, 27 insertions(+), 22 deletions(-)
>
> diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
> index b8f766c..76fe75d 100644
> --- a/arch/arm/kernel/signal.c
> +++ b/arch/arm/kernel/signal.c
> @@ -288,30 +288,35 @@ asmlinkage int sys_rt_sigreturn(struct pt_regs *regs)
> setup_sigframe(struct sigframe __user *sf, struct pt_regs *regs, sigset_t *set)
> {
> struct aux_sigframe __user *aux;
> + struct sigcontext context;
> int err = 0;
>
> - __put_user_error(regs->ARM_r0, &sf->uc.uc_mcontext.arm_r0, err);
> - __put_user_error(regs->ARM_r1, &sf->uc.uc_mcontext.arm_r1, err);
> - __put_user_error(regs->ARM_r2, &sf->uc.uc_mcontext.arm_r2, err);
> - __put_user_error(regs->ARM_r3, &sf->uc.uc_mcontext.arm_r3, err);
> - __put_user_error(regs->ARM_r4, &sf->uc.uc_mcontext.arm_r4, err);
> - __put_user_error(regs->ARM_r5, &sf->uc.uc_mcontext.arm_r5, err);
> - __put_user_error(regs->ARM_r6, &sf->uc.uc_mcontext.arm_r6, err);
> - __put_user_error(regs->ARM_r7, &sf->uc.uc_mcontext.arm_r7, err);
> - __put_user_error(regs->ARM_r8, &sf->uc.uc_mcontext.arm_r8, err);
> - __put_user_error(regs->ARM_r9, &sf->uc.uc_mcontext.arm_r9, err);
> - __put_user_error(regs->ARM_r10, &sf->uc.uc_mcontext.arm_r10, err);
> - __put_user_error(regs->ARM_fp, &sf->uc.uc_mcontext.arm_fp, err);
> - __put_user_error(regs->ARM_ip, &sf->uc.uc_mcontext.arm_ip, err);
> - __put_user_error(regs->ARM_sp, &sf->uc.uc_mcontext.arm_sp, err);
> - __put_user_error(regs->ARM_lr, &sf->uc.uc_mcontext.arm_lr, err);
> - __put_user_error(regs->ARM_pc, &sf->uc.uc_mcontext.arm_pc, err);
> - __put_user_error(regs->ARM_cpsr, &sf->uc.uc_mcontext.arm_cpsr, err);
> -
> - __put_user_error(current->thread.trap_no, &sf->uc.uc_mcontext.trap_no, err);
> - __put_user_error(current->thread.error_code, &sf->uc.uc_mcontext.error_code, err);
> - __put_user_error(current->thread.address, &sf->uc.uc_mcontext.fault_address, err);
> - __put_user_error(set->sig[0], &sf->uc.uc_mcontext.oldmask, err);
> + context = (struct sigcontext) {
> + .arm_r0 = regs->ARM_r0,
> + .arm_r1 = regs->ARM_r1,
> + .arm_r2 = regs->ARM_r2,
> + .arm_r3 = regs->ARM_r3,
> + .arm_r4 = regs->ARM_r4,
> + .arm_r5 = regs->ARM_r5,
> + .arm_r6 = regs->ARM_r6,
> + .arm_r7 = regs->ARM_r7,
> + .arm_r8 = regs->ARM_r8,
> + .arm_r9 = regs->ARM_r9,
> + .arm_r10 = regs->ARM_r10,
> + .arm_fp = regs->ARM_fp,
> + .arm_ip = regs->ARM_ip,
> + .arm_sp = regs->ARM_sp,
> + .arm_lr = regs->ARM_lr,
> + .arm_pc = regs->ARM_pc,
> + .arm_cpsr = regs->ARM_cpsr,
> +
> + .trap_no = current->thread.trap_no,
> + .error_code = current->thread.error_code,
> + .fault_address = current->thread.address,
> + .oldmask = set->sig[0],
> + };
> +
> + err |= __copy_to_user(&sf->uc.uc_mcontext, &context, sizeof(context));
>
> err |= __copy_to_user(&sf->uc.uc_sigmask, set, sizeof(*set));
>
> --
> 1.9.1
>
--
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 13.8Mbps down 630kbps up
According to speedtest.net: 13Mbps down 490kbps up
next prev parent reply other threads:[~2018-09-06 12:49 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-28 9:08 [RESEND PATCH 0/8] ARM: spectre-v1.1 mitigations Julien Thierry
2018-08-28 9:08 ` [RESEND PATCH 1/8] ARM: uaccess: Prevent speculative use of the current addr_limit Julien Thierry
2018-08-28 9:08 ` [RESEND PATCH 2/8] ARM: spectre-v1.1: force address sanitizing for __put_user*() Julien Thierry
2018-08-28 9:08 ` [RESEND PATCH 3/8] ARM: spectre-v1, v1.1: provide helpers for address sanitization Julien Thierry
2018-09-06 12:48 ` [RESEND PATCH 3/8] ARM: spectre-v1,v1.1: " Russell King - ARM Linux
2018-09-06 14:24 ` Julien Thierry
2018-08-28 9:08 ` [RESEND PATCH 4/8] ARM: spectre-v1.1: harden __copy_to_user Julien Thierry
2018-08-28 9:08 ` [RESEND PATCH 5/8] ARM: signal: copy registers using __copy_to_user() Julien Thierry
2018-09-06 12:49 ` Russell King - ARM Linux [this message]
2018-09-06 14:25 ` Julien Thierry
2018-08-28 9:08 ` [RESEND PATCH 6/8] ARM: signal: always use __copy_to_user to save iwmmxt context Julien Thierry
2018-08-28 9:08 ` [RESEND PATCH 7/8] ARM: vfp: use __copy_to_user() when saving VFP state Julien Thierry
2018-08-28 9:08 ` [RESEND PATCH 8/8] ARM: oabi-compat: copy oabi events using __copy_to_user() Julien Thierry
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180906124926.GP30658@n2100.armlinux.org.uk \
--to=linux@armlinux.org.uk \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).