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]
Date:	Thu, 21 Apr 2016 20:22:36 -0400
From:	Matthew Wilcox <willy@...ux.intel.com>
To:	Toshi Kani <toshi.kani@....com>
Cc:	Mike Kravetz <mike.kravetz@...cle.com>, Jan Kara <jack@...e.cz>,
	"linux-nvdimm@...1.01.org" <linux-nvdimm@...1.01.org>,
	"david@...morbit.com" <david@...morbit.com>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"linux-mm@...ck.org" <linux-mm@...ck.org>,
	"adilger.kernel@...ger.ca" <adilger.kernel@...ger.ca>,
	"viro@...iv.linux.org.uk" <viro@...iv.linux.org.uk>,
	"linux-fsdevel@...r.kernel.org" <linux-fsdevel@...r.kernel.org>,
	"tytso@....edu" <tytso@....edu>,
	Andrew Morton <akpm@...ux-foundation.org>,
	"kirill.shutemov@...ux.intel.com" <kirill.shutemov@...ux.intel.com>
Subject: Re: [PATCH v3 0/2] Align mmap address for DAX pmd mappings

On Thu, Apr 21, 2016 at 07:43:39PM -0400, Toshi Kani wrote:
> On 4/21/2016 4:21 PM, Mike Kravetz wrote:
> >Might want to keep the future possibility of PUD_SIZE THP in mind?
> 
> Yes, this is why the func name does not say 'pmd'. It can be extended to
> support
> PUD_SIZE in future.

Sure ... but what does that look like?  I think it should look a little
like this:

unsigned long __thp_get_unmapped_area(struct file *filp, unsigned long len,
                        loff_t off, unsigned long flags, unsigned long size);
{
        unsigned long addr;
        loff_t off_end = off + len;
        loff_t off_align = round_up(off, size);
        unsigned long len_size;

        if ((off_end <= off_align) || ((off_end - off_align) < size))
                return NULL;

        len_size = len + size;
        if ((len_size < len) || (off + len_size) < off)
                return NULL;

        addr = current->mm->get_unmapped_area(filp, NULL, len_size,
                                                off >> PAGE_SHIFT, flags);
        if (IS_ERR_VALUE(addr))
                return NULL;
 
        addr += (off - addr) & (size - 1);
        return addr;
}

unsigned long thp_get_unmapped_area(struct file *filp, unsigned long addr,
                unsigned long len, unsigned long pgoff, unsigned long flags)
{
        loff_t off = (loff_t)pgoff << PAGE_SHIFT;

        if (addr)
                goto out;
        if (IS_DAX(filp->f_mapping->host) && !IS_ENABLED(CONFIG_FS_DAX_PMD))
                goto out;
        /* Kirill, please fill in the right condition here for THP pagecache */

        addr = __thp_get_unmapped_area(filp, len, off, flags, PUD_SIZE);
        if (addr)
                return addr;
        addr = __thp_get_unmapped_area(filp, len, off, flags, PMD_SIZE);
        if (addr)
                return addr;

 out:
        return current->mm->get_unmapped_area(filp, addr, len, pgoff, flags);
}

By the way, I added an extra check here, when we add len and size
(PMD_SIZE in the original), we need to make sure that doesn't wrap.
NB: I'm not even compiling these suggestions, just throwing them out
here as ideas to be criticised.

Also, len_size is a stupid name, but I can't think of a better one.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ