From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794591065; b=K2Z10KazEF6YMZnK5finommXIVG7AZghzeA8R8iOGyiZHflTXikGRXMJ0dgEuTmqvddH EgSc4nvz4S5NHalxFAKfegTKsDXhtXS1do3e/CgR1z9WdqXoAoH1RtYUN/6pKKXzgT6rk uT9OFhwXgJiYX7MbuVGfG2DoJ7Zg+yDFwWQDWdz+8Fhq9RGpK5GE/smGONSuDluGdn2Od LdjHY5gGeUXVr4MNpaywABGWiwbI/Nl9xRB122GCd1hfKe34mNjHzNvt7lsVrvtj9j3dB Wbcg7udsXRYKsMOCzSD0HOBNRFtNScCEli3rjaUNJbJ3/lVZCmKeD58PZppeeKFjPMA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794591065; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=jh+v9g8FLoNpkvj/8xhSzjKg6TsBF2DHXaNeSWAGnWg=; b=YYyebMwWXmpwHmGxqBwXay4o3TNas43pv+jsB428M+ZeDBX7GXgUh2or9bK+61EYyej1 qVDDe2jwUf4qx7bXNxRisIdaMhh9B+dgxBLD8CJZmJBs3emoH1Y/T4Pzn9oFvApV+p82w ObaDi4AwAlbwd9nqN+bIq9kR7VsnvuuLfox/8UcIwiVjDiOx8zZX5AiRlaMxOUpS53adX R25Inz2V4E2M3hQNxE0cSzfiuK5fD9GcNOd99aA+7JwicvPy26bYznnulApRkTZXPyx8s yqO57dL51BFoK2wRpr3/mUMGwoFV16TnfYvw8f5b7jQbOTI2Yv14zsfzd8cZbOvLSdw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=MBsHIr42; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BCE54606B35A; Fri, 13 Nov 2026 17:31:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=MBsHIr42 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 690341F000C4; Fri, 13 Nov 2026 17:31:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1794591065; bh=jh+v9g8FLoNpkvj/8xhSzjKg6TsBF2DHXaNeSWAGnWg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=MBsHIr42a0/HYTXPALixpzg2TIDixm9MXiAihSCOE2uNDBZzXt33G94/hznJTlH3+ qtG0s6yIZQ8WKB/OTpW/sAWL9VCbaZKfTqlKDLPp8/tfxDrGbZeKa2y1B4DTUV4HNk UxODeV7Z81FTBhtWR7fRWLY5cF8qkLj19234f+Cs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Josef Bacik , Jan Kara , "Gregory Price (Meta)" , "David Hildenbrand (Arm)" , Sasha Levin Subject: [PATCH 6.12 224/670] tmpfs: preserve explicitly disabled quota limits Date: Fri, 13 Nov 2026 10:46:28 -0500 Message-ID: <20261113153819.473088580@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261113153811.177190860@linuxfoundation.org> References: <20261113153811.177190860@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Josef Bacik [ Upstream commit d5d861ee303da01e59fdf8e8b2f7096c76e7efd5 ] An administrator’s decision to disable a user’s or group’s quota limits can be silently lost when tmpfs restores the mount defaults after releasing and reacquiring the quota record. This can cause later file creation or writes to fail with EDQUOT, even though the administrator has explicitly disabled quota limits for the user or group. do_set_dqblk() sets DQ_FAKE_B when all block and inode limits are zero. This means quota enforcement is disabled for that user or group. shmem_is_empty_dquot() treats the flag as a reason to discard the entry from the mount's quota tree. The next shmem_acquire_dquot() finds no saved entry and recreates it with the mount's default hard limits. If the cached dquot is reused, DQ_FAKE_B remains set: Q_GETQUOTA reports the restored defaults, but enforcement is still disabled. Once that dquot has been reclaimed, a new dquot enforces the restored defaults. Remove the DQ_FAKE_B test. Only discard entries with zero usage, zero soft limits and hard limits equal to the mount defaults. Explicitly disabled limits are then preserved whenever the mount defaults are nonzero. Explicitly disabled limits now retain a quota-tree entry, just like other limits that differ from the mount defaults. Rename shmem_is_empty_dquot() to shmem_is_default_dquot() to describe the check for default values. Fix generated by an LLM and sent by Josef Bacik in private. Fixes: de4c0e7ca8b5 ("shmem: Add default quota limit mount options") Cc: stable@vger.kernel.org Signed-off-by: Josef Bacik Reviewed-by: Jan Kara Tested-by: Gregory Price (Meta) [ david: code cleanups; rewrite description ] Link: https://patch.msgid.link/20261029-fixes_shmem-v4-3-392fc715d8f6@kernel.org Signed-off-by: David Hildenbrand (Arm) Signed-off-by: Sasha Levin --- mm/shmem_quota.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/mm/shmem_quota.c b/mm/shmem_quota.c index a359e8cceedb4..868b3e05f1aa8 100644 --- a/mm/shmem_quota.c +++ b/mm/shmem_quota.c @@ -234,7 +234,7 @@ static int shmem_acquire_dquot(struct dquot *dquot) return ret; } -static bool shmem_is_empty_dquot(struct dquot *dquot) +static bool shmem_is_default_dquot(struct dquot *dquot) { struct shmem_sb_info *sbinfo = dquot->dq_sb->s_fs_info; qsize_t bhardlimit; @@ -248,21 +248,21 @@ static bool shmem_is_empty_dquot(struct dquot *dquot) ihardlimit = sbinfo->qlimits.grpquota_ihardlimit; } - if (test_bit(DQ_FAKE_B, &dquot->dq_flags) || - (dquot->dq_dqb.dqb_curspace == 0 && - dquot->dq_dqb.dqb_curinodes == 0 && - dquot->dq_dqb.dqb_bsoftlimit == 0 && - dquot->dq_dqb.dqb_isoftlimit == 0 && - dquot->dq_dqb.dqb_bhardlimit == bhardlimit && - dquot->dq_dqb.dqb_ihardlimit == ihardlimit)) - return true; - - return false; + /* + * Defaults are zero usage and soft limits, and the mount's hard limits. + * DQ_FAKE_B only means that *all* limits are zero, which need not match + * the mount defaults. + */ + return dquot->dq_dqb.dqb_curspace == 0 && + dquot->dq_dqb.dqb_curinodes == 0 && + dquot->dq_dqb.dqb_bsoftlimit == 0 && + dquot->dq_dqb.dqb_isoftlimit == 0 && + dquot->dq_dqb.dqb_bhardlimit == bhardlimit && + dquot->dq_dqb.dqb_ihardlimit == ihardlimit; } /* - * Store limits from dquot in the tree unless it's fake. If it is fake - * remove the id from the tree since there is no useful information in - * there. + * Remove the ID from the tree if it has no usage and its limits match + * the mount defaults. Otherwise, save its limits for the next acquire. */ static int shmem_release_dquot(struct dquot *dquot) { @@ -297,7 +297,7 @@ static int shmem_release_dquot(struct dquot *dquot) return -ENOENT; found: - if (shmem_is_empty_dquot(dquot)) { + if (shmem_is_default_dquot(dquot)) { /* Remove entry from the tree */ rb_erase(&entry->node, info->dqi_priv); kfree(entry); -- 2.53.0