From patchwork Mon Jul 10 12:14:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Masami Hiramatsu (Google)" X-Patchwork-Id: 11805 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp4995640vqx; Mon, 10 Jul 2023 05:42:35 -0700 (PDT) X-Google-Smtp-Source: APBJJlH1h5ElobQ2YiXV3xxyZE4RXuuO7cvIKbT9r8B0+Lww3bq7o3uLbXHZKShfc5uUYOgxoMZ+ X-Received: by 2002:a05:6358:9214:b0:133:291:f9ac with SMTP id d20-20020a056358921400b001330291f9acmr12133878rwb.25.1688992955004; Mon, 10 Jul 2023 05:42:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688992954; cv=none; d=google.com; s=arc-20160816; b=cx0+JqhwrdV87YUQDl0+ayVJFfIfE0vViGecNk+rlwI9QLRAI5xuDQIVUQzkJFE9AG /5SQbz+yAhIslHDppLGL7WECCXfmsbQDaZvhP45QWesdl97BhEaiwiLgm9r/w3CnUT7O 1CDu3PcEVsPrrkP9TC39M/IC46S4aL0m8U/kdLMZzA3CJvJZeBv/qj4AZ5UeE/aH1vY6 RiTt7hfA62+ww/5Ysrv6p6loxqnVM1g+eajteA7lHhdhy2k2hQs+FYMEc/ztkWmVZshn w6UHSZZE1AaU1ZgCwOsCv8h/xIuYoyabd7F5Krp2kBtVKmR/l9MhsnnbyBQYbrXxJBAZ Seew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:message-id:date:subject:cc:to:from:dkim-signature; bh=FkEO1tqZ+27O7SSIoQS4r6u+s69zGccn3H8AHcTlJjk=; fh=B4q89xUy9DRjDdZZ7pfgA4xc0K5nMMNyHs2WNlwRQlk=; b=SyOBI48beOauEHN4+ijMvTRHU+7IJTYKhQn6voEQuvpTvCCkW1/+jDfw7g8Yw5hpLW kceOsLmQTsta9KOazC+xbQsoUjvtUvyrj9MRFdvVEIOgK3xlBbPDg1Eqva3gbKUp0J9K 6jS/tw2hz4j/QBHK2Xdfk0b+K+gSLbGS2yR678emd7oy9d9iE7tt6tS1RuNXx++7q94u JXUyc9r3URCvqtPZqUbHE1F0XWAkj0LdEyh1raMo/v/hmnent5zv3dICaP4lnlrjBc0J PPXwPHEE8P2AEfx6g7B3AFOWReCM9hwERCg6wSOH/aQNWZWHj3a61lcvVOS1ZPnQOJbh tAoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RPkV13vT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z24-20020a631918000000b00543c8ad57f1si8826250pgl.67.2023.07.10.05.42.22; Mon, 10 Jul 2023 05:42:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RPkV13vT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230284AbjGJMOX (ORCPT + 99 others); Mon, 10 Jul 2023 08:14:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230361AbjGJMOV (ORCPT ); Mon, 10 Jul 2023 08:14:21 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1584DFE; Mon, 10 Jul 2023 05:14:20 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A466460FD8; Mon, 10 Jul 2023 12:14:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5AA4DC433C7; Mon, 10 Jul 2023 12:14:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688991259; bh=uRmPflcHLfzXe1J+lIanercG5gxP43DJIKpzISbfov4=; h=From:To:Cc:Subject:Date:From; b=RPkV13vTx9RSPN6IsnCOgNJa7lL+jSuOu6XnuBUKqQSnWSJGpEyBGyTDuhwLx4m9f OZVmwKtBKxbAjl7EJ1XUM2V1m0iYpzLJNQtKQvu4L6Srb06PpS4N2INXWISV/XIVwu FJEbqcyyZHk8gWTacR2D+a8gXO3gV1QFG7UYSpBPSuL3panFFzQ3OlC4MXavabVCWI 4VwKcIH5rys1YJVIuEOWVBVoo5IRI2ew8NZf/9klFwZemUOGlUEPB26IyrvgQp7Rr5 10MEXBucYPfTS1HC9GjhDeKzC//b4DzuxKch5VQ2KgXl3R9Phr6wpciY+aaGemJyI1 dZemgE1cwp7yQ== From: "Masami Hiramatsu (Google)" To: Peter Zijlstra Cc: Petr Pavlu , tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, samitolvanen@google.com, x86@kernel.org, linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org, Masami Hiramatsu Subject: [RFC PATCH 0/2] x86: kprobes: Fix CFI_CLANG related issues Date: Mon, 10 Jul 2023 21:14:13 +0900 Message-Id: <168899125356.80889.17967397360941194229.stgit@devnote2> X-Mailer: git-send-email 2.25.1 User-Agent: StGit/0.19 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771037476909763761 X-GMAIL-MSGID: 1771037476909763761 Hi Peter, Here I tried to fix 2 issues discussed on the previous thread; https://lore.kernel.org/all/20230706113403.GI2833176@hirez.programming.kicks-ass.net/ - Prohibit probing on __cfi_* preamble symbols, which have the typeid. - Prohibit probing on compiler generated movl/addl which is used for detecting typeid on x86. I'm not sure how arm64 implemented, but it seems cfi_handler()@arch/arm64/kernel/traps.c just reads the registers for the typeid instead of decoding the instructions. I just build tested, since I could not boot the kernel with CFI_CLANG=y. Would anyone know something about this error? [ 0.141030] MMIO Stale Data: Unknown: No mitigations [ 0.153511] SMP alternatives: Using kCFI [ 0.164593] Freeing SMP alternatives memory: 36K [ 0.165053] Kernel panic - not syncing: stack-protector: Kernel stack is corrupted in: start_kernel+0x472/0x48b [ 0.166028] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 6.4.2-00002-g12b1b2fca8ef #126 [ 0.166028] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1.1 04/01/2014 [ 0.166028] Call Trace: [ 0.166028] [ 0.166028] dump_stack_lvl+0x6e/0xb0 [ 0.166028] panic+0x146/0x2f0 [ 0.166028] ? start_kernel+0x472/0x48b [ 0.166028] __stack_chk_fail+0x14/0x20 [ 0.166028] start_kernel+0x472/0x48b [ 0.166028] x86_64_start_reservations+0x24/0x30 [ 0.166028] x86_64_start_kernel+0xa6/0xbb [ 0.166028] secondary_startup_64_no_verify+0x106/0x11b [ 0.166028] [ 0.166028] ---[ end Kernel panic - not syncing: stack-protector: Kernel stack is corrupted in: start_kernel+0x472/0x48b ]--- Thank you, --- Masami Hiramatsu (Google) (2): kprobes: Prohibit probing on CFI preamble symbol x86/kprobes: Prohibit probing on compiler generated CFI checking code arch/x86/kernel/kprobes/core.c | 34 ++++++++++++++++++++++++++++++++++ kernel/kprobes.c | 17 ++++++++++++++++- 2 files changed, 50 insertions(+), 1 deletion(-) -- Masami Hiramatsu (Google)