Re: [PATCH gnumach v4] Implement per task virtual memory limit

2025-06-29 Thread Samuel Thibault
Hello, Diego Nieto Cid, le sam. 28 juin 2025 23:31:45 +0100, a ecrit: > I was updating this patch and I've gut a doubt with what to do with the > result of vm_map_find_entry_anywhere in case of a failure to enforce the > limit. > > I end up with code like below: > > if (anywhere) { >

Re: [PATCH gnumach v4] Implement per task virtual memory limit

2025-06-28 Thread Diego Nieto Cid
Hi, I was updating this patch and I've gut a doubt with what to do with the result of vm_map_find_entry_anywhere in case of a failure to enforce the limit. I end up with code like below: if (anywhere) { entry = vm_map_find_entry_anywhere(map, size, mask, FALSE, &start);

Re: [PATCH gnumach v4] Implement per task virtual memory limit

2025-06-24 Thread Samuel Thibault
Diego Nieto Cid, le mer. 25 juin 2025 00:44:04 +0100, a ecrit: > On Wed, Jun 25, 2025 at 01:08:31AM +0200, Samuel Thibault wrote: > > > > I meant a vm_protect that changes the maximum protection. > > > > Ah, I think we concluded that the maximum protection can only go > into strictier values due

Re: [PATCH gnumach v4] Implement per task virtual memory limit

2025-06-24 Thread Diego Nieto Cid
On Wed, Jun 25, 2025 at 01:08:31AM +0200, Samuel Thibault wrote: > > I meant a vm_protect that changes the maximum protection. > Ah, I think we concluded that the maximum protection can only go into strictier values due to the loop here[1]. More specifically the following if: if ((/* VM_PR

Re: [PATCH gnumach v4] Implement per task virtual memory limit

2025-06-24 Thread Samuel Thibault
Diego Nieto Cid, le mer. 25 juin 2025 00:04:39 +0100, a ecrit: > But then I don't think I understand your suggestion: > > > It would be also useful to check that trying to vm_protect the PROT_NONE > > into PROT_ALL fails when that comes above the limit. > > Why would vm_protect fail when upgradin

Re: [PATCH gnumach v4] Implement per task virtual memory limit

2025-06-24 Thread Diego Nieto Cid
On Wed, Jun 25, 2025 at 12:52:41AM +0200, Samuel Thibault wrote: > > Yes, and that's what we want: like on Linux. RLIMIT_AS is supposed to > limit mmap(PROT_NONE) as well. > Ok, then the assumption of my test is completely wrong :) I'll remove it. But then I don't think I understand your sugge

Re: [PATCH gnumach v4] Implement per task virtual memory limit

2025-06-24 Thread Samuel Thibault
Diego Nieto Cid, le mar. 24 juin 2025 23:50:49 +0100, a ecrit: > On Tue, Jun 24, 2025 at 03:54:23PM +0200, Samuel Thibault wrote: > > Because that is what Linux implements: RLIMIT_AS limits what > > mmap(PROT_NONE) can allocate. Then, changing with mprotect() will not > > change the RLIMIT_AS count

Re: [PATCH gnumach v4] Implement per task virtual memory limit

2025-06-24 Thread Diego Nieto Cid
On Tue, Jun 24, 2025 at 03:54:23PM +0200, Samuel Thibault wrote: > > Because that is what Linux implements: RLIMIT_AS limits what > mmap(PROT_NONE) can allocate. Then, changing with mprotect() will not > change the RLIMIT_AS counting. > mmap(PROT_NONE)[1][2] ends up calling vm_map(cur: VM_PROT_NO

Re: [PATCH gnumach v4] Implement per task virtual memory limit

2025-06-24 Thread Samuel Thibault
Diego Nieto Cid, le mar. 24 juin 2025 14:39:35 +0100, a ecrit: > On Mon, Jun 23, 2025 at 12:51:23AM +0200, Samuel Thibault wrote: > > > + err = vm_deallocate(mach_task_self(), mem, M_512M); > > > + ASSERT_RET(err, "deallocation failed"); > > > > It would be also useful to check that trying to vm

Re: [PATCH gnumach v4] Implement per task virtual memory limit

2025-06-24 Thread Diego Nieto Cid
On Mon, Jun 23, 2025 at 12:51:23AM +0200, Samuel Thibault wrote: > > + err = vm_deallocate(mach_task_self(), mem, M_512M); > > + ASSERT_RET(err, "deallocation failed"); > > It would be also useful to check that trying to vm_protect the PROT_NONE > into PROT_ALL fails when that comes above the li

Re: [PATCH gnumach v4] Implement per task virtual memory limit

2025-06-22 Thread Samuel Thibault
Hello, dnie...@gmail.com, le lun. 16 juin 2025 23:58:06 +0100, a ecrit: > diff --git a/tests/test-vm.c b/tests/test-vm.c > index 4ece792e..8e4ad884 100644 > --- a/tests/test-vm.c > +++ b/tests/test-vm.c > @@ -75,11 +75,96 @@ static void test_wire() >// TODO check that all memory is actually wi

[PATCH gnumach v4] Implement per task virtual memory limit

2025-06-16 Thread dnietoc
From: Diego Nieto Cid * include/mach/gnumach.defs: (vm_set_size_limit) new routine (vm_get_size_limit) likewise * kern/task.c: (task_create_kernel) if parent_task is not null copy virtual memory limit * tests/test-vm.c: (test_vm_limit) add test for the new routines * vm/vm_kern.c: (p