From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2586AC742A8 for ; Fri, 12 Jul 2019 05:31:59 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id ECB0821530 for ; Fri, 12 Jul 2019 05:31:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="hfMAF4sp"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="cKXVVMIE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ECB0821530 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=kAYGcEbJwZSsi1c47p9ogTsoHe9UtnbPikGQM/4dTxY=; b=hfMAF4sp8NR89O 2Bn/bHGm+SYogGS4xT5L/3LiYOR1WrN/HUavC01Lh3C+4d9C/UYhDYRlt5Zsv7orvyx7VEF0rAf3O peTgIccylU5mwNK3UC9kwut6y5e2nw+lcqG7qNyDALCNbLgMeICLHLuWDYp506N2uxZI0j4ES7Fmf 5kT0ejvBSVChLV52C8xzo9+sX6huGJxoRdVvQsvQBwvbijOfxqE+rnIQWEvkUEMVtCmWY9VA7+ALy RL7glNi76O5zITWdt6Dl2bT84k45P4VMMfE55sYYYqwLa4hhiUYKMNMWP/VNdtCjILNj3hEiHOpWm dPQSp0vx4tk2/GwEeE1A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hlo9t-0003UL-N5; Fri, 12 Jul 2019 05:31:49 +0000 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hlo7T-0000Tf-8o for linux-arm-kernel@lists.infradead.org; Fri, 12 Jul 2019 05:29:21 +0000 Received: by mail-pf1-x444.google.com with SMTP id g2so3803432pfq.0 for ; Thu, 11 Jul 2019 22:29:18 -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=gNlfncScxDREAT7VjTEXAFzdaeKYbTqQ4JYCBMZ7gaA=; b=cKXVVMIE78QmcDsJ8R1sTpeboiLZLLwZ56moXlqZPVbf8aD8vMMu4Pvrm2aCvGwZUe /q51yWLi8ZVUyVOJ+XpmDnfQMDM0AlfnbywjiCvIB8wYmBsxXtXVZiSU4BC7t9OVilng DG/7xeCbeqrNVTU6/lMYNfpfYsOAMgVe6IN/V03s1mYMoXp5axz+HSBQ0IKiyltXMSFr wRoTudkSz8nW8zy40AXY6gIncpiXe57jVQfwyA15sxy9Dh5Oy0kVl+sjVutCkc/aoLA5 8lD5nJwig2b9lUBOJtdhwXQbno+v6eTUCAbdE1ByEBqwET4r6XcsfkpaytrzUd0dbnYx uTmg== 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=gNlfncScxDREAT7VjTEXAFzdaeKYbTqQ4JYCBMZ7gaA=; b=qgnQTEjejLFfQPYpsEfItFlUIdjFpuk0km1AkRPA1oD+JoPEcw7dCGvIAxEGWmRG9q 5lv5vaSc+1xDwQHQKNrfJFapUd3iRV0yYQ5V6S29OkjeoGyZ69hzjYx63ztwSUbxZis7 /SP9fPw8dSI7/G3yCUSm+sCLBbUSQXl+4WucNoTLCBYl/LzSKzoi2CynnVZ55s12YYWQ VcazTGxvlzrCEKJ9XgJKgR0k+inYG4ZLBOEvYbc7vj6+oE7P2dKWxlv/+cgN0RJGW+HQ fDKGVUiM9wtZ6CBAzdLsNCZtutsyUiYWJ9KILtk4sfhY1F89InGO8rALVHO4ACq00Je8 GtuA== X-Gm-Message-State: APjAAAVeiVNBIpUp0QUq6E7AxCrQkS99wHDRacqxK2v6ovL3ZIwU/QdA xCq2mcGnKTYBZmIG1tSsYSv28HNj51U= X-Google-Smtp-Source: APXvYqzOs7AoxIeTNlLbUFu/r10BOMxy5Hb11XJhBZ3loQ0w6O6qKzqvd0UQkPq53twoAlpesJxRqQ== X-Received: by 2002:a17:90a:cb12:: with SMTP id z18mr9007071pjt.82.1562909358269; Thu, 11 Jul 2019 22:29:18 -0700 (PDT) Received: from localhost ([122.172.28.117]) by smtp.gmail.com with ESMTPSA id o14sm13901475pfh.153.2019.07.11.22.29.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Jul 2019 22:29:17 -0700 (PDT) From: Viresh Kumar To: stable@vger.kernel.org, Julien Thierry Subject: [PATCH v4.4 V2 07/43] arm64: uaccess: Prevent speculative use of the current addr_limit Date: Fri, 12 Jul 2019 10:57:55 +0530 Message-Id: X-Mailer: git-send-email 2.21.0.rc0.269.g1a574e7a288b In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190711_222919_361929_EB42E972 X-CRM114-Status: GOOD ( 10.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Marc Zyngier , Viresh Kumar , Will Deacon , mark.brown@arm.com, Catalin Marinas , Russell King , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Will Deacon commit c2f0ad4fc089cff81cef6a13d04b399980ecbfcc upstream. A mispredicted conditional call to set_fs could result in the wrong addr_limit being forwarded under speculation to a subsequent access_ok check, potentially forming part of a spectre-v1 attack using uaccess routines. This patch prevents this forwarding from taking place, but putting heavy barriers in set_fs after writing the addr_limit. Reviewed-by: Mark Rutland Signed-off-by: Will Deacon Signed-off-by: Catalin Marinas Signed-off-by: Viresh Kumar --- arch/arm64/include/asm/uaccess.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h index 75363d723262..fc11c50af558 100644 --- a/arch/arm64/include/asm/uaccess.h +++ b/arch/arm64/include/asm/uaccess.h @@ -62,6 +62,13 @@ extern int fixup_exception(struct pt_regs *regs); static inline void set_fs(mm_segment_t fs) { current_thread_info()->addr_limit = fs; + + /* + * Prevent a mispredicted conditional call to set_fs from forwarding + * the wrong address limit to access_ok under speculation. + */ + dsb(nsh); + isb(); } #define segment_eq(a, b) ((a) == (b)) -- 2.21.0.rc0.269.g1a574e7a288b _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel