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>] [day] [month] [year] [list]
Date:	Thu, 05 Jun 2008 14:43:55 +0200
From:	Vitaly Mayatskikh <v.mayatskih@...il.com>
To:	linux-kernel@...r.kernel.org
Subject: different conditions in arch_get_unmapped_area_topdown

Hi!

Here's do-while loop from generic arch_get_unmapped_area_topdown() from mm/mmap.c:

        do {
                /*
                 * Lookup failure means no vma is above this address,
                 * else if new region fits below vma->vm_start,
                 * return with success:
                 */
                vma = find_vma(mm, addr);
                if (!vma || addr+len <= vma->vm_start)
                        /* remember the address as a hint for next time */
                        return (mm->free_area_cache = addr);
                
                /* remember the largest hole we saw so far */
                if (addr + mm->cached_hole_size < vma->vm_start)
                        mm->cached_hole_size = vma->vm_start - addr;
                       
                /* try just below the current vma->vm_start */
                addr = vma->vm_start-len;
        } while (len < vma->vm_start);

And here's from arch/x86/mm/hugetlbpage.c:

        do {
                /*
                 * Lookup failure means no vma is above this address,
                 * i.e. return with success:
                 */
                if (!(vma = find_vma_prev(mm, addr, &prev_vma)))
                        return addr;
       
                /*
                 * new region fits between prev_vma->vm_end and
                 * vma->vm_start, use it:
                 */
                if (addr + len <= vma->vm_start &&
                            (!prev_vma || (addr >= prev_vma->vm_end))) {
                        /* remember the address as a hint for next time */
                        mm->cached_hole_size = largest_hole;
                        return (mm->free_area_cache = addr);
                } else {
                        /* pull free_area_cache down to the first hole */
                        if (mm->free_area_cache == vma->vm_end) {
                                mm->free_area_cache = vma->vm_start;
                                mm->cached_hole_size = largest_hole;
                        }
                }
           
                /* remember the largest hole we saw so far */
                if (addr + largest_hole < vma->vm_start)
                        largest_hole = vma->vm_start - addr;

                /* try just below the current vma->vm_start */
                addr = (vma->vm_start - len) & HPAGE_MASK;
        } while (len <= vma->vm_start);

Why conditions in "while" differ from each other? Can the second case lead to infinite loop?

Thanks!
-- 
wbr, Vitaly
--
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