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: <54ECED97.5070500@gmx.de>
Date:	Tue, 24 Feb 2015 22:31:03 +0100
From:	Heinrich Schuchardt <xypron.glpk@....de>
To:	David Rientjes <rientjes@...gle.com>
CC:	Andrew Morton <akpm@...ux-foundation.org>,
	Aaron Tomlin <atomlin@...hat.com>,
	Andy Lutomirski <luto@...capital.net>,
	Davidlohr Bueso <dave@...olabs.net>,
	"David S. Miller" <davem@...emloft.net>,
	Fabian Frederick <fabf@...net.be>,
	Guenter Roeck <linux@...ck-us.net>,
	"H. Peter Anvin" <hpa@...or.com>, Ingo Molnar <mingo@...nel.org>,
	Jens Axboe <axboe@...com>, Joe Perches <joe@...ches.com>,
	Johannes Weiner <hannes@...xchg.org>,
	Kees Cook <keescook@...omium.org>,
	Michael Marineau <mike@...ineau.org>,
	Oleg Nesterov <oleg@...hat.com>,
	"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>,
	Peter Zijlstra <peterz@...radead.org>,
	Prarit Bhargava <prarit@...hat.com>,
	Rik van Riel <riel@...hat.com>,
	Rusty Russell <rusty@...tcorp.com.au>,
	Steven Rostedt <rostedt@...dmis.org>,
	Thomas Gleixner <tglx@...utronix.de>,
	Vladimir Davydov <vdavydov@...allels.com>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 3/3] kernel/sysctl.c: threads-max observe limits

On 24.02.2015 22:17, David Rientjes wrote:
> On Tue, 24 Feb 2015, Heinrich Schuchardt wrote:
> 
>> Users can change the maximum number of threads by writing to
>> /proc/sys/kernel/threads-max.
>>
>> With the patch the value entered is checked against the same
>> limits that apply when fork_init is called.
>>
> 
> Correct me if I'm wrong, but this is a change in functionality (without 
> update to Documentation/sysctl/kernel.txt which describes threads-max) 
> since it does not allow the value to be lowered as before from the 
> calculation involving totalram_pages.  The value passed to 
> set_max_threads() only caps the value.

threads_max is set to the value the user inputs if it is inside the
interval [20, FUTEX_TID_MASK] and it is capped by the value calculated
from totalram_pages.

So lowering and raising is still possible (inside the limits).

> 
>> Signed-off-by: Heinrich Schuchardt <xypron.glpk@....de>
>> ---
>>  include/linux/sysctl.h |  3 +++
>>  kernel/fork.c          | 24 ++++++++++++++++++++++++
>>  kernel/sysctl.c        |  6 ++----
>>  3 files changed, 29 insertions(+), 4 deletions(-)
>>
>> diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
>> index b7361f8..795d5fe 100644
>> --- a/include/linux/sysctl.h
>> +++ b/include/linux/sysctl.h
>> @@ -212,4 +212,7 @@ static inline void setup_sysctl_set(struct ctl_table_set *p,
>>  
>>  #endif /* CONFIG_SYSCTL */
>>  
>> +int sysctl_max_threads(struct ctl_table *table, int write,
>> +		       void __user *buffer, size_t *lenp, loff_t *ppos);
>> +
>>  #endif /* _LINUX_SYSCTL_H */
>> diff --git a/kernel/fork.c b/kernel/fork.c
>> index 880c78d..52a07c7 100644
>> --- a/kernel/fork.c
>> +++ b/kernel/fork.c
>> @@ -74,6 +74,7 @@
>>  #include <linux/uprobes.h>
>>  #include <linux/aio.h>
>>  #include <linux/compiler.h>
>> +#include <linux/sysctl.h>
>>  
>>  #include <asm/pgtable.h>
>>  #include <asm/pgalloc.h>
>> @@ -2024,3 +2025,26 @@ int unshare_files(struct files_struct **displaced)
>>  	task_unlock(task);
>>  	return 0;
>>  }
>> +
>> +int sysctl_max_threads(struct ctl_table *table, int write,
>> +		       void __user *buffer, size_t *lenp, loff_t *ppos)
>> +{
>> +	struct ctl_table t;
>> +	int ret;
>> +	int threads = max_threads;
>> +	int min = MIN_THREADS;
>> +	int max = MAX_THREADS;
>> +
>> +	t = *table;
>> +	t.data = &threads;
>> +	t.extra1 = &min;
>> +	t.extra2 = &max;
>> +
>> +	ret = proc_dointvec_minmax(&t, write, buffer, lenp, ppos);
>> +	if (ret || !write)
>> +		return ret;
>> +
>> +	set_max_threads(threads);
>> +
>> +	return 0;
>> +}
>> diff --git a/kernel/sysctl.c b/kernel/sysctl.c
>> index 137c7f6..2e195ae 100644
>> --- a/kernel/sysctl.c
>> +++ b/kernel/sysctl.c
>> @@ -92,11 +92,9 @@
>>  #include <linux/nmi.h>
>>  #endif
>>  
>> -
>>  #if defined(CONFIG_SYSCTL)
>>  
>>  /* External variables not in a header file. */
>> -extern int max_threads;
>>  extern int suid_dumpable;
>>  #ifdef CONFIG_COREDUMP
>>  extern int core_uses_pid;
>> @@ -709,10 +707,10 @@ static struct ctl_table kern_table[] = {
>>  #endif
>>  	{
>>  		.procname	= "threads-max",
>> -		.data		= &max_threads,
>> +		.data		= NULL,
>>  		.maxlen		= sizeof(int),
>>  		.mode		= 0644,
>> -		.proc_handler	= proc_dointvec,
>> +		.proc_handler	= sysctl_max_threads,
>>  	},
>>  	{
>>  		.procname	= "random",
> 
Best regards

Heinrich
--
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