mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hungyu Lin <dennylin0707@gmail.com>
To: jaegeuk@kernel.org, chao@kernel.org
Cc: lizhijun3@xiaomi.com, linux-f2fs-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org, dennylin0707@gmail.com
Subject: [PATCH v2 0/2] f2fs: zero preallocated blocks of pinned files for unprivileged users
Date: Sat,  5 Dec 2026 02:21:09 +0000	[thread overview]
Message-ID: <20261205022111.49900-1-dennylin0707@gmail.com> (raw)

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


             reply	other threads:[~2026-12-05  2:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-05  2:21 Hungyu Lin [this message]
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

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=20261205022111.49900-1-dennylin0707@gmail.com \
    --to=dennylin0707@gmail.com \
    --cc=chao@kernel.org \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizhijun3@xiaomi.com \
    /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

all inboxes | Powered by JetHome®