All of lore.kernel.org
 help / color / mirror / Atom feed
* + tmpfs-ramfs-let-memfd_create-work-on-nommu.patch added to mm-nonmm-unstable branch
@ 2026-06-30  3:59 Andrew Morton
  0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2026-06-30  3:59 UTC (permalink / raw)
  To: mm-commits, viro, ljs, liam, brauner, daniel, akpm


The patch titled
     Subject: tmpfs/ramfs: let memfd_create() work on nommu
has been added to the -mm mm-nonmm-unstable branch.  Its filename is
     tmpfs-ramfs-let-memfd_create-work-on-nommu.patch

This patch will shortly appear at
     https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/tmpfs-ramfs-let-memfd_create-work-on-nommu.patch

This patch will later appear in the mm-nonmm-unstable branch at
    git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days

------------------------------------------------------
From: Daniel Palmer <daniel@thingy.jp>
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.

Link: https://lore.kernel.org/20260523130445.1101818-1-daniel@thingy.jp
Signed-off-by: Daniel Palmer <daniel@thingy.jp>
Acked-by: Lorenzo Stoakes <ljs@kernel.org>
Cc: "Liam R. Howlett" <liam@infradead.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Christian Brauner <brauner@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 fs/ramfs/file-nommu.c |    3 +++
 1 file changed, 3 insertions(+)

--- a/fs/ramfs/file-nommu.c~tmpfs-ramfs-let-memfd_create-work-on-nommu
+++ a/fs/ramfs/file-nommu.c
@@ -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 daniel@thingy.jp are

tmpfs-ramfs-let-memfd_create-work-on-nommu.patch


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-06-30  3:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-30  3:59 + tmpfs-ramfs-let-memfd_create-work-on-nommu.patch added to mm-nonmm-unstable branch Andrew Morton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.