[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b50e8198-ca2e-eb44-ed71-e4ca27f48232@infradead.org>
Date: Thu, 9 Jul 2020 20:31:39 -0700
From: Randy Dunlap <rdunlap@...radead.org>
To: Changming Liu <charley.ashbringer@...il.com>, keescook@...omium.org
Cc: mcgrof@...nel.org, yzaikin@...gle.com,
linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org
Subject: Re: [PATCH] sysctl: add bound to panic_timeout to prevent overflow
On 7/9/20 8:22 PM, Changming Liu wrote:
> Function panic() in kernel/panic.c will use panic_timeout
> multiplying 1000 as a loop boundery. So this multiplication
boundary.
> can overflow when panic_timeout is greater than (INT_MAX/1000).
> And this results in a zero-delay panic, instead of a huge
> timeout as the user intends.
>
> Fix this by adding bound check to make it no bigger than
> (INT_MAX/1000).
>
> Signed-off-by: Changming Liu <charley.ashbringer@...il.com>
> ---
> kernel/sysctl.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/sysctl.c b/kernel/sysctl.c
> index db1ce7a..e60cf04 100644
> --- a/kernel/sysctl.c
> +++ b/kernel/sysctl.c
> @@ -137,6 +137,9 @@ static int minolduid;
> static int ngroups_max = NGROUPS_MAX;
> static const int cap_last_cap = CAP_LAST_CAP;
>
> +/* this is needed for setting boundery for panic_timeout to prevent it from overflow*/
boundary (or max value) overflow */
> +static int panic_time_max = INT_MAX / 1000;
> +
> /*
> * This is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs
> * and hung_task_check_interval_secs
> @@ -1857,7 +1860,8 @@ static struct ctl_table kern_table[] = {
> .data = &panic_timeout,
> .maxlen = sizeof(int),
> .mode = 0644,
> - .proc_handler = proc_dointvec,
> + .proc_handler = proc_dointvec_minmax,
> + .extra2 = &panic_time_max,
> },
> #ifdef CONFIG_COREDUMP
> {
>
thanks.
--
~Randy
Powered by blists - more mailing lists