mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/6] fs: fixes for statmount() short buffers and listmount()/listns() cursors
@ 2026-10-21 11:46 Christian Brauner
  2026-10-21 11:46 ` [PATCH 1/6] statmount: don't copy the reserved empty string past the buffer Christian Brauner
                   ` (6 more replies)
  0 siblings, 7 replies; 14+ messages in thread
From: Christian Brauner @ 2026-10-21 11:46 UTC (permalink / raw)
  To: linux-fsdevel
  Cc: Alexander Viro, Jan Kara, Miklos Szeredi, Jeff Layton, shaos,
	linux-kernel, stable, Christian Brauner (Amutable)

shaos reported two issues in [1] and [2]. Both are real.

- statmount() reserves the empty string in the seq buffer before a
  handler runs but the early return for "nothing emitted" never checks
  that byte against the caller's buffer. So ask for STATMOUNT_MNT_UIDMAP
  on a mount that isn't idmapped with a buffer smaller than struct
  statmount and we write one zero byte past the buffer. It's the
  caller's own memory but that's still not ok. I'm fixing this in
  prepare_kstatmount() where the exact-size check already lives so that
  unset strings keep pointing at an empty string.

- listmount() and listns() add one to the cursor before they look up
  the next entry. With U64_MAX that wraps to zero and the listing starts
  over. No real cursor can ever be U64_MAX so this only bites callers
  that make up cursors but it's still wrong.

All three come with selftests. I've tagged the two cursor fixes for
stable as well since they're trivial but I don't feel strongly about
that.

[1]: https://lore.kernel.org/r/20261020110747.959829-1-shawnq1@163.com
[2]: https://lore.kernel.org/r/20261020110732.959552-1-shawnq1@163.com

---
Christian Brauner (6):
      statmount: don't copy the reserved empty string past the buffer
      selftests/filesystems: check short buffers for statmount() strings
      listmount: don't wrap around with a U64_MAX cursor
      selftests/filesystems: check listmount() with a U64_MAX cursor
      listns: don't wrap around with a U64_MAX cursor
      selftests/namespaces: check listns() with a U64_MAX cursor

 fs/namespace.c                                     |  5 +-
 kernel/nstree.c                                    | 29 ++++------
 .../filesystems/statmount/listmount_test.c         | 11 ++++
 .../filesystems/statmount/statmount_test.c         | 61 +++++++++++++++++++++-
 tools/testing/selftests/namespaces/listns_test.c   | 34 ++++++++++++
 5 files changed, 120 insertions(+), 20 deletions(-)
---
base-commit: 08a7d685fc611140f5d4244abef522b71900c563
change-id: 20261021-work-mount-statmount_listns_fixes-03b0604d7341


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2026-10-21 15:30 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-21 11:46 [PATCH 0/6] fs: fixes for statmount() short buffers and listmount()/listns() cursors Christian Brauner
2026-10-21 11:46 ` [PATCH 1/6] statmount: don't copy the reserved empty string past the buffer Christian Brauner
2026-10-21 11:52   ` Jeff Layton
2026-10-21 15:18   ` Jan Kara
2026-10-21 11:46 ` [PATCH 2/6] selftests/filesystems: check short buffers for statmount() strings Christian Brauner
2026-10-21 11:46 ` [PATCH 3/6] listmount: don't wrap around with a U64_MAX cursor Christian Brauner
2026-10-21 11:52   ` Jeff Layton
2026-10-21 15:25   ` Jan Kara
2026-10-21 11:46 ` [PATCH 4/6] selftests/filesystems: check listmount() " Christian Brauner
2026-10-21 11:46 ` [PATCH 5/6] listns: don't wrap around " Christian Brauner
2026-10-21 11:55   ` Jeff Layton
2026-10-21 15:29   ` Jan Kara
2026-10-21 11:46 ` [PATCH 6/6] selftests/namespaces: check listns() " Christian Brauner
2026-10-21 13:18 ` [PATCH 0/6] fs: fixes for statmount() short buffers and listmount()/listns() cursors Christian Brauner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®