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=1795037560; b=1LGQcwUxU6AH0SXJgbaelS8t8LOzj88X+u7/+dkiBlICAj5HZrwbduAfx7ND2cllS35g LWF/NXTUMJNQ0Hy76LINYXs6ZtXetQDFd349ow8R3AFpdem7nnDNGSMNtmk/KFNiWppHp gkdKURLHRYwWuY7NDZ6eANrNJJKOUMkmtGmSJL57+/TgFgNwvHDFhECdIaFEAbcgnYN7q d8yYumQJjAh1/T+XFKvr5WfwujU70/1CBtBms+9OGLxTRqGD6eeUYpN70z8GA69FeC2Bg jk3zfYtZQWlebXt7dnGFw6rXn8m13sUeho/mUyomZYBIxPUJmCxUF+0oS5y8mH7hKFQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795037560; 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=XgKJctQvpyHJ3DqGXPZ4V6iShuV+kb8JHZ9xNwJOJAk=; b=cjDpSgBdyDeYaB/1QnkHEupnEH71t1grh6HCFICXIG/lyKLWllGPXBVXhVYFyJT43hBm tgf0uI7xJd9yH0OqNUcRcdSZWI2EvGuxECozodPU35vD0+k4SKAo+lWvxBhMASe4v66iS A9tM5E8yMfULwbLNZyOulJQbBMNSO9LDr4jPnRA5XRhNO/7uCZH1Qmb4vd7ZoUzb6WJbH m93CRTiy7bYKb0AYz/T4TBhZL5C5gBjgaYZ1O+y0fYmUWYAd2dQ1RIFaCAbDG1itkcjZg xO6r27/FCdzZwHV1VW38GfVZZ/kbgoVR3LP55W6JP1hLY/mAQKSWSant09iSfki6f3g== 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="kDlE/sA1"; 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 98B82606A325; Wed, 18 Nov 2026 21:32:40 +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=kDlE/sA1 Received: by smtp.kernel.org (Postfix) with ESMTPSA id EDFF51F000C4; Wed, 18 Nov 2026 21:32:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795037560; bh=XgKJctQvpyHJ3DqGXPZ4V6iShuV+kb8JHZ9xNwJOJAk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kDlE/sA1R57cmIfdcF1k3wTh1nV7o465iPeudztgQyIblEmrS4mh68aB2nZn9TPjD JLw0urshWjzdYI/KDROTef1OYkUCLJ5kedVBatAnANbNGfdPhbwr8E8wBB+FSY/bB9 4iERtDz6WCKy3RXolQfwHh6f2chCoH+JYfsYSRLI= 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.6 1441/3318] tmpfs: preserve explicitly disabled quota limits Date: Wed, 18 Nov 2026 15:34:23 +0100 Message-ID: <20261118150404.049518333@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150313.527275416@linuxfoundation.org> References: <20261118150313.527275416@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.6-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 23589d18a532a..1568829297451 100644 --- a/mm/shmem_quota.c +++ b/mm/shmem_quota.c @@ -236,7 +236,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; @@ -250,21 +250,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) { @@ -299,7 +299,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