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: <YoNzr1ciY12Bg6Rv@kroah.com>
Date:   Tue, 17 May 2022 12:06:39 +0200
From:   Greg KH <gregkh@...uxfoundation.org>
To:     Yuanjun Gong <ruc_gongyuanjun@....com>
Cc:     Steven Rostedt <rostedt@...dmis.org>,
        Ingo Molnar <mingo@...hat.com>, linux-kernel@...r.kernel.org,
        stable@...r.kernel.org
Subject: Re: [PATCH 1/1] tracing: fix possible null pointer dereference

On Tue, May 17, 2022 at 05:57:23PM +0800, Yuanjun Gong wrote:
> From: Gong Yuanjun <ruc_gongyuanjun@....com>
> 
> In hist_trigger_elt_data_alloc(), elt_data is freed by
> hist_elt_data_free() if kcalloc fails.
> 
> static int hist_trigger_elt_data_alloc(struct tracing_map_elt *elt)
> {
> ...
> elt_data->field_var_str = kcalloc(n_str, sizeof(char *), GFP_KERNEL);
>         if (!elt_data->field_var_str) {
>                 hist_elt_data_free(elt_data);
>                 return -EINVAL;
>         }
> ...}
> 
> In hist_elt_data_free() the elt_data->field_var_str field should be
> checked before dereference.
> 
> Signed-off-by: Gong Yuanjun <ruc_gongyuanjun@....com>
> ---
>  kernel/trace/trace_events_hist.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
> index 44db5ba9cabb..73177c9f94b2 100644
> --- a/kernel/trace/trace_events_hist.c
> +++ b/kernel/trace/trace_events_hist.c
> @@ -1576,11 +1576,11 @@ static void hist_elt_data_free(struct hist_elt_data *elt_data)
>  {
>  	unsigned int i;
>  
> -	for (i = 0; i < elt_data->n_field_var_str; i++)
> -		kfree(elt_data->field_var_str[i]);
> -
> -	kfree(elt_data->field_var_str);
> -
> +	if (elt_data->field_var_str) {
> +		for (i = 0; i < elt_data->n_field_var_str; i++)
> +			kfree(elt_data->field_var_str[i]);
> +		kfree(elt_data->field_var_str);
> +	}
>  	kfree(elt_data->comm);
>  	kfree(elt_data);
>  }
> -- 
> 2.17.1
> 

<formletter>

This is not the correct way to submit patches for inclusion in the
stable kernel tree.  Please read:
    https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.

</formletter>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ