From: Andrew Morton <akpm@linux-foundation.org>
To: Daniel Palmer <daniel@thingy.jp>
Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, Al Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>,
Lorenzo Stoakes <ljs@kernel.org>
Subject: Re: [PATCH] tmpfs/ramfs: Let memfd_create() work on nommu
Date: Mon, 29 Jun 2026 20:58:54 -0700 [thread overview]
Message-ID: <20260629205854.0062b1fc9588ba9928bb1707@linux-foundation.org> (raw)
In-Reply-To: <20260523130445.1101818-1-daniel@thingy.jp>
On Sat, 23 May 2026 22:04:45 +0900 Daniel Palmer <daniel@thingy.jp> wrote:
> 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.
>
Old patch, older code. Thanks.
> Really not sure if this is correct. It works for me but on
> nommu a lot of things just work because there is no MMU to
> shout about badness.
>
> Maybe shashiko will say this is a dumb patch and explain
> the proper fix. :)
Sashiko had no complaints but it seems to have found some unrelated
bugs:
https://sashiko.dev/#/patchset/20260523130445.1101818-1-daniel@thingy.jp
(tmpfs calls "ramfs_nommu" code. Who knew?)
> Also I had almost no idea who to send this to from the output
> of get_maintainer.pl.
I suspect most would prefer it's someone else, but this is viro/brauner
stuff, if anyone)
> --- a/fs/ramfs/file-nommu.c
> +++ b/fs/ramfs/file-nommu.c
> @@ -69,6 +69,9 @@ int ramfs_nommu_expand_for_mapping(struct inode *inode, size_t newsize)
> 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;
Oh well, thanks, I'll toss it onto the pile and see what happens.
next prev parent reply other threads:[~2026-06-30 3:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-23 13:04 [PATCH] tmpfs/ramfs: Let memfd_create() work on nommu Daniel Palmer
2026-05-28 13:02 ` Lorenzo Stoakes
2026-06-30 3:58 ` Andrew Morton [this message]
2026-07-08 11:46 ` Daniel Palmer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260629205854.0062b1fc9588ba9928bb1707@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=brauner@kernel.org \
--cc=daniel@thingy.jp \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox