Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp131521rwn; Wed, 7 Sep 2022 21:52:39 -0700 (PDT) X-Google-Smtp-Source: AA6agR5Md8N5Wwi+y5Cru2azDKEheB4reWho22zeDI254yjKGkPn4p2t0/xLECNM/ODkHcdR2GRq X-Received: by 2002:a17:90a:4fe3:b0:1fd:b6f7:f5e3 with SMTP id q90-20020a17090a4fe300b001fdb6f7f5e3mr2152784pjh.169.1662612759111; Wed, 07 Sep 2022 21:52:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662612759; cv=none; d=google.com; s=arc-20160816; b=DzHiHorJKZTQ94eDjgQemGIoKWNac7JvNcIG8eRsCjEYEkKy7mH4y4mpZPln7S6vEY 37/qnvNY/qmd+uked40mwrtnkGL6B2XPYfR6YgqhTddw94YGhaB0mruadI1O9NeF86Ic eCWCQkfWkoyr+LI4B3C3nMjMINA/3V1fRyZADKWyeDHKUFtM3IU1/7oO9ldOhiS5WMVq UUIvOPq3/PuoTezXa3IDJQeZMcHZLEmKe912qzlqhe76v4aqR+WjTk6qhEHkOvknVOVh jShuz95vSbGCVhttFqQkv9c1lUu+VsRIHAntpBcK2YjYkN5Z4aU2qAFaAsUxy+gDUQGI wxeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=NB/5phlrQWjGIxi/Z08AmIeAlR9CZftGG5wn5NLNb24=; b=Qzi6YLc2CJwry/jTRTbsGLzalqnaDBSmwBmN90HV6deKx5+EHZLCBRMNFE9V6gg2Uz sS8KTedugK5ReCwerwpJ3YbO4s5bVZmw5xDS8PtGpcZk8IQxWO8YT5K1XgLnPObCV1gL hEV2fxWgbcXXykpb7kcbxF4Xt6omctEBV+qIlPyEl6Q2cXXLab1n45DIu5tX6nL0KwPG IopW3/LtrEcQszO0zLFw7qdRwlsbKAXR68OCt3VlCPSd9/CxUSxvd1yacBzGPi772ogs gKYUjrtJIPCBrTsU1YQbuPBK3ynGyewAVyQtFAavar7mD5se8IdSP323Z6FGpU5AvRVW CiHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=qSLlmPRe; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r38-20020a635166000000b0042b438dea0asi16981260pgl.655.2022.09.07.21.52.27; Wed, 07 Sep 2022 21:52:39 -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=20210112 header.b=qSLlmPRe; 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 S229526AbiIHEvx (ORCPT + 99 others); Thu, 8 Sep 2022 00:51:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229478AbiIHEvw (ORCPT ); Thu, 8 Sep 2022 00:51:52 -0400 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D3126DAF0 for ; Wed, 7 Sep 2022 21:51:51 -0700 (PDT) Received: by mail-ej1-x631.google.com with SMTP id r17so7909561ejy.9 for ; Wed, 07 Sep 2022 21:51:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date; bh=NB/5phlrQWjGIxi/Z08AmIeAlR9CZftGG5wn5NLNb24=; b=qSLlmPRe8Sp/NoNo+DkUaUz0j0GMO38uWcV9VEDKRJYLH0qoYjqaAogHlCe1659B6Z DDzb787iTqunoWP3Sb+Uifs3Xd2wwlmqkptSt0VCfoRr/6gICDOpfhW1uZ5kIEeJkRys 68dDdtmrO57orrefZ6IGRUTBQdpWHfXV0jMTg2AYg+230YpKaZqDGhQDXpRYn9TZvBta 4Lld+d3xXqBRPwEtMg3OkeEkgyKfXX2HDf0WNGH989jEfBeXCQVqmi6zFztttrmNgZbD Yy6UWmuYqxNYaFDEgBuYgo5jmOemeZADaAIZLsa7yG764+FxsIbdwml+F8VGAvPnSqi4 KUFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date; bh=NB/5phlrQWjGIxi/Z08AmIeAlR9CZftGG5wn5NLNb24=; b=PB1vMwjXcCEJ2KwqZNCzoIeL64Vif6lkNzc4bwXQpacHp46OOyaGdLEhAqe5fDteF4 Cpvy177WkuUyLvfJ86OEiimR45vXcjTPoanIKTNzWZ8ciy4HoH0V8rOTLOdQg6EFIikP +8VJcf3ZZf6V05+2JzlKkfvW/9RAJTSQIMsYIVpZ2sMS6mnfAX+T7NAEL6Xlut3t70wr 1CWtBj3RF4R4HDMljBV0KnuoY3/APOJg2FgWp9vNXE0meb2eucP2tQ+dzmyn/I8weMmD 5S49xcy8h+tCAVCGEEIzXY3XSSrhoXxlLUOaNLWXlEqInR1rCiJ8duK+y0E4rOT/gE+E kN5Q== X-Gm-Message-State: ACgBeo0FnmYSJVHYhu2elCWleCIVMoMsqATvXmYvXtIUCUZ9YQWUmYsm 2M7UyJrl1dRWUgvJBZIeZdPu+tiEPdZwSRW7ObmMcLh2h7FqCA== X-Received: by 2002:a17:906:8b81:b0:733:183b:988e with SMTP id nr1-20020a1709068b8100b00733183b988emr4613917ejc.457.1662612709532; Wed, 07 Sep 2022 21:51:49 -0700 (PDT) MIME-Version: 1.0 References: <20220902155820.34755-1-liq3ea@163.com> In-Reply-To: <20220902155820.34755-1-liq3ea@163.com> From: Li Qiang Date: Thu, 8 Sep 2022 12:51:11 +0800 Message-ID: Subject: Re: [PATCH] kprobe: reverse kp->flags when arm_kprobe failed To: Li Qiang Cc: naveen.n.rao@linux.ibm.com, anil.s.keshavamurthy@intel.com, davem@davemloft.net, mhiramat@kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 Kindly ping. Li Qiang =E4=BA=8E2022=E5=B9=B49=E6=9C=883=E6=97=A5=E5=91= =A8=E5=85=AD 00:00=E5=86=99=E9=81=93=EF=BC=9A > > In aggregate kprobe case, when arm_kprobe failed, > we need set the kp->flags with KPROBE_FLAG_DISABLED again. > If not, the 'kp' kprobe will been considered as enabled > but it actually not enabled. > > Signed-off-by: Li Qiang > --- > kernel/kprobes.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/kernel/kprobes.c b/kernel/kprobes.c > index 08350e35a..333454df5 100644 > --- a/kernel/kprobes.c > +++ b/kernel/kprobes.c > @@ -2424,8 +2424,11 @@ int enable_kprobe(struct kprobe *kp) > if (!kprobes_all_disarmed && kprobe_disabled(p)) { > p->flags &=3D ~KPROBE_FLAG_DISABLED; > ret =3D arm_kprobe(p); > - if (ret) > + if (ret) { > p->flags |=3D KPROBE_FLAG_DISABLED; > + if (p !=3D kp) > + kp->flags |=3D KPROBE_FLAG_DISABLED; > + } > } > out: > mutex_unlock(&kprobe_mutex); > -- > 2.25.1 >