From nobody Sun Feb 8 11:59:29 2026 Received: from mail-oi1-f176.google.com (mail-oi1-f176.google.com [209.85.167.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C542A1DB13A for ; Sat, 17 Jan 2026 16:16:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768666571; cv=none; b=HmOFQ6UfdiXu6Wux42i+AOnfc04VexB5GafFx+7LRnpBbx3SQb+cW62QgGm/Cv+ihzcXOGnx1VTy7OHJhPu46O3ajhMkOe1MxgmMwixCp6B4i4IkTqvap76zzF1X272K1WLBMWsiUNdJfSn07ve/BX5n6DRJBGwMEmuQm4oyryg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768666571; c=relaxed/simple; bh=kqsWGBi7aFaKn4j7ZKU2sOBmJ/v+V/IyBmmnUMb69YU=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=d1n5y65ofstQPgs3HGZLvKY/IBRd6KAnXOtRRtM54zPsbAEdhgSZ6Rz1X3C+822e8+7TfFIiT2+a2VNHbE89Ryjj4QCGwhrVBAMEx91Xyzc3d53jsKq9D/Hgn0QxA6/sH0AXhJM79uBIehbL6NLg2sa3I5Cc6TvUrWPcftlcvUQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=aFYrMjfv; arc=none smtp.client-ip=209.85.167.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aFYrMjfv" Received: by mail-oi1-f176.google.com with SMTP id 5614622812f47-45c7f550f46so1865330b6e.3 for ; Sat, 17 Jan 2026 08:16:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768666569; x=1769271369; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=GWYOEspW5ofWF4XAspbiJ5804SDbjjJLvHgQw815IaY=; b=aFYrMjfvHvULSN+hOR/5VeGh90ZQtcP0fx+hdBoi3rMPmhadmQUmyfV4Bt1wWhxFaG uHt7UVi88PRX4mwb6oeM2/lcLbDTGB0DxtD79fmczapBjS8hUlJ4feJwipSz+lBw/eH9 In5hyLVgKSXJPiEFyngipybPz2aUpyajjFmemCaZWg46GKJ92jaFv+SdPDoGGVKUToTL klxAtdQ6ghLL5I4janJF1qHtWJGCA3GDKBDmcDSw8OVufSdMNdqyKUzLkGRSf1Y5oqf1 P1LP8Gp8tFczpSeuAiM+Z6+FJy96BkcPr7KZR0DH66mBx9AWsnsLWUNic1cOoauZl321 d8ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768666569; x=1769271369; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=GWYOEspW5ofWF4XAspbiJ5804SDbjjJLvHgQw815IaY=; b=gkVNJS3edPYlOahUEospc0lQtta/Qw5LvVNggDUGw+K062LW1ulgwKRo14rGougPq5 BsR3y5+TZ++PuOIMj+7xCPT2MXpzCCmyl38pnTq9UyVpxkx+Exhhx0U4BSLFoOwHEZtD K8CHi4CuPMwBdW4LtDdIJYtUOnlzbZB95C+aHvpnc5De0F2kJRBeqHxs/7x9p73H/bo/ 90vjqYuiffwOjeuzm4Yf/TBuajPK7lDJMj3IDwzkluEoUUJS4XIb6GQX4IGls2P4BqnO 77IK1RO9xsdfrfVpJi8RebkedlRV7z3PClRBQ6PFOwRD+30col67TGACXoEfmFOmhmZJ Crmw== X-Forwarded-Encrypted: i=1; AJvYcCV/xnIp5uhPjwx08N5Qy3Brq5b9bLBN8DuJPiJtkDNLeFxMJqzxd1JgG46dqoor/qHMyItRgRpTzD+s0kw=@vger.kernel.org X-Gm-Message-State: AOJu0YwHHCTEpI1iCdTaWMYj2xMGwmgPMArF2YIywAIWU+RtfV7hn+tS Irb0nOkr2R7O07B4+kwGae3r3Jk+IVfOSrcVKi6qL09ltM5yn6uVuqz8 X-Gm-Gg: AY/fxX74eNyens1b+7b/bFU8QGf6NXhRGXmbY0xE7KLMGir4E+IQM1uEYjPP/rljdXH jfFogEDcTYALyH5Ov3L274f1SXNjzP8wzAngy22sNsEHRLPBSRePyRWjx3CJihI1PLRgl7y/2hQ qIBG/n3XMNvRH0q+a6BpkG4rxbjd/d/Wt+ZLd79VQZurv0l4J0snYT7cD/SE7KjwlO9CIxuF879 41PWJ7rxEewnacL0mco6vnCNS2l0TsbEh3fbdbaqrpHctYNbHyJFmgSAFUuzcyCoyvQEHMYMufy oFd7oWKBJe/e5YXhdqBSmNT432/7uqjMzHWOcwxCuXV6gS9En2Bok/1l4/IldfDzGAEdcw8is3T E6L1WyZMQuEATE1qGNiN7FDo0La85p0Rh2IvDcWKcjF7za1B4p7j/E/t+qpQWbbRHbK12mv+Lda 5kS2quT5C7icxRzmypPAKgJelA2zGqFd25 X-Received: by 2002:a05:6808:5398:b0:450:d120:fe4e with SMTP id 5614622812f47-45c9bf7abacmr2747719b6e.27.1768666568696; Sat, 17 Jan 2026 08:16:08 -0800 (PST) Received: from newman.cs.purdue.edu ([128.10.127.250]) by smtp.gmail.com with ESMTPSA id 5614622812f47-45c9e03e817sm2994610b6e.16.2026.01.17.08.16.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Jan 2026 08:16:07 -0800 (PST) From: Jiasheng Jiang To: Mark Fasheh , Joel Becker , Joseph Qi , linux-kernel@vger.kernel.org Cc: ocfs2-devel@lists.linux.dev, Jiasheng Jiang Subject: [PATCH] ocfs2: fix NULL pointer dereference in ocfs2_get_refcount_rec Date: Sat, 17 Jan 2026 16:16:05 +0000 Message-Id: <20260117161605.30291-1-jiashengjiangcool@gmail.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In ocfs2_get_refcount_rec(), the 'rec' pointer is initialized to NULL. If the extent list is empty (el->l_next_free_rec =3D=3D 0), the loop skips assignment, leaving 'rec' as NULL and 'found' as 0. Currently, the code skips the 'if (found)' block but proceeds directly to dereference 'rec' at line 767 (le64_to_cpu(rec->e_blkno)), causing a NULL pointer dereference panic. This patch adds an 'else' branch to the 'if (found)' check. If no valid record is found, it reports a filesystem error and exits, preventing the invalid memory access. Signed-off-by: Jiasheng Jiang --- fs/ocfs2/refcounttree.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c index c92e0ea85bca..464bdd6e0a8e 100644 --- a/fs/ocfs2/refcounttree.c +++ b/fs/ocfs2/refcounttree.c @@ -1122,6 +1122,11 @@ static int ocfs2_get_refcount_rec(struct ocfs2_cachi= ng_info *ci, =20 if (cpos_end < low_cpos + len) len =3D cpos_end - low_cpos; + } else { + ret =3D ocfs2_error(sb, "Refcount tree %llu has no extent record coverin= g cpos %u\n", + (unsigned long long)ocfs2_metadata_cache_owner(ci), + low_cpos); + goto out; } =20 ret =3D ocfs2_read_refcount_block(ci, le64_to_cpu(rec->e_blkno), --=20 2.25.1