lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20250304040311.2081-1-vulab@iscas.ac.cn>
Date: Tue,  4 Mar 2025 12:03:11 +0800
From: Wentao Liang <vulab@...as.ac.cn>
To: kent.overstreet@...ux.dev
Cc: linux-bcachefs@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	Wentao Liang <vulab@...as.ac.cn>
Subject: [PATCH] bcachefs: Add error handling for bch2_folio()

Add error handling for the case where bch2_folio() returns NULL
in __bch2_folio_set(). Return immediately to prevent null pointer
dereference.

Signed-off-by: Wentao Liang <vulab@...as.ac.cn>
---
 fs/bcachefs/fs-io-pagecache.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/bcachefs/fs-io-pagecache.c b/fs/bcachefs/fs-io-pagecache.c
index e072900e6a5b..1dc65fef3ff4 100644
--- a/fs/bcachefs/fs-io-pagecache.c
+++ b/fs/bcachefs/fs-io-pagecache.c
@@ -159,6 +159,9 @@ static void __bch2_folio_set(struct folio *folio,
 	struct bch_folio *s = bch2_folio(folio);
 	unsigned i, sectors = folio_sectors(folio);
 
+	if (!s)
+		return;
+
 	BUG_ON(pg_offset >= sectors);
 	BUG_ON(pg_offset + pg_len > sectors);
 
-- 
2.42.0.windows.2


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ