bug-hurd
[Top][All Lists]
Advanced

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

Re: [RFC] Implementing RLIMIT_AS


From: Luca
Subject: Re: [RFC] Implementing RLIMIT_AS
Date: Fri, 20 Dec 2024 10:25:02 +0100

Il 19/12/24 23:54, Diego Nieto Cid ha scritto:
On Thu, Dec 19, 2024 at 10:36:49PM +0100, Luca wrote:

       I tried a lower value, like 2GB, but some process is mapping
       4GB at once during boot and it just hangs when the allocation
       fails.

Which process is that?


Its task name is `exec` and it's using vm_map. The log in question is:

     [vm_map] [task exec] map size: 0, requested size: 4294967296, hard limit: 
2147483648

are you working on x86_64? if yes, that could be the redzone configured here:

https://git.savannah.gnu.org/cgit/hurd/hurd.git/tree/exec/exec.c#n1247

One big point to address is how to enforce the ability to change this limit,
e.g. an unprivileged task shouldn't be able to increase its own memory
limit. You could reuse the host privileged port, but maybe it could make
sense to have a dedicated one for resource limits?

Correct. To be honest, at this poit, I haven't thought about it. I was just
toying with a POC implementation. Having the host privileged port means being
root essentially, right?

Yes, being root gives access to both the host and device privileged ports (among other things).

But if a dedicated port would make sense it may be worth exploring this option.
Do you know somewhere to look at for inspiration?

I think you could try to create e kernel port in the same way as the host or device ports, see for example in kern/ipc_host.c:ipc_host_init().

To start you might also reuse the host privileged port for simplicity, adding a "resource privileged" port would require it to be passed to the bootstrap tasks and be handled in the hurd. Also I'm not sure if there are other ideas discussed in the past about resource limits.


One additional point would be at least in task_create(), I guess the new
task would have the same restriction as the one creating it.


Yes, indeed. A quick look at kern/task.c shows I should check vm_map_fork:

     } else if (inherit_memory) {
         new_task->map = vm_map_fork(parent_task->map);


To experiment I'd suggest creating a test program as the ones in the tests/
folder in gnumach source, so you can try every single case and easily debug
it. Currently they can only be run on GNU/Linux as they require qemu.


I will try to set one up. But, I have an unusual environment for a FLOSS
developer, hehe.

----

Index: gnumach-1.8+git20240714/vm/vm_map.c

It would be better to create the patches from the git repository instead of
the debian package, and then use git-format-patch and git-send-mail.


Sorry, I've fallen in the temptation of `dpkg-buildpackage` and friends :)

I think the only debian patch you might need to be able to boot is the dde patch, I usually keep all of them on my dev branch to test my changes on a full system.


Luca




reply via email to

[Prev in Thread] Current Thread [Next in Thread]