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: <20130925121243.GK3081@twins.programming.kicks-ass.net>
Date:	Wed, 25 Sep 2013 14:12:43 +0200
From:	Peter Zijlstra <peterz@...radead.org>
To:	Knut Petersen <Knut_Petersen@...nline.de>
Cc:	Linus Torvalds <torvalds@...ux-foundation.org>,
	Paul Mackerras <paulus@...ba.org>,
	Ingo Molnar <mingo@...hat.com>,
	Arnaldo Carvalho de Melo <acme@...stprotocols.net>,
	linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] perf: Prevent divide by zero exception in
 kernel/events/core.c

On Wed, Sep 25, 2013 at 02:07:35PM +0200, Knut Petersen wrote:
> From: Knut Petersen <Knut_Petersen@...nline.de>
> Date: Wed, 25 Sep 2013 13:34:57 +0200
> Subject: [PATCH] Enforce 1 as lower limit for perf_event_max_sample_rate
> 
> /proc/sys/kernel/perf_event_max_sample_rate will accept
> negative values as well as 0.
> 
> Negative values are unreasonable, and 0 causes a
> divide by zero exception in perf_proc_update_handler.
> 
> This patch enforces a lower limit of 1.
> 
> Signed-off-by: Knut Petersen <Knut_Petersen@...nline.de>
> ---
>  kernel/events/core.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index dd236b6..350bb53 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -198,6 +198,9 @@ int perf_proc_update_handler(struct ctl_table *table, int write,
>  	if (ret || !write)
>  		return ret;
>  
> +	if (sysctl_perf_event_sample_rate <= 0)
> +		sysctl_perf_event_sample_rate = 1;
> +
>  	max_samples_per_tick = DIV_ROUND_UP(sysctl_perf_event_sample_rate, HZ);
>  	perf_sample_period_ns = NSEC_PER_SEC / sysctl_perf_event_sample_rate;
>  	update_perf_cpu_limits();

The 'normal' way of doing that is changing the sysctl table entry to use
proc_dointvec_minmax and set .extra = &one. See for example
&sysctl_sched_cfs_bandwidth_slice in kernel/sysctl.c
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ