Re: [PATCH bpf] bpf: respect CAP_IPC_LOCK in RLIMIT_MEMLOCK check

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

 



On 9/11/19 8:18 PM, Christian Barcenas wrote:
A process can lock memory addresses into physical RAM explicitly
(via mlock, mlockall, shmctl, etc.) or implicitly (via VFIO,
perf ring-buffers, bpf maps, etc.), subject to RLIMIT_MEMLOCK limits.

CAP_IPC_LOCK allows a process to exceed these limits, and throughout
the kernel this capability is checked before allowing/denying an attempt
to lock memory regions into RAM.

Because bpf locks its programs and maps into RAM, it should respect
CAP_IPC_LOCK. Previously, bpf would return EPERM when RLIMIT_MEMLOCK was
exceeded by a privileged process, which is contrary to documented
RLIMIT_MEMLOCK+CAP_IPC_LOCK behavior.

Do you have a link/pointer where this is /clearly/ documented?

Uapi header is not overly clear ...

include/uapi/linux/capability.h says:

  /* Allow locking of shared memory segments */
  /* Allow mlock and mlockall (which doesn't really have anything to do
     with IPC) */

  #define CAP_IPC_LOCK         14

  [...]

  /* Override resource limits. Set resource limits. */
  /* Override quota limits. */
  /* Override reserved space on ext2 filesystem */
  /* Modify data journaling mode on ext3 filesystem (uses journaling
     resources) */
  /* NOTE: ext2 honors fsuid when checking for resource overrides, so
     you can override using fsuid too */
  /* Override size restrictions on IPC message queues */
  /* Allow more than 64hz interrupts from the real-time clock */
  /* Override max number of consoles on console allocation */
  /* Override max number of keymaps */

  #define CAP_SYS_RESOURCE     24

... but my best guess is you are referring to `man 2 mlock`:

   Limits and permissions

       In Linux 2.6.8 and earlier, a process must be privileged (CAP_IPC_LOCK)
       in order to lock memory and the RLIMIT_MEMLOCK soft resource limit defines
       a limit on how much memory the process may lock.

       Since  Linux  2.6.9, no limits are placed on the amount of memory that a
       privileged process can lock and the RLIMIT_MEMLOCK soft resource limit
       instead defines a limit on how much memory an unprivileged process may lock.

Thanks,
Daniel



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux