Message ID | 20230703092336.268371-1-zegao@tencent.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp399585vqx; Mon, 3 Jul 2023 02:48:59 -0700 (PDT) X-Google-Smtp-Source: APBJJlHFuoLvk97SrJPtKq/HV4nltL8Xx0b1GfGpcqaiQ1Yz/xU0rAihj5ETI/sPrId9GwsR2B2T X-Received: by 2002:a17:90a:764f:b0:25b:88bc:bb6b with SMTP id s15-20020a17090a764f00b0025b88bcbb6bmr11407897pjl.2.1688377738887; Mon, 03 Jul 2023 02:48:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688377738; cv=none; d=google.com; s=arc-20160816; b=MrA8aKFoQmV41yUA6Y6G12/NnOmXWPpG3zA1JRAiJe0ArIK6orO+VuOr6ZWZ2e5lEl ubQPV62hsJjCQFELPOzc/cQ0ysjH32byOtHU/S2NFuMMWgE0BbRlm4rh4WVm2g00NCCk Vou5DWRB5KW0N3Rx2cshqJdbhuQ16ASdcuFFRZlUTI/aAbFcSAp0ZOB1LH67AlRA2yPE 8XF3TTDuovece82FwhR8sZajuEeU+EqNrJEiPyXuMxdyS8vvie1O9yznt2KkSHPiemnT h+YB93DyEzTajZ01sE9PH2lZ6T0ftA/TE9a1rWOEN4/2sn71T2crVGexcVo18Xqscq0l qUvA== 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=BJb09g/OfHvshX7XoMoqUcNq7uvwhDrwlKeW8QFnp6M=; fh=af5Vi36JybiNA2di92Nfb0Jz5qU6OmVIjFB//DkJP1Q=; b=O2mzJ6sb/1eWKYqSROAfGiq14qfbYC3irNOm9O0BD3w2AujhzXS8bTIUI829a2BvtN fQe456vPoybel9z9mt1c6NUPurxF6zxF5CJzXaFC44UPNf0FJoKh9877ar/fOaiA/VOv holblwG9oBJr42/FBxYUI87DEKLfgghuYHhgLQVTmo30R/NLtT1I7hLw3HbROgUWKDTB b2NzOqKPKZmAVdHsZ8ILnv4D/T+S7WRTiDKPt/3PKs+6+EAieEqk68INahQXyxTcEa4L KIinWpVgUS8+y6iAINIGfdMUv3kcu4GYSNcoBj7jb55XdAoG2mRA6IHiC8nSQ1uzfFDk Cq5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=KZOVsUZ9; 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 u18-20020a17090adb5200b00262d3e4b751si17215747pjx.159.2023.07.03.02.48.45; Mon, 03 Jul 2023 02:48:58 -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=KZOVsUZ9; 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 S230181AbjGCJX5 (ORCPT <rfc822;ivan.orlov0322@gmail.com> + 99 others); Mon, 3 Jul 2023 05:23:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229516AbjGCJX4 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 3 Jul 2023 05:23:56 -0400 Received: from mail-ot1-x329.google.com (mail-ot1-x329.google.com [IPv6:2607:f8b0:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFBCFCE; Mon, 3 Jul 2023 02:23:55 -0700 (PDT) Received: by mail-ot1-x329.google.com with SMTP id 46e09a7af769-6b5d57d7db9so3309675a34.3; Mon, 03 Jul 2023 02:23:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688376235; x=1690968235; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=BJb09g/OfHvshX7XoMoqUcNq7uvwhDrwlKeW8QFnp6M=; b=KZOVsUZ92vWvIGav63Q7cazYeOZBueY1L5SJXbcWtjgbJGrPTF/XqwTg1ZCxeT7s0D cW2dg/8C+f2vUK1Bgyl5Nc4igUUQlWaxe04FeBRvk47bNKiz3tm4TrWS+5LZJJJZa9No MIVcEnHlM6dg5C/TCe3avjst/ziKUV+pZxnLjfX3RPWnxCP4zZuB1dSOsa+taF9Rxr0l cB7rHBJ+cJeEqd/KXKJO7bk/ynQlHzkwMC+kePYX0UOTE+7aAaRs2O5fS12I8p6qb7Fj jV2Hz9skwOydu7tcGOHGQHojswrmbDQB2RoPsRVapDKhO0PUpsTtu7PWL5HzbftLHbl4 7v0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688376235; x=1690968235; 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=BJb09g/OfHvshX7XoMoqUcNq7uvwhDrwlKeW8QFnp6M=; b=i4R0d6bvy9S4jY1Z8VqLxgop1B79rS/yBXwjwA40Pee835ZL/AD2kME8/VsPC52dOS vwnMo6IndvN9ilX+ex0bBqKZZKvjDk2OouagB5/xrO0VZU9ybKJ6cgvKnHebxm4UrK49 0iZC5ePka9cJTuCtCEuoa4DG4hxFKUU8ry7G7e21p57cFHOwa+H6nYgNhQ+PYwXbqF7w az9B6sp0yQr4MrmJ5Ugwehar04ldRDTSPMDyAiqi2kpVX+ASGa3XDPcnYQzGV5ak6YeO fxwnY3djmUpG6Ap8sU1+Rt4gBZCpgkeI4s9/9W64WzUbirkZhdLxdVRDhOBA6U0xSpQF jC7g== X-Gm-Message-State: AC+VfDykEoJXHZxN6e1ftxSuwJe02LxjBMwGUWcvbr/2FSl3Ka9krkUY fgCmLLRkkv4KeBbPobuMP8I= X-Received: by 2002:a9d:6d81:0:b0:6b7:26aa:dbb3 with SMTP id x1-20020a9d6d81000000b006b726aadbb3mr7839695otp.38.1688376234977; Mon, 03 Jul 2023 02:23:54 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.15]) by smtp.googlemail.com with ESMTPSA id p15-20020a63e64f000000b0051b0e564963sm14633495pgj.49.2023.07.03.02.23.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 02:23:54 -0700 (PDT) From: Ze Gao <zegao2021@gmail.com> X-Google-Original-From: Ze Gao <zegao@tencent.com> To: Masami Hiramatsu <mhiramat@kernel.org> Cc: Steven Rostedt <rostedt@goodmis.org>, Ze Gao <zegao2021@gmail.com>, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, Ze Gao <zegao@tencent.com>, Yafang <laoar.shao@gmail.com> Subject: [PATCH v2] fprobe: add unlock to match a succeeded ftrace_test_recursion_trylock Date: Mon, 3 Jul 2023 17:23:36 +0800 Message-Id: <20230703092336.268371-1-zegao@tencent.com> X-Mailer: git-send-email 2.40.1 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?1770383983896936331?= X-GMAIL-MSGID: =?utf-8?q?1770392375932943870?= |
Series |
[v2] fprobe: add unlock to match a succeeded ftrace_test_recursion_trylock
|
|
Commit Message
Ze Gao
July 3, 2023, 9:23 a.m. UTC
Unlock ftrace recursion lock when fprobe_kprobe_handler() is failed
because of some running kprobe.
Fixes: 3cc4e2c5fbae ("fprobe: make fprobe_kprobe_handler recursion free")
Reported-by: Yafang <laoar.shao@gmail.com>
Closes: https://lore.kernel.org/linux-trace-kernel/CALOAHbC6UpfFOOibdDiC7xFc5YFUgZnk3MZ=3Ny6we=AcrNbew@mail.gmail.com/
Signed-off-by: Ze Gao <zegao@tencent.com>
---
kernel/trace/fprobe.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
Comments
On Mon, 3 Jul 2023 17:23:36 +0800 Ze Gao <zegao2021@gmail.com> wrote: > Unlock ftrace recursion lock when fprobe_kprobe_handler() is failed > because of some running kprobe. > Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Thanks! > Fixes: 3cc4e2c5fbae ("fprobe: make fprobe_kprobe_handler recursion free") > Reported-by: Yafang <laoar.shao@gmail.com> > Closes: https://lore.kernel.org/linux-trace-kernel/CALOAHbC6UpfFOOibdDiC7xFc5YFUgZnk3MZ=3Ny6we=AcrNbew@mail.gmail.com/ > Signed-off-by: Ze Gao <zegao@tencent.com> > --- > kernel/trace/fprobe.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/kernel/trace/fprobe.c b/kernel/trace/fprobe.c > index 18d36842faf5..93b3e361bb97 100644 > --- a/kernel/trace/fprobe.c > +++ b/kernel/trace/fprobe.c > @@ -102,12 +102,14 @@ static void fprobe_kprobe_handler(unsigned long ip, unsigned long parent_ip, > > if (unlikely(kprobe_running())) { > fp->nmissed++; > - return; > + goto recursion_unlock; > } > > kprobe_busy_begin(); > __fprobe_handler(ip, parent_ip, ops, fregs); > kprobe_busy_end(); > + > +recursion_unlock: > ftrace_test_recursion_unlock(bit); > } > > -- > 2.40.1 >
On Mon, Jul 3, 2023 at 5:23 PM Ze Gao <zegao2021@gmail.com> wrote: > > Unlock ftrace recursion lock when fprobe_kprobe_handler() is failed > because of some running kprobe. > > Fixes: 3cc4e2c5fbae ("fprobe: make fprobe_kprobe_handler recursion free") > Reported-by: Yafang <laoar.shao@gmail.com> > Closes: https://lore.kernel.org/linux-trace-kernel/CALOAHbC6UpfFOOibdDiC7xFc5YFUgZnk3MZ=3Ny6we=AcrNbew@mail.gmail.com/ > Signed-off-by: Ze Gao <zegao@tencent.com> Acked-by: Yafang Shao <laoar.shao@gmail.com> > --- > kernel/trace/fprobe.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/kernel/trace/fprobe.c b/kernel/trace/fprobe.c > index 18d36842faf5..93b3e361bb97 100644 > --- a/kernel/trace/fprobe.c > +++ b/kernel/trace/fprobe.c > @@ -102,12 +102,14 @@ static void fprobe_kprobe_handler(unsigned long ip, unsigned long parent_ip, > > if (unlikely(kprobe_running())) { > fp->nmissed++; > - return; > + goto recursion_unlock; > } > > kprobe_busy_begin(); > __fprobe_handler(ip, parent_ip, ops, fregs); > kprobe_busy_end(); > + > +recursion_unlock: > ftrace_test_recursion_unlock(bit); > } > > -- > 2.40.1 >
On Mon, 3 Jul 2023 17:23:36 +0800 Ze Gao <zegao2021@gmail.com> wrote: > Unlock ftrace recursion lock when fprobe_kprobe_handler() is failed > because of some running kprobe. > > Fixes: 3cc4e2c5fbae ("fprobe: make fprobe_kprobe_handler recursion free") > Reported-by: Yafang <laoar.shao@gmail.com> > Closes: https://lore.kernel.org/linux-trace-kernel/CALOAHbC6UpfFOOibdDiC7xFc5YFUgZnk3MZ=3Ny6we=AcrNbew@mail.gmail.com/ > Signed-off-by: Ze Gao <zegao@tencent.com> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> > --- > kernel/trace/fprobe.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/kernel/trace/fprobe.c b/kernel/trace/fprobe.c > index 18d36842faf5..93b3e361bb97 100644 > --- a/kernel/trace/fprobe.c > +++ b/kernel/trace/fprobe.c > @@ -102,12 +102,14 @@ static void fprobe_kprobe_handler(unsigned long ip, unsigned long parent_ip, > > if (unlikely(kprobe_running())) { Off topic for this patch, but Masami, what's the purpose of not calling the fprobe when a kprobe is running? Does that mean it has probed another kprobe? Probably could add a comment here to explain the issue. -- Steve > fp->nmissed++; > - return; > + goto recursion_unlock; > } > > kprobe_busy_begin(); > __fprobe_handler(ip, parent_ip, ops, fregs); > kprobe_busy_end(); > + > +recursion_unlock: > ftrace_test_recursion_unlock(bit); > } >
On Thu, 6 Jul 2023 12:09:16 -0400 Steven Rostedt <rostedt@goodmis.org> wrote: > On Mon, 3 Jul 2023 17:23:36 +0800 > Ze Gao <zegao2021@gmail.com> wrote: > > > Unlock ftrace recursion lock when fprobe_kprobe_handler() is failed > > because of some running kprobe. > > > > Fixes: 3cc4e2c5fbae ("fprobe: make fprobe_kprobe_handler recursion free") > > Reported-by: Yafang <laoar.shao@gmail.com> > > Closes: https://lore.kernel.org/linux-trace-kernel/CALOAHbC6UpfFOOibdDiC7xFc5YFUgZnk3MZ=3Ny6we=AcrNbew@mail.gmail.com/ > > Signed-off-by: Ze Gao <zegao@tencent.com> > > Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> > > > --- > > kernel/trace/fprobe.c | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/kernel/trace/fprobe.c b/kernel/trace/fprobe.c > > index 18d36842faf5..93b3e361bb97 100644 > > --- a/kernel/trace/fprobe.c > > +++ b/kernel/trace/fprobe.c > > @@ -102,12 +102,14 @@ static void fprobe_kprobe_handler(unsigned long ip, unsigned long parent_ip, > > > > if (unlikely(kprobe_running())) { > > Off topic for this patch, but Masami, what's the purpose of not calling the > fprobe when a kprobe is running? Does that mean it has probed another kprobe? This is for the user who is sharing their handler with kprobes (like eBPF), which may expect that the handler is not called recursively. (e.g. an interrupt happens while kprobe handler is running and that interrupt calls a function which is fprobed) > > Probably could add a comment here to explain the issue. OK, it is also documented in Documentation/trace/fprobe.rst, but it is better to comment in the code too. Thanks, > > -- Steve > > > > fp->nmissed++; > > - return; > > + goto recursion_unlock; > > } > > > > kprobe_busy_begin(); > > __fprobe_handler(ip, parent_ip, ops, fregs); > > kprobe_busy_end(); > > + > > +recursion_unlock: > > ftrace_test_recursion_unlock(bit); > > } > > >
diff --git a/kernel/trace/fprobe.c b/kernel/trace/fprobe.c index 18d36842faf5..93b3e361bb97 100644 --- a/kernel/trace/fprobe.c +++ b/kernel/trace/fprobe.c @@ -102,12 +102,14 @@ static void fprobe_kprobe_handler(unsigned long ip, unsigned long parent_ip, if (unlikely(kprobe_running())) { fp->nmissed++; - return; + goto recursion_unlock; } kprobe_busy_begin(); __fprobe_handler(ip, parent_ip, ops, fregs); kprobe_busy_end(); + +recursion_unlock: ftrace_test_recursion_unlock(bit); }