Skip to contentSkip to conversation

tmpfs-ramfs-let-memfd_create-work-on-nommu.patch removed from -mm tree

merged mm-stable Andrew Morton 1 participant 1 message Aug 25

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: tmpfs/ramfs: let memfd_create() work on nommu
has been removed from the -mm tree. Its filename was
tmpfs-ramfs-let-memfd_create-work-on-nommu.patch

This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Daniel Palmer <[email protected]>
Subject: tmpfs/ramfs: let memfd_create() work on nommu
Date: Sat, 23 May 2026 22:04:45 +0900

Currently trying to use memfd_create() on nommu returns an error with errno set to EFBIG. The manpage memfd_create() doesn't have EFBIG as a possible error value.

Doing some digging this is coming from 0 getting passed as newsize to ramfs_nommu_expand_for_mapping() and that getting into get_order() and there "The result is undefined if the size is 0".

Whatever comes out of get_order() is then used in the following logic and that results in the EFBIG that causes the syscall to fail and the errno in userspace.

If newsize is 0 there is nothing to do so just return.

Roughly tested on m68k nommu by creating a process, creating an memfd, forking another process, mmap()ing the memfd in the child, writing into the mapping, then mmap()ing in the parent and checking that the right data is there.

---

 fs/ramfs/file-nommu.c |    3 +++
 1 file changed, 3 insertions(+)
fs/ramfs/file-nommu.c renamed from fs/ramfs/file-nommu.c~tmpfs-ramfs-let-memfd_create-work-on-nommu +3 -0
@@ -69,6 +69,9 @@ int ramfs_nommu_expand_for_mapping(struc
 	gfp_t gfp = mapping_gfp_mask(inode->i_mapping);
 
 	/* make various checks */
+	if (!newsize)
+		return 0;
+
 	order = get_order(newsize);
 	if (unlikely(order > MAX_PAGE_ORDER))
 		return -EFBIG;

_

Patches currently in -mm which might be from [email protected] are