Message ID | 20230516071830.8190-5-zegao@tencent.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp244438vqo; Tue, 16 May 2023 00:42:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6wBbVfSOw8SXW6Lvb0JAW9BxQZDUTSpKWt12VRT+2wyVEb3L3txP+2bDRpjREl8EJ0ng+W X-Received: by 2002:a17:902:a988:b0:1ac:aedf:2222 with SMTP id bh8-20020a170902a98800b001acaedf2222mr21983708plb.3.1684222943902; Tue, 16 May 2023 00:42:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684222943; cv=none; d=google.com; s=arc-20160816; b=ZvogwTAN+Fpo2BNJHegYNZcWtusgDfj+ILgUqD48TEviIgX1FlY9iv9T7HC8M9Qj7D wAC3O+0g0Dd00igkQYmvUX7jPFn5Hz0y/f35zs8cRUqhj8Rzh/AYboJitRfELMrBuLPY d2F9ZlrRqCk+jBjkBFGSDC8nuwHfMwea8wpzTULN36nW191DtBhUS/4hJrTJifDYO+fH PEzp4+ctBdZrMOROHXYHV9gne4d9Wucy6yqNNS0wl3ItvSOo07Wh2gmOsNaTG87gUXA7 7tZmmY7i/e9hwbEHBtXn7zZvbgNua4B0oLEdpgOJITioT9FvGOsrccl9fWDFzYJJMsCv APtg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6U/vkmAUFZZcdBk+KokFbNf1ZvkKNw6bCUwh7L5Br9E=; b=DrAQ2bgn85EYHwJmLml0FGspa1I2mIvjJEZ3qfSCGyN2hrBbnPl0OXzkYMd4j3CE5B yuU9eLgeTbK5NuM9CJKKqaDR/GN9CYhJ4QMUjPNJ68aEqSPbTWl2IQzL2PvjHJklJ9lR oqN4LZjFFnigPx0TPZ2s51R1jwa8OhFgUMLnZTq9X4kD9jnXdCYBFmmjEWKUoNlAdt5I Fk+WEGe2p7iIyk7iP+wOt0l5lZ8Wz+EZ2ByvTU/Arwi2zFO/yeSGXk5RX+zs3TnEgcqg UZ7MDQBHo+zTIzaEcKpLhO5/XadQF0YfoVAdWBgOScE1RjPLuZSRQbr96LIZRw+6gA/E Vg2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=MFxu44NH; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 5-20020a170902ee4500b001ac6a9353ffsi17153558plo.116.2023.05.16.00.42.09; Tue, 16 May 2023 00:42:23 -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=@gmail.com header.s=20221208 header.b=MFxu44NH; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231241AbjEPHUO (ORCPT <rfc822;peekingduck44@gmail.com> + 99 others); Tue, 16 May 2023 03:20:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231300AbjEPHTn (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 16 May 2023 03:19:43 -0400 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A85254C0A; Tue, 16 May 2023 00:19:36 -0700 (PDT) Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-643b7b8f8ceso7937981b3a.1; Tue, 16 May 2023 00:19:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684221576; x=1686813576; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6U/vkmAUFZZcdBk+KokFbNf1ZvkKNw6bCUwh7L5Br9E=; b=MFxu44NHbkQCaNnciSPrfna7rqyLC2dxpiPT8iIxN4YMSmvNT5WNxmBHJuu8yUW1J5 EynI7VMJwAZLG3DgUCgj7G+xrxpokr5IS3ZRrGAJGBkw+eW2iHCYr1OVfGHC2+2dVCeC 7t2aGksNm18G+S2p1Kymzqk15eMpkxaiyb0tE34Y+/zfabMobsqav4iB5A1iXlLrKhDK lEZMaL3xbrp8jePUEgNVtpLBTg/oRqWZojM+xWwnnz4TUFn3Lq/fkYXul2S9MFpzPdEN BPO4ZOcnazHWeen45gEA8Cdk2tUC2dGTEKbnZkzL+XRjjJnaFOo+R/RMKJjlV4ho0L/6 Nv4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684221576; x=1686813576; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6U/vkmAUFZZcdBk+KokFbNf1ZvkKNw6bCUwh7L5Br9E=; b=HyIsLtuvUWgtq0+8nHvr71xltk9UpBFwBbCg+KcEMKFMJ+6VmJumYW4ambOnlwOWUm 86PljMJjXM5ispv66pdSn9ASMpd+6RtU2K86Cu68HmAOUxQj5FYRdx4TOOTVTGnUbCvM yMiu3Z+V1vIAfI813iLFqiKI+K9UjzFbgnlVZpImIhX3R9FIC7Ebd8K/4IC+o3KQJQds jnPRHBFu6ZyNOVt/bInLA6Hps+mFWMfkD/P3tcFf0jit0jhJzLY4MFqNxm9ghZB2ZyGE B5y0vhu5+fhihcRDTB251fsyzpcKFD3t3iw8aF59LYdOWQSUBC1EkP74jp3ecYPZIa9P UcVQ== X-Gm-Message-State: AC+VfDxwi9529cQCRBqw6WEeJSNFidVBigeAd7OdkRu+A0g9XfTBmPeb tAmyE2GSGzjZ8rvjviIELqI= X-Received: by 2002:aa7:88c8:0:b0:64a:2dd6:4f18 with SMTP id k8-20020aa788c8000000b0064a2dd64f18mr23142160pff.13.1684221575773; Tue, 16 May 2023 00:19:35 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.15]) by smtp.googlemail.com with ESMTPSA id 17-20020aa79251000000b006468222af91sm12849830pfp.48.2023.05.16.00.19.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 May 2023 00:19:35 -0700 (PDT) From: Ze Gao <zegao2021@gmail.com> X-Google-Original-From: Ze Gao <zegao@tencent.com> To: Steven Rostedt <rostedt@goodmis.org>, Masami Hiramatsu <mhiramat@kernel.org> Cc: Albert Ou <aou@eecs.berkeley.edu>, Alexander Gordeev <agordeev@linux.ibm.com>, Alexei Starovoitov <ast@kernel.org>, Borislav Petkov <bp@alien8.de>, Christian Borntraeger <borntraeger@linux.ibm.com>, Dave Hansen <dave.hansen@linux.intel.com>, Heiko Carstens <hca@linux.ibm.com>, "H. Peter Anvin" <hpa@zytor.com>, Ingo Molnar <mingo@redhat.com>, Palmer Dabbelt <palmer@dabbelt.com>, Paul Walmsley <paul.walmsley@sifive.com>, Sven Schnelle <svens@linux.ibm.com>, Thomas Gleixner <tglx@linutronix.de>, Vasily Gorbik <gor@linux.ibm.com>, x86@kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-trace-kernel@vger.kernel.org, bpf@vger.kernel.org, Conor Dooley <conor@kernel.org>, Jiri Olsa <jolsa@kernel.org>, Yonghong Song <yhs@fb.com>, Ze Gao <zegao@tencent.com> Subject: [PATCH v2 4/4] rehook, fprobe: do not trace rethook related functions Date: Tue, 16 May 2023 15:18:30 +0800 Message-Id: <20230516071830.8190-5-zegao@tencent.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230516071830.8190-1-zegao@tencent.com> References: <20230516071830.8190-1-zegao@tencent.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766035757475369535?= X-GMAIL-MSGID: =?utf-8?q?1766035757475369535?= |
Series |
Make fprobe + rethook immune to recursion
|
|
Commit Message
Ze Gao
May 16, 2023, 7:18 a.m. UTC
These functions are already marked as NOKPROBE to prevent recursion and
we have the same reason to blacklist them if rethook is used with fprobe,
since they are beyond the recursion-free region ftrace can guard.
Signed-off-by: Ze Gao <zegao@tencent.com>
---
arch/riscv/kernel/probes/Makefile | 2 ++
arch/s390/kernel/Makefile | 1 +
arch/x86/kernel/Makefile | 1 +
3 files changed, 4 insertions(+)
Comments
On Tue, 16 May 2023 15:18:30 +0800 Ze Gao <zegao2021@gmail.com> wrote: > CFLAGS_REMOVE_early.o = $(CC_FLAGS_FTRACE) > +CFLAGS_REMOVE_rethook.o = $(CC_FLAGS_FTRACE) > > endif > > diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile > index dd61752f4c96..4070a01c11b7 100644 > --- a/arch/x86/kernel/Makefile > +++ b/arch/x86/kernel/Makefile > @@ -17,6 +17,7 @@ CFLAGS_REMOVE_ftrace.o = -pg > CFLAGS_REMOVE_early_printk.o = -pg > CFLAGS_REMOVE_head64.o = -pg > CFLAGS_REMOVE_sev.o = -pg > +CFLAGS_REMOVE_rethook.o = -pg Unrelated to this patch, but someday we need to change the -pg above to $(CC_FLAGS_FTRACE). -- Steve > endif > > KASAN_SANITIZE_head$(BITS).o := n > --
On Tue, 16 May 2023 15:18:30 +0800 Ze Gao <zegao2021@gmail.com> wrote: > These functions are already marked as NOKPROBE to prevent recursion and > we have the same reason to blacklist them if rethook is used with fprobe, > since they are beyond the recursion-free region ftrace can guard. > > Signed-off-by: Ze Gao <zegao@tencent.com> Looks good to me. Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Thank you! > --- > arch/riscv/kernel/probes/Makefile | 2 ++ > arch/s390/kernel/Makefile | 1 + > arch/x86/kernel/Makefile | 1 + > 3 files changed, 4 insertions(+) > > diff --git a/arch/riscv/kernel/probes/Makefile b/arch/riscv/kernel/probes/Makefile > index c40139e9ca47..8265ff497977 100644 > --- a/arch/riscv/kernel/probes/Makefile > +++ b/arch/riscv/kernel/probes/Makefile > @@ -4,3 +4,5 @@ obj-$(CONFIG_RETHOOK) += rethook.o rethook_trampoline.o > obj-$(CONFIG_KPROBES_ON_FTRACE) += ftrace.o > obj-$(CONFIG_UPROBES) += uprobes.o decode-insn.o simulate-insn.o > CFLAGS_REMOVE_simulate-insn.o = $(CC_FLAGS_FTRACE) > +CFLAGS_REMOVE_rethook.o = $(CC_FLAGS_FTRACE) > +CFLAGS_REMOVE_rethook_trampoline.o = $(CC_FLAGS_FTRACE) > diff --git a/arch/s390/kernel/Makefile b/arch/s390/kernel/Makefile > index 8983837b3565..6b2a051e1f8a 100644 > --- a/arch/s390/kernel/Makefile > +++ b/arch/s390/kernel/Makefile > @@ -10,6 +10,7 @@ CFLAGS_REMOVE_ftrace.o = $(CC_FLAGS_FTRACE) > > # Do not trace early setup code > CFLAGS_REMOVE_early.o = $(CC_FLAGS_FTRACE) > +CFLAGS_REMOVE_rethook.o = $(CC_FLAGS_FTRACE) > > endif > > diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile > index dd61752f4c96..4070a01c11b7 100644 > --- a/arch/x86/kernel/Makefile > +++ b/arch/x86/kernel/Makefile > @@ -17,6 +17,7 @@ CFLAGS_REMOVE_ftrace.o = -pg > CFLAGS_REMOVE_early_printk.o = -pg > CFLAGS_REMOVE_head64.o = -pg > CFLAGS_REMOVE_sev.o = -pg > +CFLAGS_REMOVE_rethook.o = -pg > endif > > KASAN_SANITIZE_head$(BITS).o := n > -- > 2.40.1 >
Got it! Thank you, Steevn. Maybe I can give it a try later :) Regards, Ze On Tue, May 16, 2023 at 10:20 PM Steven Rostedt <rostedt@goodmis.org> wrote: > > On Tue, 16 May 2023 15:18:30 +0800 > Ze Gao <zegao2021@gmail.com> wrote: > > > CFLAGS_REMOVE_early.o = $(CC_FLAGS_FTRACE) > > +CFLAGS_REMOVE_rethook.o = $(CC_FLAGS_FTRACE) > > > > endif > > > > diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile > > index dd61752f4c96..4070a01c11b7 100644 > > --- a/arch/x86/kernel/Makefile > > +++ b/arch/x86/kernel/Makefile > > @@ -17,6 +17,7 @@ CFLAGS_REMOVE_ftrace.o = -pg > > CFLAGS_REMOVE_early_printk.o = -pg > > CFLAGS_REMOVE_head64.o = -pg > > CFLAGS_REMOVE_sev.o = -pg > > +CFLAGS_REMOVE_rethook.o = -pg > > Unrelated to this patch, but someday we need to change the -pg above to > $(CC_FLAGS_FTRACE). > > -- Steve > > > > endif > > > > KASAN_SANITIZE_head$(BITS).o := n > > --
diff --git a/arch/riscv/kernel/probes/Makefile b/arch/riscv/kernel/probes/Makefile index c40139e9ca47..8265ff497977 100644 --- a/arch/riscv/kernel/probes/Makefile +++ b/arch/riscv/kernel/probes/Makefile @@ -4,3 +4,5 @@ obj-$(CONFIG_RETHOOK) += rethook.o rethook_trampoline.o obj-$(CONFIG_KPROBES_ON_FTRACE) += ftrace.o obj-$(CONFIG_UPROBES) += uprobes.o decode-insn.o simulate-insn.o CFLAGS_REMOVE_simulate-insn.o = $(CC_FLAGS_FTRACE) +CFLAGS_REMOVE_rethook.o = $(CC_FLAGS_FTRACE) +CFLAGS_REMOVE_rethook_trampoline.o = $(CC_FLAGS_FTRACE) diff --git a/arch/s390/kernel/Makefile b/arch/s390/kernel/Makefile index 8983837b3565..6b2a051e1f8a 100644 --- a/arch/s390/kernel/Makefile +++ b/arch/s390/kernel/Makefile @@ -10,6 +10,7 @@ CFLAGS_REMOVE_ftrace.o = $(CC_FLAGS_FTRACE) # Do not trace early setup code CFLAGS_REMOVE_early.o = $(CC_FLAGS_FTRACE) +CFLAGS_REMOVE_rethook.o = $(CC_FLAGS_FTRACE) endif diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile index dd61752f4c96..4070a01c11b7 100644 --- a/arch/x86/kernel/Makefile +++ b/arch/x86/kernel/Makefile @@ -17,6 +17,7 @@ CFLAGS_REMOVE_ftrace.o = -pg CFLAGS_REMOVE_early_printk.o = -pg CFLAGS_REMOVE_head64.o = -pg CFLAGS_REMOVE_sev.o = -pg +CFLAGS_REMOVE_rethook.o = -pg endif KASAN_SANITIZE_head$(BITS).o := n