Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp122904pxf; Wed, 24 Mar 2021 00:26:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzchQzSuBwY3OD7sPd3xddycPwIjFWY5/pVbE2/ZJvQSMQpN7y1LMnVGjsVkFyZLmkMFS2v X-Received: by 2002:a17:906:b752:: with SMTP id fx18mr2258652ejb.128.1616570796005; Wed, 24 Mar 2021 00:26:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616570795; cv=none; d=google.com; s=arc-20160816; b=W/pnkT3CNxlsrJ8i4c0boZN+D/sLVgtrf8Ls0QIm87Fe5M01rXav/TNi1Ue4ZwwrNu x0tvklHwOlUwJ+F8FzjOm0c/qtQt0YJ504PSPNF7SUkAMZYTQv72xGZdPT2zNjRjmc9K Ws1yR5XNhtWkXekXmBMXWYNLU3DuQN0RqilOvpcySyIBg9TWk8nIX+3AhM+YUv9+TDr+ cSBDnqxs3JEJYIrSIKXI1UqDXdl2AMcMT2F02dGymGSx+6ofAP3oG19igHnf4YeVolAc H3S/5oBNBxQPtiAjg4uLD3DSxASwCGW7cuPxBsqUiIjcSoHXvsNGtzzZAhTug/9vH1pa z5pA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=qy/qpaQcjeJGAGSX/SJfdvrV6+xztRS9WV/l31kV3fo=; b=cAvdv6i4fg0TZi7jDn1ddx5vAVqrQBtfCn+eidzFyltb1p55OUmDW2RFrqmgjsKmEr NS3MjD85/qfwdXETGOYFWNt98ac6t24RMdVfu0AS7R3YCVJfME8j5CxI2o1mj2fmxsBn wdaSO7j/vR3ef2pCuu2F9dqObAUaEDLepgnFyXvWTdn6xz0PBNnCZ6W7t27d9OrxmR5k akeh/vI+b2q5K6i+U4RkNj14rs1pQ0NdGlywyYGLgD8ajPB6qSHLW04wTA/AaJZYWrs2 TsxVbKIVzlTQru+TW9BrUhroLQZd7WRza2ZtvlODUU0b8S/jJq/o5/Xfc0O/1vYecAgv yVhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=p9ojVOb7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ga23si1186376ejc.129.2021.03.24.00.26.13; Wed, 24 Mar 2021 00:26:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=p9ojVOb7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233720AbhCWUlF (ORCPT + 99 others); Tue, 23 Mar 2021 16:41:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233557AbhCWUkP (ORCPT ); Tue, 23 Mar 2021 16:40:15 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7415BC0613E6 for ; Tue, 23 Mar 2021 13:40:15 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id u128so3795327ybf.12 for ; Tue, 23 Mar 2021 13:40:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=qy/qpaQcjeJGAGSX/SJfdvrV6+xztRS9WV/l31kV3fo=; b=p9ojVOb7QdO7JLZj9S/1SqPGP8MeifFmkf1e6TNJokU+4X+mDo0s3TIOhU1rmJD0gQ C3q3EV251sFO4e//IgvNjn6P29FqOur3szQsT80WVJVAgcgLC/L4gp8LF+fgzMkzOMdQ qK0XZckG24gPmdHwXF6V6z62Qj29O8AjeBevFbC/8BXBEoj5BXdSL0u6CL6w5E92BGE7 +vtDECL4yMlxuZ35+QWL2+CnrRi7FlCo5jHCQ87YudtBBhNKSZWNcK4Kl6XHbFJXUSPL qDxp8oIjW07ybSAxf6LQQ6rDchJmoirsp7IIZbdM6z6gMba2BAhKKUVuDpzy54UcfqSt 3+kA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=qy/qpaQcjeJGAGSX/SJfdvrV6+xztRS9WV/l31kV3fo=; b=BUyZDxPpzvj/e+9EokYZ5B/bs+TdHbywVJFsYe+ZNZdA/FRkdFw7GtEpjeUdhprw8q I9UNS3om7QKpgzFkxWIPByk9H0MLaqEScgozBMr3jFw8dXYhX6hDFbYDPc3SNkKP46bJ K1Rv6BahdEtEIB5qt3WiO/pjq2s0G5u80DUWgyRY5RYjICfE65HHQqMCEh5bqc49GtPR 2dpxg91pWddC6+0Iy/dPs8fbc8yTbdFFGi5knSCPJngKInDY+ZEYzN5ZkJvhk7unzp60 507vx74hBeoqQliEiiB9+i8mSQLjjFAsobHs+rzioMdHwu5l3pp4eX/x00m440YcgFwl hCBQ== X-Gm-Message-State: AOAM532m/L5fJPWASQ/ASnk9Gc84IoUD36XGhtx8gfo6O4Mo9TrDU9af mVywhbs6h3JVzsFWhUTCi+Ln+5lZMI4hlVfGsCw= X-Received: from samitolvanen1.mtv.corp.google.com ([2620:15c:201:2:e9a3:260d:763b:67dc]) (user=samitolvanen job=sendgmr) by 2002:a25:da48:: with SMTP id n69mr74886ybf.47.1616532014644; Tue, 23 Mar 2021 13:40:14 -0700 (PDT) Date: Tue, 23 Mar 2021 13:39:43 -0700 In-Reply-To: <20210323203946.2159693-1-samitolvanen@google.com> Message-Id: <20210323203946.2159693-15-samitolvanen@google.com> Mime-Version: 1.0 References: <20210323203946.2159693-1-samitolvanen@google.com> X-Mailer: git-send-email 2.31.0.291.g576ba9dcdaf-goog Subject: [PATCH v3 14/17] arm64: add __nocfi to functions that jump to a physical address From: Sami Tolvanen To: Kees Cook Cc: Nathan Chancellor , Nick Desaulniers , Masahiro Yamada , Will Deacon , Jessica Yu , Arnd Bergmann , Tejun Heo , "Paul E. McKenney" , Christoph Hellwig , Peter Zijlstra , bpf@vger.kernel.org, linux-hardening@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kbuild@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Sami Tolvanen Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Disable CFI checking for functions that switch to linear mapping and make an indirect call to a physical address, since the compiler only understands virtual addresses and the CFI check for such indirect calls would always fail. Signed-off-by: Sami Tolvanen Reviewed-by: Kees Cook --- arch/arm64/include/asm/mmu_context.h | 2 +- arch/arm64/kernel/cpu-reset.h | 8 ++++---- arch/arm64/kernel/cpufeature.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/arm64/include/asm/mmu_context.h b/arch/arm64/include/asm/mmu_context.h index 16cc9a694bb2..270ba8761a23 100644 --- a/arch/arm64/include/asm/mmu_context.h +++ b/arch/arm64/include/asm/mmu_context.h @@ -119,7 +119,7 @@ static inline void cpu_install_idmap(void) * Atomically replaces the active TTBR1_EL1 PGD with a new VA-compatible PGD, * avoiding the possibility of conflicting TLB entries being allocated. */ -static inline void cpu_replace_ttbr1(pgd_t *pgdp) +static inline void __nocfi cpu_replace_ttbr1(pgd_t *pgdp) { typedef void (ttbr_replace_func)(phys_addr_t); extern ttbr_replace_func idmap_cpu_replace_ttbr1; diff --git a/arch/arm64/kernel/cpu-reset.h b/arch/arm64/kernel/cpu-reset.h index dfba8cf921e5..a05bda363272 100644 --- a/arch/arm64/kernel/cpu-reset.h +++ b/arch/arm64/kernel/cpu-reset.h @@ -13,10 +13,10 @@ void __cpu_soft_restart(unsigned long el2_switch, unsigned long entry, unsigned long arg0, unsigned long arg1, unsigned long arg2); -static inline void __noreturn cpu_soft_restart(unsigned long entry, - unsigned long arg0, - unsigned long arg1, - unsigned long arg2) +static inline void __noreturn __nocfi cpu_soft_restart(unsigned long entry, + unsigned long arg0, + unsigned long arg1, + unsigned long arg2) { typeof(__cpu_soft_restart) *restart; diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index 7ec1c2ccdc0b..473212ff4d70 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -1443,7 +1443,7 @@ static bool unmap_kernel_at_el0(const struct arm64_cpu_capabilities *entry, } #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 -static void +static void __nocfi kpti_install_ng_mappings(const struct arm64_cpu_capabilities *__unused) { typedef void (kpti_remap_fn)(int, int, phys_addr_t); -- 2.31.0.291.g576ba9dcdaf-goog