[dpdk-dev] [PATCH] eal/linux: fix memory allocations in containers+SELinux

David Marchand david.marchand at redhat.com
Fri Oct 2 11:36:43 CEST 2020


On Thu, Sep 17, 2020 at 4:47 PM David Marchand
<david.marchand at redhat.com> wrote:
>
> On Thu, Sep 17, 2020 at 4:17 PM Burakov, Anatoly
> <anatoly.burakov at intel.com> wrote:
> > Anonymous hugepages shouldn't matter, yes, but single-file segments mode
> > does fallocate() and remove - you have the remove part covered, but i'm
> > just curious if fallocate() would also cause any issues with SELinux.
>
> I found no hook in the kernel for fallocate + selinux...
> Looked into fallocate itself and it ends up validating lsm write
> access on the file.
>
> I don't have the full setup atm but since I could truncate and write
> to it, I'd say we are good.

I could not gain access to the same setup again.

FWIW, I tried with my reproducer:
- no issue with --in-memory option (with or without patch)

- error correctly detected (with this patch) in normal mode after restarting:

# \rm /dev/hugepages/rtemap_*
# LD_PRELOAD=libwrap.so dpdk-testpmd -w 0000:01:00.0 -- -i
[... working fine ...]
# LD_PRELOAD=libwrap.so dpdk-testpmd -w 0000:01:00.0 -- -i
EAL: Detected 28 lcore(s)
EAL: Detected 1 NUMA nodes
### called unlink for /var/run/dpdk/rte/mp_socket
EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
EAL: Selected IOVA mode 'VA'
### refused unlinkat for rtemap_0
EAL: Probing VFIO support...
EAL: VFIO support initialized
### refused unlink for /dev/hugepages/rtemap_0
EAL: Couldn't get fd on hugepage file
EAL: error allocating rte services array
EAL: FATAL: rte_service_init() failed
EAL: rte_service_init() failed
EAL: Error - exiting with code: 1
  Cause: Cannot init EAL: Exec format error
### called unlink for /var/run/dpdk/rte/mp_socket

- error detected with legacy mode from first try (with or without
patch), since the memory allocator tries to remove unneeded hugepage
files in this mode, and reports failures for this:

# \rm /dev/hugepages/rtemap_*
# LD_PRELOAD=libwrap.so dpdk-testpmd -w 0000:01:00.0 --legacy-mem -m 2048 -- -i
EAL: Detected 28 lcore(s)
EAL: Detected 1 NUMA nodes
### called unlink for /var/run/dpdk/rte/mp_socket
EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
EAL: Selected IOVA mode 'VA'
EAL: Probing VFIO support...
EAL: VFIO support initialized
### refused unlink for /dev/hugepages/rtemap_2
EAL: unmap_unneeded_hugepages(): Removing /dev/hugepages/rtemap_2
failed: Permission denied
EAL: Unmapping and locking hugepages failed!
EAL: FATAL: Cannot init memory
EAL: Cannot init memory
EAL: Error - exiting with code: 1
  Cause: Cannot init EAL: Cannot allocate memory
### called unlink for /var/run/dpdk/rte/mp_socket


-- 
David Marchand



More information about the dev mailing list