[RFC PATCH v2 17/41] quota: don't account UUID and GUID owners
Jan Koester
jan.koester at tuxist.de
Wed Oct 21 03:15:37 UTC 2026
Quota files and the quotactl interface use 32 bit ids. dqget() would
hash and store a UUID or GUID owner as -1, so all of them would share
one dquot, written out as id 4294967295.
Treat such ids like quota being off for them: dqget() returns -ESRCH,
which its callers already handle by not charging the inode. An inode
given to such an owner stays charged to the previous one.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jan Koester <jan.koester at tuxist.de>
---
fs/quota/dquot.c | 3 +++
include/linux/quota.h | 18 ++++++++++++++++++
2 files changed, 21 insertions(+)
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 1c78c695d0..62f333f824 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -954,6 +954,9 @@ struct dquot *dqget(struct super_block *sb, struct kqid qid)
if (!qid_has_mapping(sb->s_user_ns, qid))
return ERR_PTR(-EINVAL);
+ /* Quota files hold 32 bit ids: like quota off for UUIDs and GUIDs */
+ if (!qid_is_legacy(qid))
+ return ERR_PTR(-ESRCH);
if (!sb_has_quota_active(sb, qid.type))
return ERR_PTR(-ESRCH);
diff --git a/include/linux/quota.h b/include/linux/quota.h
index 89a0d83dda..00685209fd 100644
--- a/include/linux/quota.h
+++ b/include/linux/quota.h
@@ -80,6 +80,24 @@ extern qid_t from_kqid(struct user_namespace *to, struct kqid qid);
extern qid_t from_kqid_munged(struct user_namespace *to, struct kqid qid);
extern bool qid_valid(struct kqid qid);
+/**
+ * qid_is_legacy - Report if a kqid fits the 32 bit ids of quota files
+ * @qid: The kernel internal quota identifier to test.
+ *
+ * UUID and GUID owners don't, and are not subject to quotas.
+ */
+static inline bool qid_is_legacy(struct kqid qid)
+{
+ switch (qid.type) {
+ case USRQUOTA:
+ return uid_is_legacy(qid.uid);
+ case GRPQUOTA:
+ return gid_is_legacy(qid.gid);
+ default:
+ return true;
+ }
+}
+
/**
* make_kqid - Map a user-namespace, type, qid tuple into a kqid.
* @from: User namespace that the qid is in
--
2.56.0
More information about the Linux-security-module-archive
mailing list