From patchwork Sat May 13 08:23:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ze Gao X-Patchwork-Id: 93486 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp5649318vqo; Sat, 13 May 2023 01:53:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4t25TsILJ5CfsYVsrm6isrOr3y3Q/hpwMl3UNcbTTjBqK1I/6YIYhT2DWs42ELcth4d7hr X-Received: by 2002:a05:6a20:9187:b0:104:950f:fe15 with SMTP id v7-20020a056a20918700b00104950ffe15mr6077215pzd.55.1683967980117; Sat, 13 May 2023 01:53:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683967980; cv=none; d=google.com; s=arc-20160816; b=eCpmNgZ+w9SIIKBx1AbT4NEznldrHimcbj5fr1wQpUx2jBhaypIBk9rGgOb+nJ5TDV QxmicvoAPFsrV2IAeLWNZV8F9kuFuJLcHvOhzgH64OO1ZcSK6flzAAfVll1IkMY6BwSQ 9ae0ofveG6KnxhtuJ0nRrdV2dK7fMRru5uVWkIV3S8NrbirFlcl1EEdRtFYMcW+O1m32 olTZmUm5vOQ5mGF3GVRxt+deM2RpXfFXtu8nWxcBExG5wOU6XRCMz0h3AmiAn6vleRQw JnrvASo91A7gCDnuDuHIKIbIu08YsHCnnNQ8yRT5Q9yC9skNP031Rg/GwAtYHpECLXsx lP/g== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=HfO0FQe7LL8tpwg2PdMURaHU+jV7nrgpfKB4jccXJDQ=; b=G9RQxRQDDh1FsC1ieL2pYhYcgx2UqXbkLxuR4Hd7TBlNjNKQRPaMh0RxJ1pEDZ09sg ZLEg6Ef8vI+ZZpSlGmrToxEAbw64vGa1o0gPZb5+rGOnCWcnUkCFDtKeiEjOp88y1xdb CIY/6PhA6s3v/j9LYfdxEEPgemPirxM04gvojAdNpH5WolwDMysOtWLya1K5J9nD61/T RjOGv8EkrkDtSvwaXU31F0re4hrkfWFc2AxuCQsEp7pRhf8Jy7uPHzXG51iMdJMvv8ef pBc363nNZQ5NAUZIA6n72iC425r+aSowXxEd6LsNmpwvOu2VxUAzTk6cdxcKyjQ2aW/w ZHkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=ZAJFRRMR; 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 j73-20020a638b4c000000b00528c170e4f3si11980076pge.544.2023.05.13.01.52.45; Sat, 13 May 2023 01:53:00 -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=ZAJFRRMR; 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 S231196AbjEMIYK (ORCPT + 99 others); Sat, 13 May 2023 04:24:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229463AbjEMIYI (ORCPT ); Sat, 13 May 2023 04:24:08 -0400 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 358552D78; Sat, 13 May 2023 01:24:01 -0700 (PDT) Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-643b7b8f8ceso5978327b3a.1; Sat, 13 May 2023 01:24:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683966241; x=1686558241; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=HfO0FQe7LL8tpwg2PdMURaHU+jV7nrgpfKB4jccXJDQ=; b=ZAJFRRMR9pPP9o8YhqxKzCA9OjaxaDllBGMYW0Qepx86qrG33daV5b3vhW5/QwNj7G zubAiIlXTdHGzUTfo2pLtGj0s2Ca0qE+m34cFf+/3/zU2H0OPS8igLSELCbTGw/5UaZo xL3a2c4ODXw0KzRRSHNkzY/quP+MapWc0cCS1VurCvNpwxK6WzQx4ztxNgHI2iBRbgtg PHp4meI7XOYNPuRDf8naCAj2p21ni46WiBukE67MKoKhF7eAX0th5qCQogN7oWK8nfd5 DjL9r7eyZ0KaETXLJqG3oQmXrR8I9REiNxEUksYuN6uX/1KBc/lTwkQmJP8Js3/l0A0v pmXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683966241; x=1686558241; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=HfO0FQe7LL8tpwg2PdMURaHU+jV7nrgpfKB4jccXJDQ=; b=Y8l9pzBCi0phpetBnsXcjKa4eGA2Pw3q290h/bgCZVOYHTFhjRdbKNa2iMVChzCIFL 4tm+CPyl9oCakYfhlFPZ4a0wQ+2uVdzVsvsMCWbhCJ18js2moCHNKvfqluhZaKV/Q2jY Q0X+A+lp9mRjy7m+XuqG64ttxC7/qnJvJCpJfAkhIAYTN+TqTsXu2kiy2ZuHtA73VOj1 bI3dDjo5Uq8LonB+UUXeERgr7UpuTljHNwKObUHFAwml9viHP7y767GcKxscsTQVA+sf gFoYQAsJf7T1T+ivvSQ+U8LLNRIeH3IGz+eBmD4TLphTEG4bEL2D3ZfFCct2e0PsCV3l Gfqg== X-Gm-Message-State: AC+VfDyAxMN4kw4plqZJx5MQxAUT5c8veKiF0KGiBWeSvPV+OhXDBa7s oFZZIcIe2QQHSiEy2+bH2XE= X-Received: by 2002:a05:6a00:1415:b0:641:558:8e2e with SMTP id l21-20020a056a00141500b0064105588e2emr33219775pfu.15.1683966241160; Sat, 13 May 2023 01:24:01 -0700 (PDT) Received: from localhost.localdomain ([43.132.98.116]) by smtp.googlemail.com with ESMTPSA id g4-20020a62e304000000b00627ed4e23e0sm8225021pfh.101.2023.05.13.01.23.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 May 2023 01:24:00 -0700 (PDT) From: Ze Gao X-Google-Original-From: Ze Gao To: Steven Rostedt , Masami Hiramatsu Cc: Ze Gao , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Subject: [PATCH] rethook: use preempt_{disable, enable}_notrace in rethook_trampoline_handler Date: Sat, 13 May 2023 16:23:46 +0800 Message-Id: <20230513082346.375928-1-zegao@tencent.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765768362969674540?= X-GMAIL-MSGID: =?utf-8?q?1765768408883854232?= This patch replace preempt_{disable, enable} with its corresponding notrace version in rethook_trampoline_handler so no worries about stack recursion or overflow introduced by preempt_count_{add, sub} under fprobe + rethook context. Signed-off-by: Ze Gao --- kernel/trace/rethook.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/trace/rethook.c b/kernel/trace/rethook.c index 32c3dfdb4d6a..60f6cb2b486b 100644 --- a/kernel/trace/rethook.c +++ b/kernel/trace/rethook.c @@ -288,7 +288,7 @@ unsigned long rethook_trampoline_handler(struct pt_regs *regs, * These loops must be protected from rethook_free_rcu() because those * are accessing 'rhn->rethook'. */ - preempt_disable(); + preempt_disable_notrace(); /* * Run the handler on the shadow stack. Do not unlink the list here because @@ -321,7 +321,7 @@ unsigned long rethook_trampoline_handler(struct pt_regs *regs, first = first->next; rethook_recycle(rhn); } - preempt_enable(); + preempt_enable_notrace(); return correct_ret_addr; }