Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp776990iob; Wed, 4 May 2022 07:47:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxEVz4ZUz8Z9pSJL5IFKsCIbpxlPuiHfqXttwYW+WKqtwAkv6QGhJimyDrNvUQQwox2zuaq X-Received: by 2002:a17:907:1c8d:b0:6f2:eb2:1cd6 with SMTP id nb13-20020a1709071c8d00b006f20eb21cd6mr20026442ejc.568.1651675667447; Wed, 04 May 2022 07:47:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651675667; cv=none; d=google.com; s=arc-20160816; b=BWAxhkMS35e3SdrsQ48Ak6HvdGA76WctIvrkZduIx1BHuXSTvK7A23Qsquut/Kb2HZ kKP1WN96eHPpEupg9xagIDojZ7hsmsrq0oi/iS1oJiZzIa03gU9+8myPEhNlbIAK9XuK Ffc1eLLzXl0Ccnf3Rc7+TymSbSJcqapxVCg3m+dVLBjMfuL91dsKV+O30KK1JSbbqO+x s6AB8dLhcX9l6S4YSa3brGV9DMJGR1xQHqbcd0/f/5m+efEQQNrqQG+EuXHA1MJnB9wh vn2/5elFitHERvw2Rbp2KjAPK5EZqTkmgOtGI5Inr0COaLb/JmFAO2DtlXO+6/ju6EVS 4tmg== 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:subject:cc:to:from:date :dkim-signature; bh=t+iVX25O+Yitt1wxI7zg4I8blcz7CUnqRiCXg4GhnqU=; b=lOXIUh9Nrq7oXrmoBVA4KPnsMHsybbCrty922bDv4mg6UnldkhHdfiMzexK44Q5vXk VCzCaldHK/4i0ZH4C9pt5h7WJirJZThtTFzyOWen/KTKg6yrtvoOgedR8AuQfsJquMMM HrHkgzoL7XmbD4kdGXwh95eqjD78GGcMFzJMMj6mYX6BHNSs31aYuLUh1eHfUKxwsyJX Nf3Y6sJf9EsgAS/xkhQ1cUsPIaWdt/ZOZl30URgtbisSQ64XbwxuQ+J16F3lZV5xmemd QGLaHcuZO3cLF8fb9XWhCe+qsuNugdl+Ebgay8xdUtu+qnDOXFDIpK7xvfHVxd9E0o23 K+rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ojzA6aF0; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s5-20020a170906a18500b006f460f82493si6217267ejy.125.2022.05.04.07.47.22; Wed, 04 May 2022 07:47:47 -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=@kernel.org header.s=k20201202 header.b=ojzA6aF0; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245671AbiEDCZV (ORCPT + 99 others); Tue, 3 May 2022 22:25:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229579AbiEDCZS (ORCPT ); Tue, 3 May 2022 22:25:18 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2B3122BDD for ; Tue, 3 May 2022 19:21:44 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 34333619DD for ; Wed, 4 May 2022 02:21:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D56B7C385A4; Wed, 4 May 2022 02:21:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1651630903; bh=fcTqXzojK4WmUgceBGkv/oGAZ7gI7I5rRw7o4nQVbGU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=ojzA6aF0kfY1cUuum9CUbSCbM9+l4RhJ8rV5UXJnu7Mr2OEVH7qbx6sX5ml6CTL9a AoaQVg4nFBa4gCSepjH8uClbLuHAdgykwVF54AY/hL3TASIvtecRA+7EaX/kTM/hHv 5qt7BXRZFSLaute/jXivH+Gno1McJ05QZnTgCdzfCuLooRHW0f1oSgYxaMzsb2a6gv gdf0mwycPUxH6ZIpHuPEG65PrJxk5Y4The64wvEcYRV9TutNwwvW0/1SftGf/0jVN5 Yro7K5EUUwtl6Kl6Qb/dKFZJBI6eY9BlV4Sc5FN0wo/2m/zrilgV7nlVMse8yWG/MX thvcHtXZV1TSQ== Date: Wed, 4 May 2022 11:21:39 +0900 From: Masami Hiramatsu To: Max Filippov Cc: linux-kernel@vger.kernel.org, "Naveen N. Rao" , Anil S Keshavamurthy , "David S. Miller" , Masami Hiramatsu , Peter Zijlstra Subject: Re: [PATCH] kprobes: fix build with CONFIG_KRETPROBES=n Message-Id: <20220504112139.a4b9e0bbeb697fb0980864c6@kernel.org> In-Reply-To: <20220502184050.1792743-1-jcmvbkbc@gmail.com> References: <20220502184050.1792743-1-jcmvbkbc@gmail.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_HI,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 Hello Max, Thank you for reporting this issue and making a patch. However, it looks those functions (free_rp_inst_rcu(), recycle_rp_inst(), kprobe_flush_task() and free_rp_inst()) should be moved into the CONFIG_KRETPROBES=y area simply because all of those are needed for kretprobes. Let me fix that. Thank you, On Mon, 2 May 2022 11:40:50 -0700 Max Filippov wrote: > When building kernel with CONFIG_KRETPROBES=n kernel/kprobes.c > compilation fails with the following messages: > > kernel/kprobes.c: In function ‘recycle_rp_inst’: > kernel/kprobes.c:1273:32: error: implicit declaration of function > ‘get_kretprobe’ > > kernel/kprobes.c: In function ‘kprobe_flush_task’: > kernel/kprobes.c:1299:35: error: ‘struct task_struct’ has no member > named ‘kretprobe_instances’ > > Make references to kretprobe-specific structures and functions > conditional. > > Signed-off-by: Max Filippov > --- > kernel/kprobes.c | 32 +++++++++++++++++++++----------- > 1 file changed, 21 insertions(+), 11 deletions(-) > > diff --git a/kernel/kprobes.c b/kernel/kprobes.c > index dd58c0be9ce2..95ce4d16e63e 100644 > --- a/kernel/kprobes.c > +++ b/kernel/kprobes.c > @@ -1258,6 +1258,7 @@ void kprobe_busy_end(void) > } > > #if !defined(CONFIG_KRETPROBE_ON_RETHOOK) > +#ifdef CONFIG_KRETPROBES > static void free_rp_inst_rcu(struct rcu_head *head) > { > struct kretprobe_instance *ri = container_of(head, struct kretprobe_instance, rcu); > @@ -1279,21 +1280,11 @@ static void recycle_rp_inst(struct kretprobe_instance *ri) > } > NOKPROBE_SYMBOL(recycle_rp_inst); > > -/* > - * This function is called from delayed_put_task_struct() when a task is > - * dead and cleaned up to recycle any kretprobe instances associated with > - * this task. These left over instances represent probed functions that > - * have been called but will never return. > - */ > -void kprobe_flush_task(struct task_struct *tk) > +static void kretprobe_flush_task(struct task_struct *tk) > { > struct kretprobe_instance *ri; > struct llist_node *node; > > - /* Early boot, not yet initialized. */ > - if (unlikely(!kprobes_initialized)) > - return; > - > kprobe_busy_begin(); > > node = __llist_del_all(&tk->kretprobe_instances); > @@ -1306,6 +1297,25 @@ void kprobe_flush_task(struct task_struct *tk) > > kprobe_busy_end(); > } > +NOKPROBE_SYMBOL(kretprobe_flush_task); > +#endif > + > +/* > + * This function is called from delayed_put_task_struct() when a task is > + * dead and cleaned up to recycle any kretprobe instances associated with > + * this task. These left over instances represent probed functions that > + * have been called but will never return. > + */ > +void kprobe_flush_task(struct task_struct *tk) > +{ > + /* Early boot, not yet initialized. */ > + if (unlikely(!kprobes_initialized)) > + return; > + > +#ifdef CONFIG_KRETPROBES > + kretprobe_flush_task(tk); > +#endif > +} > NOKPROBE_SYMBOL(kprobe_flush_task); > > static inline void free_rp_inst(struct kretprobe *rp) > -- > 2.30.2 > -- Masami Hiramatsu