From patchwork Thu Aug 1 08:16:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 170332 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp5086198ile; Thu, 1 Aug 2019 01:20:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqxxDHGfyYFu23a9XF+tWAN72Jj7l2itgEAzsmdIp6FwaZSLNIjrEfDxmBWT4GabZ/R8LbvJ X-Received: by 2002:a65:518a:: with SMTP id h10mr116070225pgq.117.1564647640254; Thu, 01 Aug 2019 01:20:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564647640; cv=none; d=google.com; s=arc-20160816; b=FOr1zHKQqLcOzTgQagr5ozXNMti2YqtwHBso+pp0Cg4PkR8teWTXrrmjwrqp9XiyQA bTXCAReM75RrWm8IGMyW5RDYmUDSnNmD3Uq/7oLHTFRg1mbZt6Uwj8MwNVqibzGvuWHQ mdMeZlV/zaEOk8b+LHoBHRtknW3HdohCXKixx38tjBoJZevD7qGJZp7ycvbgDo8U5NpM +pqedH6k0NwFV+IyEhG9gOATG8UDHJ4JtcNDjbhlG8Y1qEEEIl+xf9xh7tPR+JBPfbzU Jy4OPBX+UuIOkPYKWTxkJWCUEf6BKAvBHek5vpBh3qWgorddKaakOmBmS+6A2UmD4LQ5 s03w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=cd+CJgxpyw48wYexEQLN0Ryuy346dGX9j+MO3rZWGCA=; b=EO3aTz7x+VB66U/B+b9v9Wu7wdB3y5bq4iXdiNG1vT+BOmkY8nbVNC93yxJa93F0fx N97IlBsFJJ+Y8+PIA7oSBOC1B8DQoUIF4JF3QQ2/IaCiyhRoxrJgCxcZtpkFuC46grBY UVUp4tfwFoSl5qse+i5E34lrdUzvFPOv59nJNOvDgrMMe9UFS3Yb3iE1Ljt7LwcAH2PS jNwdp+qXCdip4oopadQCOYtKLD4K9WaMqCUTiwsrLAJcAyqwNyEk25r1MfWbBMufKZ5k sRPFVe1lnRbi9QbgTfhA+GS2OKFM78ze9HGEaupGKmlfE7Gb0xkZRM3/NGEvedKBeBqr Ri6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Z2hoeeYK; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f10si37407577pfq.194.2019.08.01.01.20.39; Thu, 01 Aug 2019 01:20:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Z2hoeeYK; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731089AbfHAIUj (ORCPT + 14 others); Thu, 1 Aug 2019 04:20:39 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:44928 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729760AbfHAIUi (ORCPT ); Thu, 1 Aug 2019 04:20:38 -0400 Received: by mail-pf1-f196.google.com with SMTP id t16so33575083pfe.11 for ; Thu, 01 Aug 2019 01:20:38 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=cd+CJgxpyw48wYexEQLN0Ryuy346dGX9j+MO3rZWGCA=; b=Z2hoeeYKddLvWgzkdCUEz+2ekNkZhKgcRMApcaKIJ7G2CIMAm1cubhuNLH0vwcT8P8 DmxIMWPwhRX603RJVjktdRBeAM4BzKt+1c16yhRSV52OElcwQ2L6MNZDgJZKJ2XoR/Vr qgiyoHQNvVUb7Nc+j7L1Iqm1RRpCH+xuPcVYNz1OUQYngmWAZuAlPcPICZa557bjJoeQ 30kRgnzcmBqKpvWjBhMv9oMvtu6dj7gKLZofh36CdRU9/n0nfWQvp2xA3iJPXLxub6cc 3Db/fga6lj3CgKI85yaJQhvd5i4Z9vn/+aPJLHb392RWMyFDVdH5e/2+Gp5+p1LbBpvR 4qMQ== 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:mime-version:content-transfer-encoding; bh=cd+CJgxpyw48wYexEQLN0Ryuy346dGX9j+MO3rZWGCA=; b=qVx/5BJQRQYb7Sf50uvsvcHbLUtVOW6hCHU0eCARJyEAJsXDGGP0Rr7qKVl/AvVwGq 40eRqRN9t4b5EyuOiZzzit+Uxn3KtVtYxXNTMsACVOZg+UTwnzBcBtUgTYwZt+Ty9yHO XR+Pf1kjb4o8fs+hs4dFjrXGDKI+SxdA9u0kWAA1nvUqcjeBDxtGaRQugmIGxhGT/uEr gr1SMrr4QENjF10ld9RskEZvcKjKD16coh3AEzpcz9TsZj96c85J+tJ7F6VdQ2FW7t3D n3NDqpCceTlQGfwx+sLY+SVZ/vvzE/cIEXGykC+Ex5o1HRWR88Ce0yz/Wsdv4IbMCHAR mUAQ== X-Gm-Message-State: APjAAAWo3VEQcHyFpusZ1rvA1xitijJmmrGZNliok/rAZj9RADwPD4YN 1dunn9UtZIEDzZM1xsSSbDxbMj7uN3I= X-Received: by 2002:a63:1046:: with SMTP id 6mr120820447pgq.111.1564647638075; Thu, 01 Aug 2019 01:20:38 -0700 (PDT) Received: from localhost ([122.172.28.117]) by smtp.gmail.com with ESMTPSA id e189sm56924368pgc.15.2019.08.01.01.20.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Aug 2019 01:20:37 -0700 (PDT) From: Viresh Kumar To: stable@vger.kernel.org Cc: Viresh Kumar , Julien Thierry , linux-arm-kernel@lists.infradead.org, Catalin Marinas , Marc Zyngier , Mark Rutland , Will Deacon , Russell King , Vincent Guittot , mark.brown@arm.com, guohanjun@huawei.com Subject: [PATCH ARM32 v4.4 V2 24/47] ARM: oabi-compat: copy semops using __copy_from_user() Date: Thu, 1 Aug 2019 13:46:08 +0530 Message-Id: X-Mailer: git-send-email 2.21.0.rc0.269.g1a574e7a288b In-Reply-To: References: MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.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 Signed-off-by: Viresh Kumar --- arch/arm/kernel/sys_oabi-compat.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) -- 2.21.0.rc0.269.g1a574e7a288b 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) {