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=1796156430; b=TRfXDk8Y+aJurNqepXVRuTrlm/9XeDXLIOXEcZnwdWLonlubVYeDSmyHd1lPWMD65Tg7 2HYqVfCNbTDXMrBc/+HJ9RCxRgTF8mlGZ3LrPQt92pEaP+jTRvpu08SuUBiGoO3DwC9Hm bSek2iua+roHw/OHQZjwOb9fpYr0CxXhqtZyK97/qofGdz1PqUTvlPR4msmNanIYn/oQF JO/BsH60FzRqO3Hnib0ig8sANYzGIpo4VCl7DJgminobNFHG7zs4uNRHBka+T9PT4IWi3 LVOFby3/GDeYNH78QbiZZFE5vLkXSG/pWr5vyHE9ikivQBaBOzCVAZ2VwPtv3nrjfJw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796156430; h=Received:DKIM-Signature:Date:To:From:In-Reply-To:References:Subject: Message-Id; bh=1wyFt+gNUziJ4UFlB1mDlf3et3ODv7KX5SOdAv8HQtY=; b=Y2IxeiVJeoHSJZUHtxs7JCYOiceCy3qPzvztXxdNxDSTMWT9jZBRNrEomScIPmHHl/Ip g7AhqEnIi9ve/OmlLl7r298EnUMzmp1WrizDxj8xSvWmVqYr5cUF9JxFs2tnEdKiJp8G8 Gp+JPhlagSPykrgGikDmZhJEVZ5hT9dWzgqcGMtKFmXfSiS9Hb4K4nW5WzlRVhoUSiKVG eZvUx6bEP+Fb1ozVws9bDwYpnRuPM1RYbFJBs/lFp2wTK3DZN8ryV1gmoLW/L0zhE+AiR RvDt52OCoBLDisbh2oiCd6Y6MYuD6C/hmbq0DUgE9qRWFq/xR4Q3bF7mxCETJJUytkw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=KbvJOJsf; 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 34139606A329; Tue, 1 Dec 2026 20:20:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=KbvJOJsf Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3980D1F00899; Tue, 1 Dec 2026 20:20:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1796156429; bh=1wyFt+gNUziJ4UFlB1mDlf3et3ODv7KX5SOdAv8HQtY=; h=Date:To:From:In-Reply-To:References:Subject; b=KbvJOJsf0sC6HkUMs5/6iwvpFwVWjZwiyxpqLlm1sdEiRyAocOVF1Ng97Akcvxbae BdOvSUadC0MID2HtcFHCHDL/IGpCnTrvH0gxzHr7JBDLbL/qcj+kllobuQSzrvm7GY gNSLyjnlOzlhCxuXVfL+qQ4w7Bt3ZzQsePSk4omg= Date: Tue, 01 Dec 2026 12:20:28 -0800 To: mm-commits@vger.kernel.org,stable@vger.kernel.org,mark@fasheh.com, joseph.qi@linux.alibaba.com,jlbec@evilplan.org,jack@suse.cz, heming.zhao@suse.com,zzjas98@gmail.com,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20261130-kbug-l1059-ocfs2-quota-v1-1-ea88bd28639b@gmail.com> References: <20261130-kbug-l1059-ocfs2-quota-v1-1-ea88bd28639b@gmail.com> Subject: + ocfs2-dont-free-a-null-chunk-in-ocfs2_local_quota_add_chunk.patch added to mm-nonmm-hotfixes-unstable branch Message-Id: <20261201202029.3980D1F00899@smtp.kernel.org> X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list The patch titled Subject: ocfs2: don't free a NULL chunk in ocfs2_local_quota_add_chunk() has been added to the -mm mm-nonmm-hotfixes-unstable branch. Its filename is ocfs2-dont-free-a-null-chunk-in-ocfs2_local_quota_add_chunk.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/ocfs2-dont-free-a-null-chunk-in-ocfs2_local_quota_add_chunk.patch This patch will later appear in the mm-nonmm-hotfixes-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via various branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there most days ------------------------------------------------------ From: Zijie Zhao Subject: ocfs2: don't free a NULL chunk in ocfs2_local_quota_add_chunk() Date: Mon, 30 Nov 2026 17:56:19 -0600 ocfs2_local_quota_add_chunk() allocates the in-memory chunk only after the local quota file has been extended. If ocfs2_extend_no_holes() or ocfs2_simple_size_update() fails, for example with -ENOSPC on a full filesystem, or if kmem_cache_alloc() fails, the function jumps to the out label with chunk still NULL. The out label then calls kmem_cache_free(ocfs2_qf_chunk_cachep, NULL). Unlike kfree(), kmem_cache_free() does not accept NULL. It calls virt_to_slab() on the pointer and reads the struct page derived from address 0. This can oops, or warn about freeing an object that is not from a slab page. Allocate the chunk before the file is extended and return right away if the allocation fails. Every jump to the out label then has a valid chunk to free. A failed allocation also no longer leaves the local quota file grown by two unused blocks. Found by a static analysis tool. The fix and this changelog were drafted with AI assistance (Claude Code, with a second review by OpenAI Codex), then reviewed by the submitter. Link: https://patch.msgid.link/20261130-kbug-l1059-ocfs2-quota-v1-1-ea88bd28639b@gmail.com Fixes: 9e33d69f553a ("ocfs2: Implementation of local and global quota file handling") Signed-off-by: Zijie Zhao Signed-off-by: Andrew Morton Reviewed-by: Joseph Qi Reviewed-by: Jan Kara Cc: Mark Fasheh Cc: Joel Becker Cc: Heming Zhao Cc: fs/ocfs2/quota_local.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) --- a/fs/ocfs2/quota_local.c~ocfs2-dont-free-a-null-chunk-in-ocfs2_local_quota_add_chunk +++ a/fs/ocfs2/quota_local.c @@ -1003,6 +1003,13 @@ static struct ocfs2_quota_chunk *ocfs2_l struct buffer_head *bh = NULL, *dbh = NULL; u64 p_blkno; + chunk = kmem_cache_alloc(ocfs2_qf_chunk_cachep, GFP_NOFS); + if (!chunk) { + status = -ENOMEM; + mlog_errno(status); + return ERR_PTR(status); + } + /* We are protected by dqio_sem so no locking needed */ status = ocfs2_extend_no_holes(lqinode, NULL, i_size_read(lqinode) + 2 * sb->s_blocksize, @@ -1018,12 +1025,6 @@ static struct ocfs2_quota_chunk *ocfs2_l goto out; } - chunk = kmem_cache_alloc(ocfs2_qf_chunk_cachep, GFP_NOFS); - if (!chunk) { - status = -ENOMEM; - mlog_errno(status); - goto out; - } /* Local quota info and two new blocks we initialize */ handle = ocfs2_start_trans(OCFS2_SB(sb), OCFS2_LOCAL_QINFO_WRITE_CREDITS + _ Patches currently in -mm which might be from zzjas98@gmail.com are ocfs2-dont-free-a-null-chunk-in-ocfs2_local_quota_add_chunk.patch