Linux EXT4 FS development
 help / color / mirror / Atom feed
From: Kitae Yoo <kitaeyoo777@gmail.com>
To: Jan Kara <jack@suse.com>
Cc: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org,
	linux-kernel@vger.kernel.org, Kitae Yoo <kitaeyoo777@gmail.com>
Subject: [RFC PATCH 2/2] quota_v2: persist DQF_ROOT_SQUASH
Date: Fri, 14 Aug 2026 20:46:49 +0900	[thread overview]
Message-ID: <20260814114649.51253-3-kitaeyoo777@gmail.com> (raw)
In-Reply-To: <20260814114649.51253-1-kitaeyoo777@gmail.com>

Commit c119c5b9749e ("quota: Don't store flags for v2 quota format")
stopped persisting dqi_flags because no v2 flag was supported and
on-disk flags could contain unvalidated garbage. Now that
DQF_ROOT_SQUASH is settable on v2, losing it across quotaoff/quotaon or
remount would silently re-enable the CAP_SYS_RESOURCE exemption - a poor
property for an enforcement policy.

Store the flag in the existing on-disk dqi_flags field and mask on read
so only the supported flag is ever accepted from disk, which also keeps
pre-existing garbage bits out of the in-memory flags.

An older kernel rewriting quota info still clears the stored flag;
strict enforcement then needs to be set up again after booting back.

Signed-off-by: Kitae Yoo <kitaeyoo777@gmail.com>
---
 fs/quota/quota_v2.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/quota/quota_v2.c b/fs/quota/quota_v2.c
index a24fab5f9f..814db61681 100644
--- a/fs/quota/quota_v2.c
+++ b/fs/quota/quota_v2.c
@@ -142,8 +142,7 @@ static int v2_read_file_info(struct super_block *sb, int type)
 	}
 	info->dqi_bgrace = le32_to_cpu(dinfo.dqi_bgrace);
 	info->dqi_igrace = le32_to_cpu(dinfo.dqi_igrace);
-	/* No flags currently supported */
-	info->dqi_flags = 0;
+	info->dqi_flags = le32_to_cpu(dinfo.dqi_flags) & DQF_ROOT_SQUASH;
 	qinfo->dqi_sb = sb;
 	qinfo->dqi_type = type;
 	qinfo->dqi_blocks = le32_to_cpu(dinfo.dqi_blocks);
@@ -209,8 +208,7 @@ static int v2_write_file_info(struct super_block *sb, int type)
 	info->dqi_flags &= ~DQF_INFO_DIRTY;
 	dinfo.dqi_bgrace = cpu_to_le32(info->dqi_bgrace);
 	dinfo.dqi_igrace = cpu_to_le32(info->dqi_igrace);
-	/* No flags currently supported */
-	dinfo.dqi_flags = cpu_to_le32(0);
+	dinfo.dqi_flags = cpu_to_le32(info->dqi_flags & DQF_ROOT_SQUASH);
 	spin_unlock(&dq_data_lock);
 	dinfo.dqi_blocks = cpu_to_le32(qinfo->dqi_blocks);
 	dinfo.dqi_free_blk = cpu_to_le32(qinfo->dqi_free_blk);
-- 
2.50.1 (Apple Git-155)


  parent reply	other threads:[~2026-08-14 11:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-14 11:46 [RFC PATCH 0/2] quota: opt-in strict enforcement of project quota hard limits Kitae Yoo
2026-08-14 11:46 ` [RFC PATCH 1/2] quota: allow DQF_ROOT_SQUASH on all quota formats Kitae Yoo
2026-08-14 12:01   ` sashiko-bot
2026-08-14 11:46 ` Kitae Yoo [this message]
2026-08-14 11:56   ` [RFC PATCH 2/2] quota_v2: persist DQF_ROOT_SQUASH sashiko-bot

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=20260814114649.51253-3-kitaeyoo777@gmail.com \
    --to=kitaeyoo777@gmail.com \
    --cc=jack@suse.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox