lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 7 Feb 2018 22:39:35 +0100
From:   Björn Töpel <bjorn.topel@...il.com>
To:     Willem de Bruijn <willemdebruijn.kernel@...il.com>
Cc:     "Karlsson, Magnus" <magnus.karlsson@...el.com>,
        Alexander Duyck <alexander.h.duyck@...el.com>,
        Alexander Duyck <alexander.duyck@...il.com>,
        John Fastabend <john.fastabend@...il.com>,
        Alexei Starovoitov <ast@...com>,
        Jesper Dangaard Brouer <brouer@...hat.com>,
        Daniel Borkmann <daniel@...earbox.net>,
        Network Development <netdev@...r.kernel.org>,
        Björn Töpel <bjorn.topel@...el.com>,
        michael.lundkvist@...csson.com,
        "Brandeburg, Jesse" <jesse.brandeburg@...el.com>,
        "Singhai, Anjali" <anjali.singhai@...el.com>,
        "Shaw, Jeffrey B" <jeffrey.b.shaw@...el.com>,
        "Yigit, Ferruh" <ferruh.yigit@...el.com>,
        "Zhang, Qi Z" <qi.z.zhang@...el.com>
Subject: Re: [RFC PATCH 02/24] xsk: add user memory registration sockopt

2018-02-07 17:00 GMT+01:00 Willem de Bruijn <willemdebruijn.kernel@...il.com>:
> On Wed, Jan 31, 2018 at 8:53 AM, Björn Töpel <bjorn.topel@...il.com> wrote:
>> From: Björn Töpel <bjorn.topel@...el.com>
>>
>> The XDP_MEM_REG socket option allows a process to register a window of
>> user space memory to the kernel. This memory will later be used as
>> frame data buffer.
>>
>> Signed-off-by: Björn Töpel <bjorn.topel@...el.com>
>> ---
>
>> +static struct xsk_umem *xsk_mem_reg(u64 addr, u64 size, u32 frame_size,
>> +                                   u32 data_headroom)
>> +{
>> +       unsigned long lock_limit, locked, npages;
>> +       int ret = 0;
>> +       struct xsk_umem *umem;
>> +
>> +       if (!can_do_mlock())
>> +               return ERR_PTR(-EPERM);
>> +
>> +       umem = xsk_umem_create(addr, size, frame_size, data_headroom);
>> +       if (IS_ERR(umem))
>> +               return umem;
>> +
>> +       npages = PAGE_ALIGN(umem->nframes * umem->frame_size) >> PAGE_SHIFT;
>> +
>> +       down_write(&current->mm->mmap_sem);
>> +
>> +       locked = npages + current->mm->pinned_vm;
>> +       lock_limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT;
>> +
>> +       if (locked > lock_limit && !capable(CAP_IPC_LOCK)) {
>> +               ret = -ENOMEM;
>> +               goto out;
>> +       }
>> +
>> +       if (npages == 0 || npages > UINT_MAX) {
>> +               ret = -EINVAL;
>> +               goto out;
>> +       }
>> +       umem->npgs = npages;
>> +
>> +       ret = xsk_umem_pin_pages(umem);
>> +
>> +out:
>> +       if (ret < 0) {
>> +               put_pid(umem->pid);
>> +               kfree(umem);
>> +       } else {
>> +               current->mm->pinned_vm = locked;
>> +       }
>> +
>> +       up_write(&current->mm->mmap_sem);
>
> This limits per process. You may want to limit per user. See also
> mm_account_pinned_pages.

Ah, noted! Thanks for pointing that out!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ