From patchwork Wed May 17 03:45:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ze Gao X-Patchwork-Id: 95035 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp858267vqo; Tue, 16 May 2023 20:54:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7GUwsWf0vHwctvE+ozziL9mvXl2S3xZkF+p8hb/Q14XWBMMrX6qaxr3L4H5MGoZ9+kOOqf X-Received: by 2002:a17:902:b946:b0:1aa:f6f2:46b7 with SMTP id h6-20020a170902b94600b001aaf6f246b7mr36836543pls.34.1684295667178; Tue, 16 May 2023 20:54:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684295667; cv=none; d=google.com; s=arc-20160816; b=bcq9l6KKatRUkGiOsbpa3wZ0/ddwx+0BMk12+9XnIqzczWxsZXKlNIapwh/Tjy3hCg cnfKX7BQp3jGCA9PiBTfUPotnh7TqcLI9TuEet97+m64WSqbmXJmqTgGJmnYs499DUty ZE8RPE3sYkjsgZ+ZYUu0qE5HijkopnppR2RHm0pdnPkxihMoQMtJfRSNOmsIcvas6H+D T0mEYRET744BXt9tMOjk3BahRBeyQWi5m9X7AfOSiQabYUIdngA6DtJ/vO41eBQq1rxX ckFWH4Y1vLB3M49AkQUoCCa34mD/z2B0/mXQfSfxfic7waQ5I/yNd8B5KFOhMiLwR00L HT8g== 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=2uMSZdlVzbxeM11qsVcr0sdcteuxEXHjRqP1IVvopNU=; b=NVdEtv1k5MC2jV0+xb/dkZp6a/8RFNKCgEtzcForZWfDjdP2yx5V44rbsIMOIQm/FT Ot5aq6duue8ytgYgPjs9AgrKm9IGcmPjB1wXSGLhhU8PbwE8EkgvnYVJhh9WJ3WNqFfk UzQ4aNOEDncR9qKHoed1Jx2lpJN3x1NsocwLaRcV9JniuxRIHdFg5j9zB6wqRZ1eAQz1 DL87dcgBeZOHDzkWbIquQtR6e8b5IByndbQzt0x9P+73y/iY0D6ttHu7sm9f+SVqg1Ya exa39C53pbP8/y08uQ/IuWb6lgNarV8oqH80RnPJgolZuqwm22Ty+COqV5MVvhLfN+HD 5JjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=NaiABcWC; 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 r9-20020a170902be0900b001aaf7a9d7aasi18792187pls.126.2023.05.16.20.54.13; Tue, 16 May 2023 20:54:27 -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=NaiABcWC; 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 S232548AbjEQDpc (ORCPT + 99 others); Tue, 16 May 2023 23:45:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232532AbjEQDp1 (ORCPT ); Tue, 16 May 2023 23:45:27 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9920430E8; Tue, 16 May 2023 20:45:26 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1ae454844edso2995535ad.1; Tue, 16 May 2023 20:45:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684295126; x=1686887126; 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=2uMSZdlVzbxeM11qsVcr0sdcteuxEXHjRqP1IVvopNU=; b=NaiABcWCkvK2DCfRgsRBZ/BumHoPpPMfbt+vLGTc6mJZBbSsqJ0Qfs1mqA7kr8myUo s7kSI/PYlCeuqR4ZbKL9S1vhuAY+ZO32SdCRVFiTtC3/xKk1CUQDuNXIMAh3wyt3/G64 rQWz6cmVHkWp9jnZhxAKMfX2GMLup8u+aKqErt2ZO3RuFuVlpDjKXH4tL2d1zxJYDeRP ECA8Kbi6BULm0yKVVaAKuR3xEaYyCpEWicvFRD1kFGuO1KsnamVYvfWDtne7SmUss8Bi uvPjR3V/VweHcFPDZkGddzvzmyH6a+8PLhXzZqGWD0Fq589AY6UlUaV1QRpGrKEEYisb 4R5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684295126; x=1686887126; 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=2uMSZdlVzbxeM11qsVcr0sdcteuxEXHjRqP1IVvopNU=; b=J4BMx1ya4BmdmL60ryHoZmFvThJnrJXVEsA4vdF+wvjX71fsKpl64LeKeqnxFlOyVq QEUQOs0rJDItpbkNRvO+3x0+tWwkz/AQwIQDnRGtJ9ui79RLcyIG6vN20E7FiaN1sP7T 5SrOkl+Zz7d6If6NC1Vbnc4kBMmQF27lwNUtHit1JJL187YnhZWUoKwF1Edz/yeos7P6 myzJKHEae5nFuj9f7REe7tTz9POnjw031fjJjoj11L+O2oaAuetDEnWmy9jV4U8O8g6u ACC0fT7y76A52gcmAdI5MZCnQoRu5Cgcszo9AXpOxjkUOWURQ1QPXI4MsILLiSqPV7rn gfAg== X-Gm-Message-State: AC+VfDyjoN6lbjda/o5PRHkG9YQOxIoPx17PieAjPcXwOqyS+OrOcx1u fVN1woXYoNTgCG1Q9EEA3kA= X-Received: by 2002:a17:903:32c5:b0:1aa:e5cd:647a with SMTP id i5-20020a17090332c500b001aae5cd647amr54727835plr.23.1684295126019; Tue, 16 May 2023 20:45:26 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.83]) by smtp.googlemail.com with ESMTPSA id t2-20020a170902e84200b001a19196af48sm16336746plg.64.2023.05.16.20.45.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 May 2023 20:45:25 -0700 (PDT) From: Ze Gao X-Google-Original-From: Ze Gao To: Steven Rostedt , Masami Hiramatsu Cc: Albert Ou , Alexander Gordeev , Alexei Starovoitov , Borislav Petkov , Christian Borntraeger , Dave Hansen , Heiko Carstens , "H. Peter Anvin" , Ingo Molnar , Palmer Dabbelt , Paul Walmsley , Sven Schnelle , Thomas Gleixner , Vasily Gorbik , x86@kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-trace-kernel@vger.kernel.org, Conor Dooley , Jiri Olsa , Yonghong Song , Ze Gao , stable@vger.kernel.org Subject: [PATCH v3 1/4] rethook: use preempt_{disable, enable}_notrace in rethook_trampoline_handler Date: Wed, 17 May 2023 11:45:06 +0800 Message-Id: <20230517034510.15639-2-zegao@tencent.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230517034510.15639-1-zegao@tencent.com> References: <20230517034510.15639-1-zegao@tencent.com> 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?1766112013254641015?= X-GMAIL-MSGID: =?utf-8?q?1766112013254641015?= This patch replaces 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. Fixes: 54ecbe6f1ed5 ("rethook: Add a generic return hook") Signed-off-by: Ze Gao Acked-by: Masami Hiramatsu (Google) Cc: Link: https://lore.kernel.org/linux-trace-kernel/20230516071830.8190-2-zegao@tencent.com --- 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; }