Skip to contentSkip to conversation

gfs2: fix NULL deref in gfs2_quota_lock() for meta inodes

PATCH Applied ThangNN99 2 participants 2 messages Sep 6 – Sep 8 GFS2 file system

lore
Share & tools
lore

ThangNN99

author
#0 lore raw

PATCH 1/1 gfs2: fix NULL deref in gfs2_quota_lock() for meta inodes

gfs2_quota_hold() now treats a meta/system inode's NULL i_qadata as success, but gfs2_quota_lock() still dereferences it unconditionally afterwards. Bail out early when there is nothing to lock.

Reported-by [email protected]
Fixes 0025112796287599dc79c822ed37124582a0d68a ("gfs2: No quotas for meta inodes")
---
 fs/gfs2/quota.c | 3 +++
 1 file changed, 3 insertions(+)
fs/gfs2/quota.c +3 -0
index 3bbe5c78c793..0c7ea7375f6c 100644
@@ -1100,6 +1100,9 @@ int gfs2_quota_lock(struct gfs2_inode *ip, kuid_t uid, kgid_t gid)
 	error = gfs2_quota_hold(ip, uid, gid);
 	if (error)
 		return error;
+	/* Meta inodes never get quota data (see gfs2_qa_get()); nothing to lock. */
+	if (!ip->i_qadata)
+		return 0;
 
 	sort(ip->i_qadata->qa_qd, ip->i_qadata->qa_qd_num,
 	     sizeof(struct gfs2_quota_data *), sort_qd, NULL);

--
2.43.0

maintainer Applied
#1 lore raw
Quoted 27 lines · On Sun, Sep 6, 2026 at 10:08 AM ThangNN99 <[email protected]> wrote:

gfs2_quota_hold() now treats a meta/system inode's NULL i_qadata as success, but gfs2_quota_lock() still dereferences it unconditionally afterwards. Bail out early when there is nothing to lock.

Reported-by [email protected]
Fixes 0025112796287599dc79c822ed37124582a0d68a ("gfs2: No quotas for meta inodes")
---
 fs/gfs2/quota.c | 3 +++
 1 file changed, 3 insertions(+)
fs/gfs2/quota.c +3 -1
index 3bbe5c78c793..0c7ea7375f6c 100644
@@ -1100,6 +1100,9 @@ int gfs2_quota_lock(struct gfs2_inode *ip, kuid_t uid, kgid_t gid)
        error = gfs2_quota_hold(ip, uid, gid);
        if (error)
                return error;
+       /* Meta inodes never get quota data (see gfs2_qa_get()); nothing to lock. */
+       if (!ip->i_qadata)
+               return 0;
 
        sort(ip->i_qadata->qa_qd, ip->i_qadata->qa_qd_num,
             sizeof(struct gfs2_quota_data *), sort_qd, NULL);
--
Quoted 2 lines

2.43.0

Applied, thanks.

Andreas