Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp52244rwb; Fri, 2 Sep 2022 10:03:44 -0700 (PDT) X-Google-Smtp-Source: AA6agR7ZgUmGuQlHi5N5HS6nGZ0FKGuhQn32xFH3pHkv7YNlpJesHU7qkTVW2+QxjJSri0Y7IAz+ X-Received: by 2002:a05:6a00:27a0:b0:52f:8766:82ec with SMTP id bd32-20020a056a0027a000b0052f876682ecmr37599832pfb.17.1662138223938; Fri, 02 Sep 2022 10:03:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662138223; cv=none; d=google.com; s=arc-20160816; b=cX8wcScYd5dn+0AVjYCsp63CEhLcW4e1Uc46hWOidnWK3kNICgbgJZdT20nTtHwGP0 EODTvyhbU0u4xDl60GuT2cqiS5D5/nsWzv7rGj/6RvUpvLC/kEK33Y7loo5DY/g8nOme QTXuocGWebD1D1V3pG+3vv+caLfOmbkQp6+XhJdjFTaASFJTlgYdS/3a4Od4XBQZA2OU 2IjqKwr00nPqj6+U8EybmCx4jWsRMVXJT4mC1C016rDdCxGV9v+PZ5Yx3MUGPb50GID1 sBR5NoJYq7X/mhJ/QbmQ4MXrfn1nQT7+I8f4QStbFsJogszemN0gs4ldFlpSQXrFahsI C7Pw== 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=TEjnZ6xt2wlLT8EUIt9/RhmVBAzoRToS1Rn3ukjQe90=; b=IpCOR41uW0X8nFXbKc5DXBT9fSZ61bUmp1Zub3HFPIEZJqgCYRDNEZA3bUhevBB31L kzkoqQ46J8Vs0nFQ1QmFCqF6BhJIxkGF3QpaTUY5zh8cEW9TKtJQOwFmUFt0cSJuWTvK K5+xr2NtWuUiPmUwGQhKxbWfjNWJIPo2R8ALPCj4hT8gLMHm4Qcng+PP7dUE1kWJyw6e y6wT21eJcJskp3Honfj9HQjr4D/Wkv05U6ZL/enwvAWZ9AMDX3E3OiLpavWDC3b89as3 njor5eC6UNOzFI9j6L/D8mfQzyqF2tkoL5HT1w1ciBz8AwjFKeT3z8da3egH/INbtkEO IRGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=XmYAQSNx; 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=NONE dis=NONE) header.from=163.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 69-20020a630548000000b0042daf0155fbsi2500686pgf.692.2022.09.02.10.03.32; Fri, 02 Sep 2022 10:03:43 -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=@163.com header.s=s110527 header.b=XmYAQSNx; 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=NONE dis=NONE) header.from=163.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237258AbiIBQRs (ORCPT + 99 others); Fri, 2 Sep 2022 12:17:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237055AbiIBQRQ (ORCPT ); Fri, 2 Sep 2022 12:17:16 -0400 Received: from m12-11.163.com (m12-11.163.com [220.181.12.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1BAD32CC9B for ; Fri, 2 Sep 2022 09:15:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=TEjnZ 6xt2wlLT8EUIt9/RhmVBAzoRToS1Rn3ukjQe90=; b=XmYAQSNxPRIwo3y9TMEkh 7YS3HEqS7+NAUd5590uGeDowzqSWwRtCbgR5mFyUfUF+zIpVBopglFQ0fcwswmhm LtSW5avMuxtUTXmUb2OgaXkzp7PBpoKHQFfQJaRtyI998rSanVyOXN37BX8UkBO5 2vthxVp47ByIo1ZBD8XfQg= Received: from ubuntu.localdomain (unknown [183.159.78.175]) by smtp7 (Coremail) with SMTP id C8CowAA3sgwdKBJj3tXsCw--.41444S4; Fri, 02 Sep 2022 23:58:22 +0800 (CST) From: Li Qiang To: naveen.n.rao@linux.ibm.com, anil.s.keshavamurthy@intel.com, davem@davemloft.net, mhiramat@kernel.org Cc: linux-kernel@vger.kernel.org, liq3ea@gmail.com, Li Qiang Subject: [PATCH] kprobe: reverse kp->flags when arm_kprobe failed Date: Fri, 2 Sep 2022 08:58:20 -0700 Message-Id: <20220902155820.34755-1-liq3ea@163.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: C8CowAA3sgwdKBJj3tXsCw--.41444S4 X-Coremail-Antispam: 1Uf129KBjvdXoWrtF17KF4UWrWkWF4UtFyUtrb_yoW3ZFX_Aa 4vqrZ09r4YyFsxZr4YyrW5urs2grsa9FWfCFy0qFW5Ka17GrnIgan5uFy5Aa4Fga4DXF9x Arn8Zrs0vFyYqjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7sRA0eQ3UUUUU== X-Originating-IP: [183.159.78.175] X-CM-SenderInfo: 5oltjvrd6rljoofrz/ 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,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 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 &= ~KPROBE_FLAG_DISABLED; ret = arm_kprobe(p); - if (ret) + if (ret) { p->flags |= KPROBE_FLAG_DISABLED; + if (p != kp) + kp->flags |= KPROBE_FLAG_DISABLED; + } } out: mutex_unlock(&kprobe_mutex); -- 2.25.1