From patchwork Mon May 15 03:13:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ze Gao X-Patchwork-Id: 93833 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp6632114vqo; Sun, 14 May 2023 20:18:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6xpUubzKelDG641vtfzfHdMMzC2ecTX6rL+VqWDCKw670ann/srFQ6pRnl44Kgnt6XMVT0 X-Received: by 2002:a05:6a00:1681:b0:639:c88b:c3e0 with SMTP id k1-20020a056a00168100b00639c88bc3e0mr44987542pfc.22.1684120681135; Sun, 14 May 2023 20:18:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684120681; cv=none; d=google.com; s=arc-20160816; b=Ryhhfq5thFoFUEYRee2CKp84dnwaBIW/THgZ/i6t4S7wqpsFxO8ZxgoCmFY4WziKqx iBCWt2lOB+H2VeFy5nZ5ARi6FJlPTUYxkSxLi1hCb/Gl/xRYFPwufD2uuN6vDySgyRlE dpfVJAumwfhxbSKWZQAz5f5ngo2M5AvPaSAgKNINo8aY6z/UCuLhsSuHVPDFVEXl3+Yz b9hJYXPQQyFnvW2vVGfGk4gyRDk4og6RZKRca4oCJFAQS5v0dqzP80PxiWRla8bzT+wK AMAcly+sAjGwa+DLggyx2CTkvvKJ4YVHS7zLvHVq/959VpLGHHqJKOSVTHhRazeYPcHj 2zrQ== 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=HfO0FQe7LL8tpwg2PdMURaHU+jV7nrgpfKB4jccXJDQ=; b=SJetWWRjKiyik+RxFH1d/UheWmEAnezRnzpiBTSKmdKU59zcWASsG/GH/lVfiT2arY 03M8kFOHOX/vCBn38VbyB+uv8y054EeO5rxTSVu0yMGmblp2w7Ih9DJYqKQX/GsJhF3K 5YZqawaR65DbctJanFgbX7tL0zJWKeP9BduqFMCg53i+hK4Eov0qmwV1jz1BdejBDXFx A1/2hcWBSn9//MHTOetD3vz8wn6lY2zlsI1tsjvMgMIcVVZvkbSlgo97N8fkrGbyieKz Ieh+wBB3K4i4ZgugzgoR5n3iDQeagpS1cL07oOQmffuZlO3WgpstG/wVFA64eqbKYe/E MZ1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=AriHxAGw; 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 i6-20020a056a00004600b00643bac6f81esi16326874pfk.16.2023.05.14.20.17.46; Sun, 14 May 2023 20:18:01 -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=AriHxAGw; 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 S235564AbjEODNq (ORCPT + 99 others); Sun, 14 May 2023 23:13:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229701AbjEODNn (ORCPT ); Sun, 14 May 2023 23:13:43 -0400 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28E3B10F8; Sun, 14 May 2023 20:13:42 -0700 (PDT) Received: by mail-pg1-x52c.google.com with SMTP id 41be03b00d2f7-52160f75920so8354957a12.2; Sun, 14 May 2023 20:13:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684120421; x=1686712421; 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=HfO0FQe7LL8tpwg2PdMURaHU+jV7nrgpfKB4jccXJDQ=; b=AriHxAGwHUCx9Thh3FsC2fX+7ryTYGbNbpqTWfPEJAGknhGeexqWbFK1+boA7T7l2i cvZsPOsPIDZabmoL1UYaQ+W0PbauJN8DEj9jsFE1MONzFGabg2F0r698TyuuiWsH50oP WNj1umDfsuCg8kJggoxamsUhZs+OZeDDFlixPn8g1MsXajPaIUXOBnIqcNt2Mm8I/+uO laHDPUW5/MBzYBYJarVwqxAoi6OOwB5Zw0ic+dsbDsopHMdUSJJd1/BaMGf/WU2MJrLG hSjR4vV3n0yt9gYg/ctMJrrFHZGySk92o/C+2L1l6BXChx8u64b+cCyyN4cYN2OMU/2i V6tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684120421; x=1686712421; 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=HfO0FQe7LL8tpwg2PdMURaHU+jV7nrgpfKB4jccXJDQ=; b=TURNCvXJlwtci6WNG/Yc5w/HZs2jo5stgqkBGTAhDwmfWctkltqwLN/lgh4/ajzLwB wmMsmMP3RoyMofXnfXoXGtUyuMZDgL+1LggNAzpETQCBehDOQWQ/DSbMYYLwWJi/dg1W sTB1Z4xy8SrtFW0I1eD03FWe1xypv2OJ7hnE0CAjdgIUiSLrtosGP8gvf6BCC3KZZlod NuCg3WhBjomfCw77IQSNiTc8a5WMAO3pPDKXlMKA4SzgSzNCktmFveDHnCc5mEowpKEw 18MHP2VE1DWaU5hCmWJx6clViXpgbC6N0wop4SCNbsz170p8vb9U4CGA1WikHwwuI1eY E2sg== X-Gm-Message-State: AC+VfDzswF2ciQESfRUy8HROF/Qd5oCakPz6AU2iX1DBxOGD3OXElmV7 S1lEQI6mVElU6zXaeYO7160= X-Received: by 2002:a05:6a20:3d1a:b0:104:d028:ffe8 with SMTP id y26-20020a056a203d1a00b00104d028ffe8mr10782506pzi.45.1684120421467; Sun, 14 May 2023 20:13:41 -0700 (PDT) Received: from localhost.localdomain ([43.132.98.42]) by smtp.googlemail.com with ESMTPSA id o4-20020a17090a744400b00252b3328ad8sm4943577pjk.0.2023.05.14.20.13.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 May 2023 20:13:41 -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 1/4] rethook: use preempt_{disable, enable}_notrace in rethook_trampoline_handler Date: Mon, 15 May 2023 11:13:10 +0800 Message-Id: <20230515031314.7836-2-zegao@tencent.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230515031314.7836-1-zegao@tencent.com> References: <20230515031314.7836-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?1765928527487585819?= X-GMAIL-MSGID: =?utf-8?q?1765928527487585819?= 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; }