mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/2] f2fs: zero preallocated blocks of pinned files for unprivileged users
@ 2026-12-05  2:21 Hungyu Lin
  2026-12-05  2:21 ` [PATCH v2 1/2] f2fs: fix to avoid pinfile fragment on checkpoint=disable mode Hungyu Lin
  2026-12-05  2:21 ` [PATCH v2 2/2] f2fs: zero preallocated blocks of pinned files for unprivileged users Hungyu Lin
  0 siblings, 2 replies; 3+ messages in thread
From: Hungyu Lin @ 2026-12-05  2:21 UTC (permalink / raw)
  To: jaegeuk, chao; +Cc: lizhijun3, linux-f2fs-devel, linux-kernel, dennylin0707

fallocate() on a pinned file hands out blocks without zeroing them, and
any user can pin a file, so any user can read back data of files that
other users have deleted. v1 required CAP_SYS_ADMIN for fallocate() on a
pinned file. This version zeroes the blocks for callers without
CAP_SYS_ADMIN instead, so that they can still preallocate.

Patch 1 keeps the pinned log from switching to SSR while checkpoint is
disabled. It is a fix on its own, and patch 2 needs it: the blocks are
zeroed one section at a time before they are allocated, which relies on
the pinned log staying in its section.

Patch 2 zeroes the free blocks of the pinning section.
f2fs_secure_erase() is not used, as it works on blocks which are already
mapped to the file. The blocks are zeroed on the device, so an encrypted
pinned file reads them back as the decryption of zeroes.

Changes since v1:
- Zero the blocks for callers without CAP_SYS_ADMIN instead of refusing
  fallocate(), as suggested by Chao Yu. They are zeroed before the
  allocation rather than after it, so that a concurrent read cannot see
  the old data and the blocks which the file already had are kept.
- Add patch 1.

v1: https://lore.kernel.org/all/20261108075357.43331-1-dennylin0707@gmail.com/

Hungyu Lin (2):
  f2fs: fix to avoid pinfile fragment on checkpoint=disable mode
  f2fs: zero preallocated blocks of pinned files for unprivileged users

 fs/f2fs/f2fs.h    |  1 +
 fs/f2fs/file.c    |  3 +++
 fs/f2fs/segment.c | 40 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 44 insertions(+)


base-commit: 029b14ff22f28fddba992d58a216d30bda45586a
-- 
2.43.0


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

end of thread, other threads:[~2026-12-05  2:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-05  2:21 [PATCH v2 0/2] f2fs: zero preallocated blocks of pinned files for unprivileged users Hungyu Lin
2026-12-05  2:21 ` [PATCH v2 1/2] f2fs: fix to avoid pinfile fragment on checkpoint=disable mode Hungyu Lin
2026-12-05  2:21 ` [PATCH v2 2/2] f2fs: zero preallocated blocks of pinned files for unprivileged users Hungyu Lin

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®