tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: uvm_unmap() vs. uvm_deallocate()



Hello Stephan,

uvm_deallocate is a wrapper for uvm_unmap. It calls unmap after checking 3 things:

- size is not 0
- address starts at a page. If not, it is rounded
- address + size is at the end of a page, otherwise, size is also rounded

A thing to look out for here is that unmap takes a pointer to the end while deallocate uses the size instead and it is not possible to set the flags using deallocate.

From what I understand in regard to sys_shmdt (sysv_shm.c), the address in this case cannot be influenced by the user/userland. This would make the checks introduced by deallocate not necessary.

Kind regards


Am 13.01.25 um 14:06 schrieb Stephan:
Hello,

what is the difference between uvm_unmap() and uvm_deallocate()?

It does not become clear to me from what is written in uvm_map(9):


uvm_unmap() removes a valid mapping, from start to end, in map map, which
      must be unlocked.

uvm_deallocate() deallocates kernel memory in map map from address start
      to start + size.


uvm_deallocate() is used e.g. in sysv_shm.c, in which case I would
have expected uvm_unmap().


Thanks,

Stephan


Home | Main Index | Thread Index | Old Index