From patchwork Wed Nov 7 16:43:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 150436 Delivered-To: patches@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp5387565ljp; Wed, 7 Nov 2018 08:44:30 -0800 (PST) X-Received: by 2002:ac8:2729:: with SMTP id g38-v6mr975357qtg.168.1541609070136; Wed, 07 Nov 2018 08:44:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541609070; cv=none; d=google.com; s=arc-20160816; b=aRf49nALYrpzLEz3pDrh2Pd94JEAPsMmqiD1Uyhj/mWbcJVzJstpUjerzQe1+t5a+B c6JQoMJ4Gzsm43TSL5NBWjERI+EYYS6ODof9SdfLYp5eUvfCVGMKx/97fFS6gUB51PyI fU+vv4jl5iiyP3k7rty7ORekWD9GBXDBJMFD0TWSn+UXJ+DTo6OMYL+M2uAbO9C+4iX7 69G5rAk+XbH5UOrfu8WwJtfXKfhuxSuWI0rABMNaogL4riFIfhqx+XlIZvPB3T0u8rEd Pj94tNI22TSyWsR+7x6IiM/qJj7XoFk01AlpC606QB5nsR7b1jIAck+u3y5IZMUQktpC pTGw== 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=IaoQxTRrxrYBzQWir0u9ErhYqEdp4e5JRmU48kGigvg=; b=EgQxsd4ouBhWYPJLNtif8yqOmEUpXspe893i3+FRtGaZbaW17JNd/Gtgrl31IyTL/H u8Fr7Uu5FRGBZgSV9SsPgm+kvrerBKrNNAnwAxxBUHWb8lcmDqmYLJJJ7z16jBmBlDEC GYdDkqnC03+uzG/6X8nIjul4M+v83T8tx+wwfwkKxlWOtxRiYpBgh8vWu1o4+zeEhYh7 tHK73IJ0rR02ZyUat1+mPdNWuNqNf51aY7UVwPvmUDnYVMbamYcPl8CersBCWIdrJ7dQ 7wQPXwidtWCGvuJz8fELpAYk4hzV9I6g8stFirMfyUllyhjQrqQ2e3e2UTVKhodkfGFU ExwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QM4ksajz; 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 b127sor644092qkc.48.2018.11.07.08.44.29 for (Google Transport Security); Wed, 07 Nov 2018 08:44:30 -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=QM4ksajz; 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=IaoQxTRrxrYBzQWir0u9ErhYqEdp4e5JRmU48kGigvg=; b=QM4ksajzmmbpZkQhfhWG60F3SGkJ5YCdOROCgMH0zyGWDY7AWE+/V9nCVus+KvNJbR n3optY4Rzhl56TkDWFuGtkw5LUBY1j454R4N5ypGpZ/igTIEwjoyemMZ/LZ0zR0IMk1l PABc9OtKGGeTY/O4dq+VY6XepthHIqJhR9/RY= 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=IaoQxTRrxrYBzQWir0u9ErhYqEdp4e5JRmU48kGigvg=; b=lOzU+9rke/EjdrvvTxAxgDgP1zWJBXO1KsfJpz+NugGnZcnqnJc4o/6h5kQIAADAdc F0fpDnmTf9/Af/vvAM15VU3USTJqxRmE2N+ilBgBhBr8SSqzSohemrtJU7ywBsmddGzV wX9TgyHfGQq8cgy7jjDrnrMrdVxvtjdiOHQRQpPBzUTJHYWJGA0zuJ0T6d+Z8B3qEyh8 e/jUTniaEMusgunJM7Ei/QZtDGo4VZwKaWxKMd/P3P47MjAgwdB7aOivQnmM87RCTn5P NOQvpiUlcKaQDVM2YF74C3kMxFCvsaO2U393vvHSu0ubyDZ/VCW8pPE4IPffLIYZ1SE8 6Pmg== X-Gm-Message-State: AGRZ1gJp6kXgGvIvw4l9NjkbHbq52FhpU5ShADwaiky9HB7tDkT17/MR gvdRklMLxl+c3S9cR/nugjfSTt+z3iPO1g== X-Google-Smtp-Source: AJdET5dgTUO2k6soNHIiBZIy4t4G1uNUBT+fAvnl/uKE273YPI0yCA8P6MvzXTuR7lH728BR7iBkHQ== X-Received: by 2002:a37:630a:: with SMTP id x10mr942223qkb.146.1541609069677; Wed, 07 Nov 2018 08:44:29 -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 96-v6sm681817qtc.56.2018.11.07.08.44.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Nov 2018 08:44:29 -0800 (PST) From: David Long To: stable@vger.kernel.org, Russell King - ARM Linux , Florian Fainelli , Tony Lindgren , Marc Zyngier , Mark Rutland Cc: Greg KH , Mark Brown Subject: [PATCH 4.9 V2 21/24] ARM: oabi-compat: copy semops using __copy_from_user() Date: Wed, 7 Nov 2018 11:43:59 -0500 Message-Id: <20181107164402.9380-22-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181107164402.9380-1-dave.long@linaro.org> References: <20181107164402.9380-1-dave.long@linaro.org> From: Russell King Commit 8c8484a1c18e3231648f5ba7cc5ffb7fd70b3ca4 upstream. __get_user_error() is used as a fast accessor to make copying structure members as efficient as possible. However, with software PAN and the recent Spectre variant 1, the efficiency is reduced as these are no longer fast accessors. In the case of software PAN, it has to switch the domain register around each access, and with Spectre variant 1, it would have to repeat the access_ok() check for each access. Rather than using __get_user_error() to copy each semops element member, copy each semops element in full using __copy_from_user(). Acked-by: Mark Rutland Signed-off-by: Russell King Signed-off-by: David A. Long --- arch/arm/kernel/sys_oabi-compat.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/arch/arm/kernel/sys_oabi-compat.c b/arch/arm/kernel/sys_oabi-compat.c index 5f221acd21ae..640748e27035 100644 --- a/arch/arm/kernel/sys_oabi-compat.c +++ b/arch/arm/kernel/sys_oabi-compat.c @@ -328,9 +328,11 @@ asmlinkage long sys_oabi_semtimedop(int semid, return -ENOMEM; err = 0; for (i = 0; i < nsops; i++) { - __get_user_error(sops[i].sem_num, &tsops->sem_num, err); - __get_user_error(sops[i].sem_op, &tsops->sem_op, err); - __get_user_error(sops[i].sem_flg, &tsops->sem_flg, err); + struct oabi_sembuf osb; + err |= __copy_from_user(&osb, tsops, sizeof(osb)); + sops[i].sem_num = osb.sem_num; + sops[i].sem_op = osb.sem_op; + sops[i].sem_flg = osb.sem_flg; tsops++; } if (timeout) {