From: Yifan Feng <evanfengff@gmail.com>
To: Hugh Dickins <hughd@google.com>,
David Hildenbrand <david@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>,
Gregory Price <gourry@gourry.net>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Yifan Feng <evanfengff@gmail.com>
Subject: [PATCH] tmpfs: escape the space in the mpol mount option
Date: Sat, 28 Nov 2026 15:37:47 -0800 [thread overview]
Message-ID: <20261128233747.60722-1-evanfengff@gmail.com> (raw)
The policy names "weighted interleave" and "prefer (many)" contain a
space, and shmem_show_mpol() prints the name as it is. Readers of
/proc/mounts take the space as the end of the options field, so
mount(8) reads back mpol=prefer and an unrelated remount replaces the
policy:
# mount -t tmpfs -o 'mpol=prefer (many):0-1' none /mnt
# mount -o remount,size=128M /mnt
# grep /mnt /proc/mounts
none /mnt tmpfs rw,relatime,size=131072k,inode64,mpol=local 0 0
With "weighted interleave" the same remount fails with EINVAL.
Escape the value like the other fields of the line, so that the space
is printed as \040.
Fixes: b27abaccf8e8 ("mm/mempolicy: add MPOL_PREFERRED_MANY for multiple preferred nodes")
Signed-off-by: Yifan Feng <evanfengff@gmail.com>
---
Tested in a 2-node NUMA QEMU guest with util-linux 2.33.1: findmnt and getmntent() show the whole policy, both remounts keep it, and the options read from /proc/mounts mount again to an identical line.
Found and written with the help of an AI coding assistant.
mm/shmem.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/mm/shmem.c b/mm/shmem.c
index a5713109c843..75f0223084a7 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -2045,7 +2045,8 @@ static void shmem_show_mpol(struct seq_file *seq, struct mempolicy *mpol)
mpol_to_str(buffer, sizeof(buffer), mpol);
- seq_printf(seq, ",mpol=%s", buffer);
+ seq_puts(seq, ",mpol=");
+ seq_escape(seq, buffer, " \t\n\\");
}
static struct mempolicy *shmem_get_sbmpol(struct shmem_sb_info *sbinfo)
base-commit: 822ba3a89c7896b26e4beb70e2ebffb881924dfe
--
2.39.3 (Apple Git-146)
next reply other threads:[~2026-11-28 23:38 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-28 23:37 Yifan Feng [this message]
2026-11-29 2:13 ` [PATCH] tmpfs: escape the space in the mpol mount option Andrew Morton
2026-11-30 2:09 ` Yifan Feng
2026-11-30 2:12 ` Andrew Morton
2026-11-30 11:13 ` David Hildenbrand (Arm)
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=20261128233747.60722-1-evanfengff@gmail.com \
--to=evanfengff@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=david@kernel.org \
--cc=gourry@gourry.net \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/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 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.