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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200226074906.0acb08b31d01c96c475da0cb@kernel.org>
Date:   Wed, 26 Feb 2020 07:49:06 +0900
From:   Masami Hiramatsu <mhiramat@...nel.org>
To:     <zhe.he@...driver.com>
Cc:     <peterz@...radead.org>, <mingo@...hat.com>, <acme@...nel.org>,
        <mark.rutland@....com>, <alexander.shishkin@...ux.intel.com>,
        <jolsa@...hat.com>, <namhyung@...nel.org>,
        <kstewart@...uxfoundation.org>, <tglx@...utronix.de>,
        <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/2] perf: probe-file: Check return value of
 strlist__add

On Tue, 25 Feb 2020 22:41:43 +0800
<zhe.he@...driver.com> wrote:

> From: He Zhe <zhe.he@...driver.com>
> 
> strlist__add may fail with -ENOMEM or -EEXIST. Check it and give debugging
> hint when necessary.
> 
> Signed-off-by: He Zhe <zhe.he@...driver.com>
> ---
>  tools/perf/builtin-probe.c   | 30 ++++++++++++++++--------------
>  tools/perf/util/probe-file.c | 26 +++++++++++++++++++++-----
>  2 files changed, 37 insertions(+), 19 deletions(-)
> 
> diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
> index 26bc5923e6b5..8b4511c70fed 100644
> --- a/tools/perf/builtin-probe.c
> +++ b/tools/perf/builtin-probe.c
> @@ -442,24 +442,26 @@ static int perf_del_probe_events(struct strfilter *filter)
>  	}
>  
>  	ret = probe_file__get_events(kfd, filter, klist);
> -	if (ret == 0) {
> -		strlist__for_each_entry(ent, klist)
> -			pr_info("Removed event: %s\n", ent->s);
> +	if (ret < 0)
> +		goto out;

No, this is ignored by design.
Since probe_file__get_events() returns -ENOENT when no event is matched,
this should be just ignored, and goto uprobe event matching.

>  
> -		ret = probe_file__del_strlist(kfd, klist);
> -		if (ret < 0)
> -			goto error;
> -	}
> +	strlist__for_each_entry(ent, klist)
> +		pr_info("Removed event: %s\n", ent->s);
> +
> +	ret = probe_file__del_strlist(kfd, klist);
> +	if (ret < 0)
> +		goto error;
>  
>  	ret2 = probe_file__get_events(ufd, filter, ulist);
> -	if (ret2 == 0) {
> -		strlist__for_each_entry(ent, ulist)
> -			pr_info("Removed event: %s\n", ent->s);
> +	if (ret2 < 0)
> +		goto out;

Ditto.

Thank you,

>  
> -		ret2 = probe_file__del_strlist(ufd, ulist);
> -		if (ret2 < 0)
> -			goto error;
> -	}
> +	strlist__for_each_entry(ent, ulist)
> +		pr_info("Removed event: %s\n", ent->s);
> +
> +	ret2 = probe_file__del_strlist(ufd, ulist);
> +	if (ret2 < 0)
> +		goto error;
>  
>  	if (ret == -ENOENT && ret2 == -ENOENT)
>  		pr_warning("\"%s\" does not hit any event.\n", str);
> diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c
> index cf44c05f89c1..00f086cba88f 100644
> --- a/tools/perf/util/probe-file.c
> +++ b/tools/perf/util/probe-file.c
> @@ -307,10 +307,14 @@ int probe_file__get_events(int fd, struct strfilter *filter,
>  		p = strchr(ent->s, ':');
>  		if ((p && strfilter__compare(filter, p + 1)) ||
>  		    strfilter__compare(filter, ent->s)) {
> -			strlist__add(plist, ent->s);
> -			ret = 0;
> +			ret = strlist__add(plist, ent->s);
> +			if (ret < 0) {
> +				pr_debug("strlist__add failed (%d)\n", ret);
> +				goto out;
> +			}
>  		}
>  	}
> +out:
>  	strlist__delete(namelist);
>  
>  	return ret;
> @@ -517,7 +521,11 @@ static int probe_cache__load(struct probe_cache *pcache)
>  				ret = -EINVAL;
>  				goto out;
>  			}
> -			strlist__add(entry->tevlist, buf);
> +			ret = strlist__add(entry->tevlist, buf);
> +			if (ret < 0) {
> +				pr_debug("strlist__add failed (%d)\n", ret);
> +				goto out;
> +			}
>  		}
>  	}
>  out:
> @@ -678,7 +686,12 @@ int probe_cache__add_entry(struct probe_cache *pcache,
>  		command = synthesize_probe_trace_command(&tevs[i]);
>  		if (!command)
>  			goto out_err;
> -		strlist__add(entry->tevlist, command);
> +		ret = strlist__add(entry->tevlist, command);
> +		if (ret < 0) {
> +			pr_debug("strlist__add failed (%d)\n", ret);
> +			goto out_err;
> +		}
> +
>  		free(command);
>  	}
>  	list_add_tail(&entry->node, &pcache->entries);
> @@ -859,7 +872,10 @@ int probe_cache__scan_sdt(struct probe_cache *pcache, const char *pathname)
>  			break;
>  		}
>  
> -		strlist__add(entry->tevlist, buf);
> +		ret = strlist__add(entry->tevlist, buf);
> +		if (ret < 0)
> +			pr_debug("strlist__add failed (%d)\n", ret);
> +
>  		free(buf);
>  		entry = NULL;
>  	}
> -- 
> 2.24.1
> 


-- 
Masami Hiramatsu <mhiramat@...nel.org>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ