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 Apr 2013 15:42:02 +0200
From:	chrubis@...e.cz
To:	Andrew Morton <akpm@...ux-foundation.org>
Cc:	linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] mm/mmap: Check for RLIMIT_AS before unmapping

Hi!
> > +static unsigned long count_vma_pages_range(struct mm_struct *mm,
> > +		unsigned long addr, unsigned long end)
> > +{
> > +	unsigned long nr_pages = 0;
> > +	struct vm_area_struct *vma;
> > +
> > +	/* Find first overlaping mapping */
> > +	vma = find_vma_intersection(mm, addr, end);
> > +	if (!vma)
> > +		return 0;
> > +
> > +	nr_pages = (min(end, vma->vm_end) -
> > +		max(addr, vma->vm_start)) >> PAGE_SHIFT;
> 
> urgh, these things always make my head spin.  Is it guaranteed that
> end, vm_end, addr and vm_start are all multiples of PAGE_SIZE?  If not,
> we have a problem don't we?

Yes, it takes a little of concentration before one can say what the code
does, unfortunatelly this is the most readable variant I've came up
with.

The len is page aligned right at the start of the do_mmap_pgoff() (end
is addr + len). The addr should be aligned in the get_unmapped_area()
although the codepath is more complicated to follow, but it seems to end
up in one of the arch_get_unmapped_area* and these makes sure the
address is aligned.

Moreover mmap() manual page says that the addr passed to mmap() is page
aligned (although I tend to check the code rather than the docs).

And for the vmas I belive these are page aligned by definition, correct
me if I'm wrong.

-- 
Cyril Hrubis
chrubis@...e.cz
--
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