[Bug 271579] Incorrect vmemoryuse per user rctl limits for jails calculation

From: <bugzilla-noreply_at_freebsd.org>
Date: Tue, 23 May 2023 10:07:02 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=271579

            Bug ID: 271579
           Summary: Incorrect vmemoryuse per user rctl limits for jails
                    calculation
           Product: Base System
           Version: 13.2-STABLE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: KOT@MATPOCKuH.Ru

I want to limit a per user memory usage for every running jail.
I'm tried to set a limits like this:
jail:pg198:vmemoryuse:deny=17179869184/user
jail:pg199:vmemoryuse:deny=17179869184/user

I have users with same uid in there jails, resulting a memory allocation for
user in jail pg198, makes impossible to use this limit for same user in jail
pg199.

To check I used this simple code:
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>

int
main(int argc, char *argv[]) {
        long size = atol(argv[1]);
        void *buf = malloc(size);

        if (buf == NULL) {
                fprintf(stderr, "malloc(%li) failed: %s\n", size,
strerror(errno));
                return 1;
        }

        fgets(buf, size < 1024 ? size : 1024, stdin);
        return 0;
}

And when a user in one jail is running a command:
./alloc $((10*1024*1024*1024))
User in a different jail can't allocate memory:
malloc(10737418240) failed: Cannot allocate memory

A limits like jail:jailname:vmemoryuse:deny=limit/user should limit a allocated
memory per user for each jail, but not for user in all jails.

-- 
You are receiving this mail because:
You are the assignee for the bug.