Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3480525ybb; Mon, 6 Apr 2020 09:44:01 -0700 (PDT) X-Google-Smtp-Source: APiQypIVVzCARWr5f1ppLLNWkLbjROXJyRYxcCyIAksYSd28q4ZAudrQrAyjY7vNpIdf61yXY6Si X-Received: by 2002:a4a:2fd0:: with SMTP id p199mr57517oop.14.1586191440956; Mon, 06 Apr 2020 09:44:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586191440; cv=none; d=google.com; s=arc-20160816; b=VgM73FrMWfzVUJdKaPRanTjvwFOvb5oI9+jfXrhPHnXSCSMOsbyoqtSWY7xrWUJCrn dpTRh1I1nRpfB6i1Sf9vxkhKk9b2qdF+q9rKqrNQQe96rzgdodtWHvWmS269emi7HgqR B1c5C5J7m5AUwoWOqBJu/4AY1ODePlFC56exi4uGghGbfUSFve5ZqCYsV5DB/y/edbXw 2CURdsCOwHbERWU6GQobFWXUKOtfluJJgSHc5+Hfvz0tulHPHo0tW+BNqtOyuFQeDu+4 F4FgwR37Xy0p6jpou7zGOATjPRe3viM+F/c2DTIvKgU2/d/dWKWED/yyRVNAPVkl8TRJ Edqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=9QG25IWAvZkbAzL22nhTW74bT1ay/PnpyS4BHMHWGZk=; b=UjDZRkwpZoI8VS4Nh4YWX31xVEb5moqXDPpZASJuUlkp1qhJJk+EXJHBi57Dy4Akql FLLzC9pgHpTh6o2l8LSOZTOFmpRzAz8TazyaxocGMwWf2FzsRUanmONZ2EYoAEAWgwsW A5nMtLUbvcuNQ1fmAJrXMWxcfxxe/QC0Wf4zkFL+IuCqgglTDv3Ph8tGgYttNgwI+TFy /AS/wXnxVEU/BfDml1nXpJNSNObjZlD6siejhtg77Q1k+4Hsxe7TtFfVPn4iwayceQau Mm/tDjw0vTWlWbJOxWPethS7nAgStuKxoQFei1Bwhv4zsi/BOIwy5knoEuBngdPnM5DF agaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Et7gqyUD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id u133si7949784oib.138.2020.04.06.09.43.48; Mon, 06 Apr 2020 09:44:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@google.com header.s=20161025 header.b=Et7gqyUD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1729602AbgDFQlr (ORCPT + 99 others); Mon, 6 Apr 2020 12:41:47 -0400 Received: from mail-pl1-f202.google.com ([209.85.214.202]:53732 "EHLO mail-pl1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729540AbgDFQln (ORCPT ); Mon, 6 Apr 2020 12:41:43 -0400 Received: by mail-pl1-f202.google.com with SMTP id 2so81513plb.20 for ; Mon, 06 Apr 2020 09:41:42 -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=9QG25IWAvZkbAzL22nhTW74bT1ay/PnpyS4BHMHWGZk=; b=Et7gqyUD+/vBdaTxuXGtUp/T61DuoxfIWoFaBtN3Pan+9c6mJeAvmtTBqFUxV+t/h4 LN0HQT9+KjSaqn7Mixerv+7k7S7BD4mkDsLs/o8wZMIjVa09HJA7KFSGB/TtuXU7FvlL 6uPHdyBl7z3cK9g1xF6YKJ4HL90gk6SiklDTGe+TeqWBho/vNNZIxuxtDhoiNjjP56EE VSD6bCJZy8gm1psKtCCT8FCp/6jDu2WpsQ5TdwxuxinTh/gByzaJiThF8xLLt1HhDfgN opEo0Vvbom6U7ovVNJ2IYajd7Ohq17yrtIacfoTmqzq2KcnP242dGSb7nqvNQr4W2sOL fQPQ== 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=9QG25IWAvZkbAzL22nhTW74bT1ay/PnpyS4BHMHWGZk=; b=KVihb4EiKGBzRPpcKDBVnGIlnfYcHxO12h7HFYx8GeNNDY32/RLozdsxFZ9SDM6HDm qqJKRaWiyZBQeh2MtC/CEm1OAQJ+YXUgx3ljHdqSmOuPMCeXIpcV1j6eRywlJVTxtTEv 9WTUGQ4ZzVsVNjznkpd9t02V28ZHwiu7NBuZuxmcQ4Trg1quRBPnX92bm7hrcAnDZrYh MgDBCs0S6YStdKXFEu4p+XY42H1GLuvr45PJ3AHs9yXUBj8vRTeU9INLJfuW+SojbL13 RaW0JJiEQUcq3ujYDSuCAMKKvnNJuwgQPRNXxex8halzX0efs/u52spBwgLa5bovVjWm ci3w== X-Gm-Message-State: AGi0PuYGPAbinQ3dp+fb8+dp786dgCfkuBTSsmxRlLvZkWlM8+LaHHF+ u3bn17dO+jBqDhw42Sgd67I53N0IWzGeGwcQLrs= X-Received: by 2002:a17:90a:1b4f:: with SMTP id q73mr169352pjq.188.1586191301528; Mon, 06 Apr 2020 09:41:41 -0700 (PDT) Date: Mon, 6 Apr 2020 09:41:13 -0700 In-Reply-To: <20200406164121.154322-1-samitolvanen@google.com> Message-Id: <20200406164121.154322-5-samitolvanen@google.com> Mime-Version: 1.0 References: <20191018161033.261971-1-samitolvanen@google.com> <20200406164121.154322-1-samitolvanen@google.com> X-Mailer: git-send-email 2.26.0.292.g33ef6b2f38-goog Subject: [PATCH v10 04/12] scs: disable when function graph tracing is enabled From: Sami Tolvanen To: Will Deacon , Catalin Marinas , James Morse , Steven Rostedt , Masami Hiramatsu , Ard Biesheuvel , Mark Rutland Cc: Dave Martin , Kees Cook , Laura Abbott , Marc Zyngier , Nick Desaulniers , Jann Horn , Miguel Ojeda , Masahiro Yamada , clang-built-linux@googlegroups.com, kernel-hardening@lists.openwall.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sami Tolvanen Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The graph tracer hooks returns by modifying frame records on the (regular) stack, but with SCS the return address is taken from the shadow stack, and the value in the frame record has no effect. As we don't currently have a mechanism to determine the corresponding slot on the shadow stack (and to pass this through the ftrace infrastructure), for now let's disable SCS when the graph tracer is enabled. With SCS the return address is taken from the shadow stack and the value in the frame record has no effect. The mcount based graph tracer hooks returns by modifying frame records on the (regular) stack, and thus is not compatible. The patchable-function-entry graph tracer used for DYNAMIC_FTRACE_WITH_REGS modifies the LR before it is saved to the shadow stack, and is compatible. Modifying the mcount based graph tracer to work with SCS would require a mechanism to determine the corresponding slot on the shadow stack (and to pass this through the ftrace infrastructure), and we expect that everyone will eventually move to the patchable-function-entry based graph tracer anyway, so for now let's disable SCS when the mcount-based graph tracer is enabled. SCS and patchable-function-entry are both supported from LLVM 10.x. Signed-off-by: Sami Tolvanen Reviewed-by: Kees Cook Reviewed-by: Mark Rutland --- arch/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/Kconfig b/arch/Kconfig index 691a552c2cc3..c53cb9025ad2 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -542,6 +542,7 @@ config ARCH_SUPPORTS_SHADOW_CALL_STACK config SHADOW_CALL_STACK bool "Clang Shadow Call Stack" + depends on DYNAMIC_FTRACE_WITH_REGS || !FUNCTION_GRAPH_TRACER depends on ARCH_SUPPORTS_SHADOW_CALL_STACK help This option enables Clang's Shadow Call Stack, which uses a -- 2.26.0.292.g33ef6b2f38-goog