Re: [RFC][PATCH 3/4] kprobes: Allow kprobes with CONFIG_MODULES=n

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Mar 06, 2024 at 12:05:10PM -0800, Calvin Owens wrote:
> If something like this is merged down the road, it can go in at leisure
> once the module_alloc change is in: it's a one-way dependency.
> 
> Signed-off-by: Calvin Owens <jcalvinowens@xxxxxxxxx>
> ---
>  arch/Kconfig                |  2 +-
>  kernel/kprobes.c            | 22 ++++++++++++++++++++++
>  kernel/trace/trace_kprobe.c | 11 +++++++++++
>  3 files changed, 34 insertions(+), 1 deletion(-)

When I did this in my last execmem posting, I think I've got slightly less
ugly ifdery, you may want to take a look at that:

https://lore.kernel.org/all/20230918072955.2507221-13-rppt@xxxxxxxxxx
 
> diff --git a/arch/Kconfig b/arch/Kconfig
> index cfc24ced16dd..e60ce984d095 100644
> --- a/arch/Kconfig
> +++ b/arch/Kconfig
> @@ -52,8 +52,8 @@ config GENERIC_ENTRY
>  
>  config KPROBES
>  	bool "Kprobes"
> -	depends on MODULES
>  	depends on HAVE_KPROBES
> +	select MODULE_ALLOC
>  	select KALLSYMS
>  	select TASKS_RCU if PREEMPTION
>  	help
> diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> index 9d9095e81792..194270e17d57 100644
> --- a/kernel/kprobes.c
> +++ b/kernel/kprobes.c
> @@ -1556,8 +1556,12 @@ static bool is_cfi_preamble_symbol(unsigned long addr)
>  		str_has_prefix("__pfx_", symbuf);
>  }
>  
> +#if IS_ENABLED(CONFIG_MODULES)
>  static int check_kprobe_address_safe(struct kprobe *p,
>  				     struct module **probed_mod)
> +#else
> +static int check_kprobe_address_safe(struct kprobe *p)
> +#endif
>  {
>  	int ret;
>  
> @@ -1580,6 +1584,7 @@ static int check_kprobe_address_safe(struct kprobe *p,
>  		goto out;
>  	}
>  
> +#if IS_ENABLED(CONFIG_MODULES)

Plain #ifdef will do here and below. IS_ENABLED is for usage withing the
code, like

	if (IS_ENABLED(CONFIG_MODULES))
		;

>  	/* Check if 'p' is probing a module. */
>  	*probed_mod = __module_text_address((unsigned long) p->addr);
>  	if (*probed_mod) {

-- 
Sincerely yours,
Mike.




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux