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] [day] [month] [year] [list]
Date:	Fri, 12 Sep 2008 13:52:26 +0200
From:	Adam Tkac <vonsch@...il.com>
To:	Andreas Schwab <schwab@...e.de>
Cc:	torvalds@...ux-foundation.org, linux-kernel@...r.kernel.org,
	akpm@...ux-foundation.org, mtk.manpages@...il.com
Subject: Re: [PATCH 2.6.27-rc5] Allow set RLIMIT_NOFILE to RLIM_INFINITY

On Fri, Sep 12, 2008 at 01:20:46PM +0200, Andreas Schwab wrote:
> Adam Tkac <vonsch@...il.com> writes:
> 
> > diff -puN kernel/sys.c~rlimit-permit-setting-rlimit_nofile-to-rlim_infinity kernel/sys.c
> > --- a/kernel/sys.c~rlimit-permit-setting-rlimit_nofile-to-rlim_infinity
> > +++ a/kernel/sys.c
> > @@ -1532,8 +1532,14 @@ asmlinkage long sys_setrlimit(unsigned i
> >  	if ((new_rlim.rlim_max > old_rlim->rlim_max) &&
> >  	    !capable(CAP_SYS_RESOURCE))
> >  		return -EPERM;
> > -	if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > sysctl_nr_open)
> > -		return -EPERM;
> > +	if (resource == RLIMIT_NOFILE) {
> > +		if (new_rlim.rlim_max == RLIM_INFINITY)
> > +			new_rlim.rlim_max = sysctl_nr_open;
> > +		if (new_rlim.rlim_cur == RLIM_INFINITY)
> > +			new_rlim.rlim_cur = sysctl_nr_open;
> > +		if (new_rlim.rlim_max > sysctl_nr_open)
> > +			return -EPERM;
> 
> This makes it possible to set cur > nr_open (when max = INF but nr_open
> < cur < INF).  You need to check that cur <= max after adjustment.
> 
> Andreas.
> 

Right you are. Improved patch is attached, when cur > max && cur !=
INF after adjustment EINVAL is returned. (cur can be also set to max
but it seems like bad solution for me)

-- 
Adam Tkac


View attachment "linux26-openfiles.patch" of type "text/plain" (1968 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ