Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp235420iob; Mon, 2 May 2022 18:04:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNGDiTnsu7cQ4hnUjII/GFkPNWKyaagGkKdyXHodGjSo0HzOE4hJE/GocjCLweB97hfsC+ X-Received: by 2002:a17:902:ce11:b0:15b:4232:e5e7 with SMTP id k17-20020a170902ce1100b0015b4232e5e7mr14140729plg.39.1651539842772; Mon, 02 May 2022 18:04:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651539842; cv=none; d=google.com; s=arc-20160816; b=PJujal9xOdOUjs4fbYrm+zIplFDCxhsOyoS2zTW+AtVAldw3pcfrDlcgpoULJGorCg nEhc6EhoL6CxIbRmoqKADIH4ynqJgaYzpKQKvkwwJfEqO5QYG2mPfTE8i/V++Ez0RiI1 CKzVlu8sLbd0RzEnUOlS1aDtKrobuBQBzsIDMoZ5cUJGYVmcZboTKgrKYH9QjsgNT0Se 3M4D64Tzn1cmcp3eqKAQ0q6oeEe1RJgvbPeBiRceuD3dm3LytocgRBv/O/ahml5famEz ooq993dwxAiFqgRkuGUdsIlJNHrADIG5uHqSglxbp+NnQMuQ4Xe5hgD8A3Za0jqf4l/9 VqpQ== 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=Ky0MEvXpm39NcrzucQHp70smIiw6DLihko8P5JGPfNM=; b=ro5Rr6tJJ4xZOqE+K+oE1hoYCQjC59GAZBeg5d9b2e1pzq0XKwMw4CjkZtReI8NJh2 STgjliJc8G5xQ1yZBiSKIaoeUxl2Sgp9lRpFJQqcbN55svs6M+eF30SVl3AQHFkKpkcH OWjUDXFbfgBln4oIrGcRUgz+HS5qbctIOUpvaa4GTCKdRcNvqnATm3xf4reLenwYxcwI 8+4HLAWFRKjm10jzUpfPuUSfbZe8hF1c9ImgDFZPVNUrnqoVC9my4M1BONc4a2T6BMXU 8puA9LnWavlcsi5FDbptxKLWOWjrbSTD5aSJHFRlS3emYvY0WqJ80QDIIfTF4TacbCz3 Racw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=QIku27bW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id e11-20020a170902f1cb00b0015d53c6c340si13902503plc.473.2022.05.02.18.04.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 18:04:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=QIku27bW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C3AFD56FAF; Mon, 2 May 2022 17:47:42 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236624AbiEBSpn (ORCPT + 99 others); Mon, 2 May 2022 14:45:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240455AbiEBSol (ORCPT ); Mon, 2 May 2022 14:44:41 -0400 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD24CF71 for ; Mon, 2 May 2022 11:41:12 -0700 (PDT) Received: by mail-pg1-x533.google.com with SMTP id 15so12302721pgf.4 for ; Mon, 02 May 2022 11:41:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Ky0MEvXpm39NcrzucQHp70smIiw6DLihko8P5JGPfNM=; b=QIku27bWUkSEGWT8oQUpsOXy8xsPr6pyS06whMjEWtcMB8VDjFspIws8/dsTbBe9Fk G4L4x07Pl/lLjv3NzlSGWFTzGP2Um/yYZlOo7H0kmiDWMXTjiI2/INBhFv8tKONbUmb1 SFKvMxDtHhJNVvwGIY16eOzX2zmJ/XE/9EaySUCyi+Y+QdgnvZLKlTCAP/DxsiDRkabr lq+ik7pzaD+lXYv+10xFfZM2qAcEAvIuEP82lumDF+nHP6lpOrI5pIYlwzc41nOaALQq K+d9pDlKgdjb1Qnz25kLBimzTFyUFmYadu/6B6MurHnFcQo9YDP9ro6+pu6zML4imjLT zZAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Ky0MEvXpm39NcrzucQHp70smIiw6DLihko8P5JGPfNM=; b=0aRr9699QV+Rpnu8KPdCYaSZPZY/uJRUnd1QbaTR4OfIUrPWO4E44bAhYzZGg+cOyY iKj0/AMLpWLjtOrqKoaiEhQT+bcaGEJ2y3KF1ERvov4Zp8ghPbykhM+fewBPnlth6pQG t03RezbfC8xeU35Dmns89HHrrNn3jAgAlki/vH580C6sH/Dq3oUQo3RnHVFNs//Nh3EH fG209UaJYnUmtgkktnYqx+9oiGcqDrIDv/1hUmrxgv9XZDPVhefhmKm4WIt2FViz5VUn 1kAcVLFmSJNlfnjtyvM42ooZu84JdN8MByKrhxlBpKL8Xt5ajUfrnVGMhhnTqsB+MvJc bYWg== X-Gm-Message-State: AOAM532ul91MMWF7X2fdFZMDIJM5BwEqvZecrvi0lANcKFJmTxw2MzE/ /guxkGkdqr3jarxOTE3XXQax9YEo1iE= X-Received: by 2002:a65:6149:0:b0:3a9:7e8f:6429 with SMTP id o9-20020a656149000000b003a97e8f6429mr10757017pgv.613.1651516872044; Mon, 02 May 2022 11:41:12 -0700 (PDT) Received: from octofox.hsd1.ca.comcast.net ([2601:641:401:1d20:8d9f:cb26:e2f0:4a8a]) by smtp.gmail.com with ESMTPSA id 12-20020a170902c24c00b0015e8d4eb22dsm4966660plg.119.2022.05.02.11.41.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 11:41:11 -0700 (PDT) From: Max Filippov To: linux-kernel@vger.kernel.org Cc: "Naveen N. Rao" , Anil S Keshavamurthy , "David S. Miller" , Masami Hiramatsu , Peter Zijlstra , Max Filippov Subject: [PATCH] kprobes: fix build with CONFIG_KRETPROBES=n Date: Mon, 2 May 2022 11:40:50 -0700 Message-Id: <20220502184050.1792743-1-jcmvbkbc@gmail.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, FROM_LOCAL_NOVOWEL,HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 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