From patchwork Thu Jan 10 17:51:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 155245 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2175981jaa; Thu, 10 Jan 2019 09:51:54 -0800 (PST) X-Received: by 2002:ac8:4258:: with SMTP id r24mr10808498qtm.213.1547142714606; Thu, 10 Jan 2019 09:51:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547142714; cv=none; d=google.com; s=arc-20160816; b=hCDihWUshiV7wNx+FuqUrpyK7EibfjcczksBSecz+dWRV31Jb0a1uTMyMqU3msjT24 90aT9hk8LrhWE149QjtbKo6UM118GWIlRMBxRYyYgF2QStXTAK/ka0FYRSjjTnP07E0o hGHWkT5Od43M7IwFhPOWQOIFGmEbNt5kT8Vp6qAWFs2o3BJxQuK4xYbZuQKzv0xy2jZP fbldVSkzSZdIxLxML4Cmr2veKzaOd00wM6fa8X9eOgHYHUHCO0slI1QMI3TbjzB99Ipr sjTojoGj/z/MWKybnbCkh+VMuzaJ1lZYNR87cBKOhx86QsIa+EduW0q9VFTpwGvPq4Zy QlOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=JdLRrZPibA2dIcwMA1KY3ab0IY+IQcbm99bqdyt8hkw=; b=lm06b5DnPFl6WUPd6gP7nA38VSjPWciHgOrlaMdIKVwqEbiqi5c9ZxSTGgsABvQcCS SDN+me+aS2LLhlvLHkQgUVjzYxCI08Bwc+68RZk3OleUpBX2iUSR2xAO4X2N9qSxPH+A KwHrEBG5H5YOXo8mmnbxrIad2r2ZUVu11xMzktGgQM8N4dT/LEjZWTFzRC0YufzdkSHP 2yzE35LiFGF45luBfIqS4wkCUwrRcOgysSJYAGUdSlyfjcHpo9TNg7PDrbVUQeHwEPPl rJA702reoE+omfByM8fgetz9wJHK3rjvnwK41EmATlANDmLaWdaM4MMU7Ynom+SAiNc5 2yFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UzrGXbEs; spf=pass (google.com: domain of dave.long@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=dave.long@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id v66sor9690667qkh.138.2019.01.10.09.51.54 for (Google Transport Security); Thu, 10 Jan 2019 09:51:54 -0800 (PST) Received-SPF: pass (google.com: domain of dave.long@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UzrGXbEs; spf=pass (google.com: domain of dave.long@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=dave.long@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=JdLRrZPibA2dIcwMA1KY3ab0IY+IQcbm99bqdyt8hkw=; b=UzrGXbEsoP6BDF2X1AalBLgV2YrTfRwhfEkZuMvbAwfa8H8w2zxWzlvfCsjPg8jp4L iw06xvImEdYEJk7gHOGqQJhegQdSWfDV9x9sTiBoJaCldpkxJQrrXSx6t81kWeW9xueS ETA0a2T822wtIwhNVAG6SEH1xY1Ybm2Pcwajw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=JdLRrZPibA2dIcwMA1KY3ab0IY+IQcbm99bqdyt8hkw=; b=UzSi9koFbgPi5NLG6ZfnsLb6gpdTR5/Pznc+f/o3mSF7hckI/rvwIEG3NwQYL/KQ+Y siJoLFyX2XLnZljL9qC1NHfqslWoaDWoPhylBYKrUIf6iEty6++cOeEs4ArwinuDc2SB zv/7QqpRL4TxAlh2soLcy64vaRO1Tz7BkND5IIIgFdRtZqqRjme+uJtqBis1wBIZnNq7 BNEqQNX5508nbEmIZ+7T75E0q1qeVOtSk2UJ+D41M8yPM2q6iLhUnD3PnhvnoCduELO/ oQOU5xrkDYWNr9YxQbrzoNgTyj8uG/Zaqbx0rEc7XBvh51OqslgvO9Oy68ajsTBaC5QK JXHQ== X-Gm-Message-State: AJcUukdC5wmhjvp3qX2b8wnmOsTjPp/ZFQhmo/zzx0zVOuAVxPSY6pTf ftCM3hoC/mohqSM/tT1opM7YVpQ4 X-Google-Smtp-Source: ALg8bN4Fkl6ODTP/UhBFyFBnXhDxaAfj70cvw18D/M4Sysygrd4/ne1C+7fiL37RqTjK+1r1JPGf4w== X-Received: by 2002:a37:9c57:: with SMTP id f84mr10025110qke.176.1547142714110; Thu, 10 Jan 2019 09:51:54 -0800 (PST) Return-Path: Received: from localhost.localdomain (pool-72-71-243-63.cncdnh.fast00.myfairpoint.net. [72.71.243.63]) by smtp.googlemail.com with ESMTPSA id b8sm41815904qka.79.2019.01.10.09.51.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Jan 2019 09:51:53 -0800 (PST) From: David Long To: stable@vger.kernel.org, Russell King - ARM Linux , Florian Fainelli , Julien Thierry , Tony Lindgren , Marc Zyngier , Mark Rutland Cc: Greg KH , Mark Brown Subject: [PATCH 4.14 01/17] ARM: 8789/1: signal: copy registers using __copy_to_user() Date: Thu, 10 Jan 2019 12:51:34 -0500 Message-Id: <20190110175150.5239-2-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190110175150.5239-1-dave.long@linaro.org> References: <20190110175150.5239-1-dave.long@linaro.org> From: Julien Thierry Commit 5ca451cf6ed04443774bbb7ee45332dafa42e99f upstream. 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 Signed-off-by: Russell King Signed-off-by: David A. Long --- arch/arm/kernel/signal.c | 49 ++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 22 deletions(-) -- 2.17.1 diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c index cdfe52b15a0a..1dc1f39825b6 100644 --- a/arch/arm/kernel/signal.c +++ b/arch/arm/kernel/signal.c @@ -296,30 +296,35 @@ static int 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));