Re: [PATCH v2] tmpfs: escape the space in the mpol mount option

From: Baolin Wang

Date: Fri Dec 04 2026 - 03:51:46 EST




On 12/2/26 8:18 AM, Yifan Feng wrote:
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
# grep /mnt /proc/mounts
none /mnt tmpfs rw,relatime,inode64,mpol=prefer (many):0-1 0 0
# 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. The mount above is then shown as

none /mnt tmpfs rw,relatime,inode64,mpol=prefer\040(many):0-1 0 0

and keeps its policy over the remount.

Fixes: b27abaccf8e8 ("mm/mempolicy: add MPOL_PREFERRED_MANY for multiple preferred nodes")
Signed-off-by: Yifan Feng <evanfengff@xxxxxxxxx>
---

LGTM.
Reviewed-by: Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx>