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]
Date: Tue, 16 Jan 2024 09:01:29 +0200
From: Adrian Hunter <adrian.hunter@...el.com>
To: Li Zhijian <lizhijian@...itsu.com>, linux-kernel@...r.kernel.org
Cc: Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>,
 Arnaldo Carvalho de Melo <acme@...nel.org>,
 Mark Rutland <mark.rutland@....com>,
 Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
 Jiri Olsa <jolsa@...nel.org>, Namhyung Kim <namhyung@...nel.org>,
 Ian Rogers <irogers@...gle.com>, Thomas Gleixner <tglx@...utronix.de>,
 Borislav Petkov <bp@...en8.de>, Dave Hansen <dave.hansen@...ux.intel.com>,
 x86@...nel.org, "H. Peter Anvin" <hpa@...or.com>,
 linux-perf-users@...r.kernel.org
Subject: Re: [PATCH 04/42] arch/x86/events/core: Convert snprintf to
 sysfs_emit

On 16/01/24 06:51, Li Zhijian wrote:
> Per filesystems/sysfs.rst, show() should only use sysfs_emit()
> or sysfs_emit_at() when formatting the value to be returned to user space.
> 
> coccinelle complains that there are still a couple of functions that use
> snprintf(). Convert them to sysfs_emit().
> 
>> ./arch/x86/events/core.c:1895:11-19: WARNING: please use sysfs_emit
>> ./arch/x86/events/core.c:2542:8-16: WARNING: please use sysfs_emit
>> ./arch/x86/events/core.c:2600:8-16: WARNING: please use sysfs_emit
> 
> No functional change intended
> 
> CC: Peter Zijlstra <peterz@...radead.org>
> CC: Ingo Molnar <mingo@...hat.com>
> CC: Arnaldo Carvalho de Melo <acme@...nel.org>
> CC: Mark Rutland <mark.rutland@....com>
> CC: Alexander Shishkin <alexander.shishkin@...ux.intel.com>
> CC: Jiri Olsa <jolsa@...nel.org>
> CC: Namhyung Kim <namhyung@...nel.org>
> CC: Ian Rogers <irogers@...gle.com>
> CC: Adrian Hunter <adrian.hunter@...el.com>
> CC: Thomas Gleixner <tglx@...utronix.de>
> CC: Borislav Petkov <bp@...en8.de>
> CC: Dave Hansen <dave.hansen@...ux.intel.com>
> CC: x86@...nel.org
> CC: "H. Peter Anvin" <hpa@...or.com>
> CC: linux-perf-users@...r.kernel.org
> Signed-off-by: Li Zhijian <lizhijian@...itsu.com>
> ---
>  arch/x86/events/core.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
> index 40ad1425ffa2..52e5707be03b 100644
> --- a/arch/x86/events/core.c
> +++ b/arch/x86/events/core.c
> @@ -1892,7 +1892,7 @@ ssize_t events_hybrid_sysfs_show(struct device *dev,
>  		if (x86_pmu.hybrid_pmu[i].pmu_type & pmu->pmu_type) {
>  			next_str = strchr(str, ';');
>  			if (next_str)
> -				return snprintf(page, next_str - str + 1, "%s", str);
> +				return sysfs_emit(page, "%s", str);

The intention seems to be to print only up to, and not including, the next ';',
but sysfs_emit() is not going to do that.

>  			else
>  				return sprintf(page, "%s", str);
>  		}
> @@ -2539,7 +2539,7 @@ static ssize_t get_attr_rdpmc(struct device *cdev,
>  			      struct device_attribute *attr,
>  			      char *buf)
>  {
> -	return snprintf(buf, 40, "%d\n", x86_pmu.attr_rdpmc);
> +	return sysfs_emit(buf, "%d\n", x86_pmu.attr_rdpmc);
>  }
>  
>  static ssize_t set_attr_rdpmc(struct device *cdev,
> @@ -2597,7 +2597,7 @@ static ssize_t max_precise_show(struct device *cdev,
>  				  struct device_attribute *attr,
>  				  char *buf)
>  {
> -	return snprintf(buf, PAGE_SIZE, "%d\n", x86_pmu_max_precise());
> +	return sysfs_emit(buf, "%d\n", x86_pmu_max_precise());
>  }
>  
>  static DEVICE_ATTR_RO(max_precise);


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ