lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220504112139.a4b9e0bbeb697fb0980864c6@kernel.org>
Date:   Wed, 4 May 2022 11:21:39 +0900
From:   Masami Hiramatsu <mhiramat@...nel.org>
To:     Max Filippov <jcmvbkbc@...il.com>
Cc:     linux-kernel@...r.kernel.org,
        "Naveen N. Rao" <naveen.n.rao@...ux.ibm.com>,
        Anil S Keshavamurthy <anil.s.keshavamurthy@...el.com>,
        "David S. Miller" <davem@...emloft.net>,
        Masami Hiramatsu <mhiramat@...nel.org>,
        Peter Zijlstra <peterz@...radead.org>
Subject: Re: [PATCH] kprobes: fix build with CONFIG_KRETPROBES=n

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 <jcmvbkbc@...il.com> 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 <jcmvbkbc@...il.com>
> ---
>  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 <mhiramat@...nel.org>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ