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: <ZeD-HkC7bsAn_YgK@krava>
Date: Thu, 29 Feb 2024 22:58:54 +0100
From: Jiri Olsa <olsajiri@...il.com>
To: "Masami Hiramatsu (Google)" <mhiramat@...nel.org>
Cc: Steven Rostedt <rostedt@...dmis.org>,
	linux-trace-kernel@...r.kernel.org, Jiri Olsa <olsajiri@...il.com>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] fprobe: Fix to allocate entry_data_size buffer with
 rethook instances

On Thu, Feb 29, 2024 at 08:22:47PM +0900, Masami Hiramatsu (Google) wrote:
> From: Masami Hiramatsu (Google) <mhiramat@...nel.org>
> 
> Fix to allocate fprobe::entry_data_size buffer with rethook instances.
> If fprobe doesn't allocate entry_data_size buffer for each rethook instance,
> fprobe entry handler can cause a buffer overrun when storing entry data in
> entry handler.
> 
> Reported-by: Jiri Olsa <olsajiri@...il.com>

Tested-by: Jiri Olsa <olsajiri@...il.com>

thanks,
jirka

> Fixes: 4bbd93455659 ("kprobes: kretprobe scalability improvement")
> Cc: stable@...r.kernel.org
> Signed-off-by: Masami Hiramatsu (Google) <mhiramat@...nel.org>
> ---
>  kernel/trace/fprobe.c |   14 ++++++--------
>  1 file changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/kernel/trace/fprobe.c b/kernel/trace/fprobe.c
> index 6cd2a4e3afb8..9ff018245840 100644
> --- a/kernel/trace/fprobe.c
> +++ b/kernel/trace/fprobe.c
> @@ -189,9 +189,6 @@ static int fprobe_init_rethook(struct fprobe *fp, int num)
>  {
>  	int size;
>  
> -	if (num <= 0)
> -		return -EINVAL;
> -
>  	if (!fp->exit_handler) {
>  		fp->rethook = NULL;
>  		return 0;
> @@ -199,15 +196,16 @@ static int fprobe_init_rethook(struct fprobe *fp, int num)
>  
>  	/* Initialize rethook if needed */
>  	if (fp->nr_maxactive)
> -		size = fp->nr_maxactive;
> +		num = fp->nr_maxactive;
>  	else
> -		size = num * num_possible_cpus() * 2;
> -	if (size <= 0)
> +		num *= num_possible_cpus() * 2;
> +	if (num <= 0)
>  		return -EINVAL;
>  
> +	size = sizeof(struct fprobe_rethook_node) + fp->entry_data_size;
> +
>  	/* Initialize rethook */
> -	fp->rethook = rethook_alloc((void *)fp, fprobe_exit_handler,
> -				sizeof(struct fprobe_rethook_node), size);
> +	fp->rethook = rethook_alloc((void *)fp, fprobe_exit_handler, size, num);
>  	if (IS_ERR(fp->rethook))
>  		return PTR_ERR(fp->rethook);
>  
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ