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: <1254803939.14541.49.camel@macbook.infradead.org>
Date:	Tue, 06 Oct 2009 05:38:59 +0100
From:	David Woodhouse <dwmw2@...radead.org>
To:	Mike Frysinger <vapier.adi@...il.com>
Cc:	David Howells <dhowells@...hat.com>,
	Linux kernel mailing list <linux-kernel@...r.kernel.org>,
	uclinux-dist-devel <uclinux-dist-devel@...ckfin.uclinux.org>
Subject: Re: userspace firmware loader, vmap, and nommu

On Tue, 2009-10-06 at 00:25 -0400, Mike Frysinger wrote:
> semi-recently (9 Apr 2009), the userspace firmware code was rewritten
> to use vmap().  this causes problems for nommu systems as it isnt
> possible to create a virtually contiguous map with physically
> discontiguous pages. 

Oops, sorry.

>  the firmware loader used to work before this
> change because it would handle the realloc steps itself (allocate
> larger contiguous memory, copy over older data, release older memory)
> and vmalloc() on nommu is simply kmalloc().
> 
> this could be handled transparently on nommu systems by moving this
> scatter gathering of pages into vmap:
> void *vmap(struct page **pages, unsigned int count, unsigned long
> flags, pgprot_t prot)
> {
>     unsigned int i;
>     void *new_map, *page_data;
> 
>     new_map = kmalloc(count << PAGE_SHIFT, GFP_KERNEL);
>     if (!new_map)
>         return NULL;
> 
>     for (i = 0; i < count; ++i) {
>         page_data = kmap(pages[i]);
>         memcpy(new_map + (i << PAGE_SHIFT), page_data, PAGE_SIZE);
>         kunmap(page_data);
>     }
> 
>     return new_map;

I wouldn't necessarily want to do that for _all_ vmap() calls, but doing
it just for the firmware loader might make some sense. It does mean you
have to have _twice_ as much memory available as the size of the
firmware in question. And you have to have a contiguous chunk even
_after_ allocating it once piecemeal.

> void vunmap(const void *addr)
> {
>     kfree(addr);
> }
> 
> or we could add nommu-specific code to the firmware loader to not use
> vmap().  how would you like to go David (Howells) ?

Or we could add _generic_ code not to use vmap(). Just teach the users
that you don't get a virtually contiguous blob back from
request_firmware(); you get an array of pages instead.

-- 
David Woodhouse                            Open Source Technology Centre
David.Woodhouse@...el.com                              Intel Corporation

--
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