[openib-general] Re: ibv_reg_mr/ memory locking

Michael S. Tsirkin mst at mellanox.co.il
Mon Jan 24 13:18:32 PST 2005


Quoting r. Roland Dreier <roland at topspin.com>:
> Subject: Re: ibv_reg_mr/ memory locking
> 
>     Michael> Specifically, if it exposes to the user the ability to
>     Michael> lock raw physical memory, how do you plan to prevent a
>     Michael> DOS by locking all memory?
> 
>     Michael> The architecture document says it is done with mlock from
>     Michael> userspace, so I thought for a bit that driver may simply
>     Michael> require that user mlocks the relevant memory, but then I
>     Michael> understood that its easy to bypass by munlocking the
>     Michael> registered memory.
> 
> This is a good question.  Userspace does need to do mlock() to get
> correct results (otherwise the kernel may map new pages at a given
> virtual address, even if the old pages are locked).
Are you aware of the fact that mlock wont always be sufficient for this
(notably COW)?
And, pages may be, or become, COW, often without the user knowing.

> However the
> kernel side will do get_user_pages() to keep the pages present.  So if
> a rogue process does munlock(), the only problem it can cause is to
> screw itself up.

I was referring to the fact that event if kernel would like to help by
checking VMA is locked, it cant.

> There is a possibility of userspace possibly pinning a lot of pages
> this way, but it would have to allocate the memory first.  I think
> there are a lot of local DOS attacks like this that people just don't
> worry about too much.
> 
>  - R.

Some people do care about it http://kerneltrap.org/node/4540
I dont know how reasonable it is to make this unfixable by design.

-- 
I dont speak for Mellanox.



More information about the general mailing list