From patchwork Mon Oct 15 15:32:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 148871 Delivered-To: patches@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp3934107lji; Mon, 15 Oct 2018 08:32:44 -0700 (PDT) X-Received: by 2002:a0c:92f3:: with SMTP id c48mr17209385qvc.39.1539617563928; Mon, 15 Oct 2018 08:32:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539617563; cv=none; d=google.com; s=arc-20160816; b=u0tiWkztnehuAkWWEbVLbi1ueePOjHWyG3mYuW4xlAlHwgvob4bxaI0oiUm9TcFHcd DgXHiCCO9dvG9RuTyDPCg/J19xzkYM1d1ovHca6cW067qStSB30/R0yNqFCsHsi882fy jfpDfa0wkwfG3bPirpOR82TUbsGWGZ5I4A/1UNxqDcWG2sHuR5Ey0VZIG8WHbW56In+f RAChHyDnUjYpQ49ARegJj1JvNdp6eoGZVaUECCT3GYisbn3XepHIluuiaN8bLg83YSWY XfVoSYnWI3SA/6YEumBx4iJY+y7i2Z3orWzf2mxZrdjNIY4VDc12/RVZOhGtw8n6ayvY y7eA== 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=kaYwyiLiqbp3ApLMSp+XwtWz/du68dLedeyXm7UQOlc=; b=F3p80hLf3LVVMVU7U/na8JqoGvTl9qnqHpLMTeJntEyiuH5RgLrF0gXCkAng1Dy1VU xS/pbMKXB0wTqobwU5SbkQK2kFZjC8O1PCKM4hcROk/ZdURtXaqzfj3isyCceAbVigeR DivkdS9Mp3HwAx2L8z/J8jwpkXoiJBQHVTQ/CUcXCjXJAT3xdfgHwfLfl84xGdj9DRff wTdl9NCR0eWx0xaxVq4ABJdFH1lJKJsiJdeDjRCFezMhOL8gnkXayAwr/IaSdjbbuvlq JTeVdVLx1ze7OvE3g5WFkM3h5+Mv+17uvE0QdQhFuJepDk4EVYVcUe4mp4ryfj40RMKC rr8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DNbi8CQ0; 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 x83-v6sor6408845qkb.86.2018.10.15.08.32.43 for (Google Transport Security); Mon, 15 Oct 2018 08:32:43 -0700 (PDT) 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=DNbi8CQ0; 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=kaYwyiLiqbp3ApLMSp+XwtWz/du68dLedeyXm7UQOlc=; b=DNbi8CQ0einghyYn5cNh2uNm6eJmEayXWVkT1W81UwBKVY7t9az1PCv/X3z+wtPuRk C493pK70z/PHyZQZWajHZU/2HbaXrTNQ1yI/7KZHZ4M0vnTJXQvU8pm+zo/yE1z0HaAb kMZneoMinOEHMo8Coy1ppz7CR2heK+4Xq2194= 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=kaYwyiLiqbp3ApLMSp+XwtWz/du68dLedeyXm7UQOlc=; b=obBNSWwuMDYaRJm/XsI+VDCs/rkWW+kb1kywOgESq2NSfoNykYKGJ6SvCMtuSIYiw0 ri3t8h8+tDpDXSMDI3aQfkxkvT1o8SWQFcbPkASmcaDQn2zII2b0uLiyMfOQDVMzJDEr G48ia1X/6AmkYEbuZcr68KrzRk8YyDtsihFrlg2USN2wEKHaC8nCzYZtELhnN4FGYhUf 0ffarzeZa/rJtk0pdiuNLyB2vO7qvHiLFGW5eOh4k5dvSBwcaUReYaCNwrr870r/E6hC L1jdm5G8jrqmG0m988RJrnc5BwutDevTueUyID7riDs7lt5c5DyocQWVumDDiyFirTwr 4VtQ== X-Gm-Message-State: ABuFfohi2U6cPy40Hn7Znp0qqlPP17CGpwt2sexIluUUUhy/hgTuS2+s ILtrLJmF55Jz/YsOnq7++vCLNYQ+ X-Google-Smtp-Source: ACcGV63vHFczBSqwD+9Ary+9ZskBJLDF8FrBY/2MVsYoQc73HH40NEtV2InR8BYPXKvwzAZGAPNTXg== X-Received: by 2002:a37:15e7:: with SMTP id 100-v6mr16686190qkv.151.1539617563278; Mon, 15 Oct 2018 08:32:43 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([72.71.243.63]) by smtp.googlemail.com with ESMTPSA id g82-v6sm10087768qkh.24.2018.10.15.08.32.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Oct 2018 08:32:42 -0700 (PDT) From: David Long To: , Russell King - ARM Linux , Florian Fainelli , Tony Lindgren , Marc Zyngier , Mark Rutland Cc: Greg KH , Mark Brown Subject: [PATCH 4.14 21/24] ARM: oabi-compat: copy semops using __copy_from_user() Date: Mon, 15 Oct 2018 11:32:15 -0400 Message-Id: <1539617538-22328-22-git-send-email-dave.long@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1539617538-22328-1-git-send-email-dave.long@linaro.org> References: <1539617538-22328-1-git-send-email-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.5.0 diff --git a/arch/arm/kernel/sys_oabi-compat.c b/arch/arm/kernel/sys_oabi-compat.c index b9786f4..4abe490 100644 --- a/arch/arm/kernel/sys_oabi-compat.c +++ b/arch/arm/kernel/sys_oabi-compat.c @@ -329,9 +329,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) {