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: <1499257556.2707.38.camel@decadent.org.uk>
Date:   Wed, 05 Jul 2017 13:25:56 +0100
From:   Ben Hutchings <ben@...adent.org.uk>
To:     Willy Tarreau <w@....eu>
Cc:     Michal Hocko <mhocko@...nel.org>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        Hugh Dickins <hughd@...gle.com>,
        Oleg Nesterov <oleg@...hat.com>,
        "Jason A. Donenfeld" <Jason@...c4.com>,
        Rik van Riel <riel@...hat.com>,
        Larry Woodman <lwoodman@...hat.com>,
        "Kirill A. Shutemov" <kirill@...temov.name>,
        Tony Luck <tony.luck@...el.com>,
        "James E.J. Bottomley" <jejb@...isc-linux.org>,
        Helge Diller <deller@....de>,
        James Hogan <james.hogan@...tec.com>,
        Laura Abbott <labbott@...hat.com>, Greg KH <greg@...ah.com>,
        "security@...nel.org" <security@...nel.org>,
        linux-distros@...openwall.org,
        Qualys Security Advisory <qsa@...lys.com>,
        LKML <linux-kernel@...r.kernel.org>,
        Ximin Luo <infinity0@...ian.org>
Subject: Re: [PATCH] mm: larger stack guard gap, between vmas

On Tue, 2017-07-04 at 19:11 +0200, Willy Tarreau wrote:
> On Tue, Jul 04, 2017 at 12:36:11PM +0100, Ben Hutchings wrote:
> > @@ -2323,11 +2330,17 @@ int expand_downwards(struct vm_area_struct *vma,
> >  	if (error)
> >  		return error;
> >  
> > -	/* Enforce stack_guard_gap */
> > +	/*
> > +	 * Enforce stack_guard_gap, but allow VM_NONE mappings in the gap
> > +	 * as some applications try to make their own stack guards
> > +	 */
> >  	gap_addr = address - stack_guard_gap;
> >  	if (gap_addr > address)
> >  		return -ENOMEM;
> > -	prev = vma->vm_prev;
> > +	for (prev = vma->vm_prev;
> > +	     prev && !(prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC));
> > +	     prev = prev->vm_prev)
> > +		;
> >  	if (prev && prev->vm_end > gap_addr) {
> >  		if (!(prev->vm_flags & VM_GROWSDOWN))
> >  			return -ENOMEM;
> 
> Hmmm shouldn't we also stop looping when we're out of the gap ?

Yes, either that or only allow one such vma.

Ben.

> Something like this :
> 
> 	for (prev = vma->vm_prev;
> 	     prev && !(prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) &&
> 	        address - prev->vm_end < stack_guard_gap;
> 	     prev = prev->vm_prev)
> 		;
> 
> This would limit the risk of runaway loops if someone is having fun
> allocating a lot of memory in small chunks (eg: 4 GB in 1 million
> independant mmap() calls).

-- 
Ben Hutchings
Anthony's Law of Force: Don't force it, get a larger hammer.


Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ