| /linux/tools/testing/selftests/drivers/dma-buf/ |
| H A D | udmabuf.c | 30 int memfd, ret; in create_memfd_with_seals() local 36 memfd = memfd_create("udmabuf-test", flags); in create_memfd_with_seals() 37 if (memfd < 0) { in create_memfd_with_seals() 42 ret = fcntl(memfd, F_ADD_SEALS, F_SEAL_SHRINK); in create_memfd_with_seals() 48 ret = ftruncate(memfd, size); in create_memfd_with_seals() 54 return memfd; in create_memfd_with_seals() 57 static int create_udmabuf_list(int devfd, int memfd, off64_t memfd_size) in create_udmabuf_list() argument 70 list->list[i].memfd = memfd; in create_udmabuf_list() 136 int devfd, memfd, buf, ret; in main() local 151 memfd = memfd_create("udmabuf-test", MFD_ALLOW_SEALING); in main() [all …]
|
| /linux/tools/testing/selftests/kvm/ |
| H A D | set_memory_region_test.c | 465 static void test_invalid_guest_memfd(struct kvm_vm *vm, int memfd, in test_invalid_guest_memfd() argument 470 0, memfd, offset); in test_invalid_guest_memfd() 477 int memfd, i; in test_add_private_memory_region() local 486 memfd = kvm_memfd_alloc(MEM_REGION_SIZE, false); in test_add_private_memory_region() 487 test_invalid_guest_memfd(vm, memfd, 0, "Regular memfd() should fail"); in test_add_private_memory_region() 488 close(memfd); in test_add_private_memory_region() 491 memfd = vm_create_guest_memfd(vm2, MEM_REGION_SIZE, 0); in test_add_private_memory_region() 492 test_invalid_guest_memfd(vm, memfd, 0, "Other VM's guest_memfd() should fail"); in test_add_private_memory_region() 495 MEM_REGION_GPA, MEM_REGION_SIZE, 0, memfd, 0); in test_add_private_memory_region() 496 close(memfd); in test_add_private_memory_region() [all …]
|
| /linux/Documentation/userspace-api/ |
| H A D | mfd_noexec.rst | 13 Since Linux introduced the memfd feature, memfds have always had their 19 boot), this executable nature of memfd opens a door for NoExec bypass 21 process created a memfd to share the content with an external process, 22 however the memfd is overwritten and used for executing arbitrary code 25 On the other hand, executable memfd has its legit use: runc uses memfd’s 32 - Let memfd be sealed for modifying X bit when NX is set. 41 When MFD_NOEXEC_SEAL bit is set in the ``flags``, memfd is created 42 with NX. F_SEAL_EXEC is set and the memfd can't be modified to 44 This is the most common case for the application to use memfd. 47 When MFD_EXEC bit is set in the ``flags``, memfd is created with X. [all …]
|
| /linux/tools/testing/selftests/pidfd/ |
| H A D | pidfd_getfd_test.c | 37 static int __child(int sk, int memfd) in __child() argument 53 ret = send(sk, &memfd, sizeof(memfd), 0); in __child() 54 if (ret != sizeof(memfd)) { in __child() 101 int memfd, ret; in child() local 103 memfd = sys_memfd_create("test", 0); in child() 104 if (memfd < 0) { in child() 109 ret = __child(sk, memfd); in child() 110 close(memfd); in child()
|
| /linux/drivers/dma-buf/ |
| H A D | udmabuf.c | 291 static int check_memfd_seals(struct file *memfd) in check_memfd_seals() argument 295 if (!shmem_file(memfd) && !is_file_hugepages(memfd)) in check_memfd_seals() 298 seals = memfd_fcntl(memfd, F_GET_SEALS, 0); in check_memfd_seals() 323 static long udmabuf_pin_folios(struct udmabuf *ubuf, struct file *memfd, in udmabuf_pin_folios() argument 335 nr_folios = memfd_pin_folios(memfd, start, end, folios, pgcnt, &pgoff); in udmabuf_pin_folios() 416 struct file *memfd = fget(list[i].memfd); in udmabuf_create() local 418 if (!memfd) { in udmabuf_create() 427 inode_lock_shared(file_inode(memfd)); in udmabuf_create() 428 ret = check_memfd_seals(memfd); in udmabuf_create() 432 ret = udmabuf_pin_folios(ubuf, memfd, list[i].offset, in udmabuf_create() [all …]
|
| /linux/tools/testing/selftests/bpf/prog_tests/ |
| H A D | dmabuf_iter.c | 32 int dev_udmabuf, memfd, local_udmabuf; in create_udmabuf() local 39 memfd = memfd_create("memfd_test", MFD_ALLOW_SEALING); in create_udmabuf() 40 if (!ASSERT_OK_FD(memfd, "memfd_create")) in create_udmabuf() 43 if (!ASSERT_OK(ftruncate(memfd, udmabuf_test_buffer_size), "ftruncate")) in create_udmabuf() 46 if (!ASSERT_OK(fcntl(memfd, F_ADD_SEALS, F_SEAL_SHRINK), "seal")) in create_udmabuf() 54 create.memfd = memfd; in create_udmabuf() 72 close(memfd); in create_udmabuf()
|
| /linux/tools/testing/selftests/exec/ |
| H A D | check-exec.c | 73 int memfd, pipefd; in FIXTURE() local 154 self->memfd = memfd_create("test-exec-probe", MFD_CLOEXEC); in FIXTURE_SETUP() 155 ASSERT_LE(0, self->memfd); in FIXTURE_SETUP() 157 ASSERT_EQ(0, fchmod(self->memfd, variant->file_exec ? 0700 : 0600)); in FIXTURE_SETUP() 294 test_exec_fd(_metadata, self->memfd, exec ? 0 : EACCES); in TEST_F() 297 test_exec_fd(_metadata, self->memfd, exec ? 0 : EACCES); in TEST_F() 304 fill_exec_fd(_metadata, self->memfd); in TEST_F() 306 test_exec_fd(_metadata, self->memfd, exec ? 0 : EACCES); in TEST_F() 309 test_exec_fd(_metadata, self->memfd, exec ? 0 : EACCES); in TEST_F()
|
| /linux/Documentation/mm/ |
| H A D | memfd_preservation.rst | 13 .. kernel-doc:: include/linux/kho/abi/memfd.h 14 :doc: DOC: memfd Live Update ABI 16 .. kernel-doc:: include/linux/kho/abi/memfd.h
|
| /linux/mm/ |
| H A D | memfd.c | 67 struct folio *memfd_alloc_folio(struct file *memfd, pgoff_t idx) in memfd_alloc_folio() argument 73 if (is_file_hugepages(memfd)) { in memfd_alloc_folio() 80 struct inode *inode = file_inode(memfd); in memfd_alloc_folio() 81 struct hstate *h = hstate_file(memfd); in memfd_alloc_folio() 119 hash = hugetlb_fault_mutex_hash(memfd->f_mapping, idx); in memfd_alloc_folio() 123 memfd->f_mapping, in memfd_alloc_folio() 143 return shmem_read_folio(memfd->f_mapping, idx); in memfd_alloc_folio()
|
| H A D | gup.c | 3436 long memfd_pin_folios(struct file *memfd, loff_t start, loff_t end, in memfd_pin_folios() argument 3451 if (!memfd) in memfd_pin_folios() 3454 if (!shmem_file(memfd) && !is_file_hugepages(memfd)) in memfd_pin_folios() 3457 if (end >= i_size_read(file_inode(memfd))) in memfd_pin_folios() 3460 if (is_file_hugepages(memfd)) { in memfd_pin_folios() 3461 h = hstate_file(memfd); in memfd_pin_folios() 3470 if (is_file_hugepages(memfd)) { in memfd_pin_folios() 3483 nr_found = filemap_get_folios_contig(memfd->f_mapping, in memfd_pin_folios() 3512 folio = memfd_alloc_folio(memfd, start_idx); in memfd_pin_folios()
|
| H A D | Makefile | 143 obj-$(CONFIG_MEMFD_CREATE) += memfd.o
|
| /linux/tools/testing/selftests/kvm/x86/ |
| H A D | private_mem_conversions_test.c | 383 int memfd, i; in test_mem_conversions() local 397 memfd = vm_create_guest_memfd(vm, memfd_size, 0); in test_mem_conversions() 402 KVM_MEM_GUEST_MEMFD, memfd, slot_size * i); in test_mem_conversions() 431 kvm_fallocate(memfd, FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE, 0, memfd_size); in test_mem_conversions() 432 kvm_fallocate(memfd, FALLOC_FL_KEEP_SIZE, 0, memfd_size); in test_mem_conversions() 434 close(memfd); in test_mem_conversions()
|
| /linux/include/uapi/linux/ |
| H A D | udmabuf.h | 11 __u32 memfd; member 18 __u32 memfd; member
|
| /linux/include/linux/ |
| H A D | memfd.h | 11 struct folio *memfd_alloc_folio(struct file *memfd, pgoff_t idx); 26 static inline struct folio *memfd_alloc_folio(struct file *memfd, pgoff_t idx) in memfd_alloc_folio() argument
|
| H A D | mm.h | 2995 long memfd_pin_folios(struct file *memfd, loff_t start, loff_t end,
|
| /linux/kernel/liveupdate/ |
| H A D | Kconfig | 76 bool "Live update support for memfd" 82 Enable live update support for memfd regions. This allows preserving 83 memfd-backed memory across kernel live updates.
|
| /linux/tools/testing/selftests/drivers/net/hw/ |
| H A D | ncdevmem.c | 112 int memfd; member 158 ctx->memfd = memfd_create("udmabuf-test", MFD_ALLOW_SEALING); in udmabuf_alloc() 159 if (ctx->memfd < 0) { in udmabuf_alloc() 164 ret = fcntl(ctx->memfd, F_ADD_SEALS, F_SEAL_SHRINK); in udmabuf_alloc() 170 ret = ftruncate(ctx->memfd, size); in udmabuf_alloc() 178 create.memfd = ctx->memfd; in udmabuf_alloc() 199 close(ctx->memfd); in udmabuf_alloc() 211 close(ctx->memfd); in udmabuf_free()
|
| /linux/tools/testing/selftests/memfd/ |
| H A D | .gitignore | 5 memfd-test-file
|
| H A D | run_fuse_test.sh | 13 ./fuse_test ./mnt/memfd $@
|
| /linux/tools/testing/selftests/seccomp/ |
| H A D | seccomp_bpf.c | 4137 int status, listener, memfd, fd, nextfd; in TEST() local 4147 memfd = memfd_create("test", 0); in TEST() 4148 ASSERT_GE(memfd, 0); in TEST() 4149 nextfd = get_next_fd(memfd); in TEST() 4180 addfd.srcfd = memfd; in TEST() 4218 EXPECT_EQ(filecmp(getpid(), pid, memfd, fd), 0); in TEST() 4232 EXPECT_EQ(filecmp(getpid(), pid, memfd, fd), 0); in TEST() 4265 ASSERT_EQ(filecmp(getpid(), pid, memfd, fd), 0); in TEST() 4292 close(memfd); in TEST() 4299 int status, listener, memfd; in TEST() local [all …]
|
| /linux/tools/testing/selftests/ |
| H A D | Makefile | 62 TARGETS += memfd
|
| /linux/Documentation/arch/arm64/ |
| H A D | memory-tagging-extension.rst | 47 RAM-based file mappings (``tmpfs``, ``memfd``). Passing it to other
|
| /linux/Documentation/filesystems/ |
| H A D | proc.rst | 1136 as mlocked pages, ramfs backing pages, secret memfd pages etc.
|
| /linux/lib/ |
| H A D | Kconfig.debug | 2891 that support live update (such as the memfd handler).
|
| /linux/Documentation/virt/kvm/ |
| H A D | api.rst | 8398 ``MAP_ANONYMOUS`` or with a RAM-based file mapping (``tmpfs``, ``memfd``),
|