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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tencent_DB74336E9E1D1B304BFF1B3F25DBBAA6BB08@qq.com>
Date: Wed, 31 Jul 2024 09:35:56 +0800
From: Edward Adam Davis <eadavis@...com>
To: kent.overstreet@...ux.dev
Cc: eadavis@...com,
	linux-bcachefs@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	syzbot+05d7520be047c9be86e0@...kaller.appspotmail.com,
	syzkaller-bugs@...glegroups.com
Subject: [PATCH V2] bcachefs: Add checks for entry's _data bytes

syzbot report slab-out-of-bounds in journal_entry_dev_usage_to_text,
it because vstruct_bytes(entry) smaller than sizeof(struct
jset_entry_dev_usage), overflow occurs when calculating the difference in
jset_entry_dev_usage_nr_types(u).

Reported-by: syzbot+05d7520be047c9be86e0@...kaller.appspotmail.com
Signed-off-by: Edward Adam Davis <eadavis@...com>
---
 fs/bcachefs/bcachefs_format.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/fs/bcachefs/bcachefs_format.h b/fs/bcachefs/bcachefs_format.h
index e3b1bde489c3..d536da101e89 100644
--- a/fs/bcachefs/bcachefs_format.h
+++ b/fs/bcachefs/bcachefs_format.h
@@ -1252,6 +1252,11 @@ struct jset_entry_dev_usage {
 
 static inline unsigned jset_entry_dev_usage_nr_types(struct jset_entry_dev_usage *u)
 {
+	if (vstruct_bytes(&u->entry) < sizeof(struct jset_entry_dev_usage)) {
+		pr_info("entry data bytes %u is too small", vstruct_bytes(&u->entry));
+		return 0;
+	}
+
 	return (vstruct_bytes(&u->entry) - sizeof(struct jset_entry_dev_usage)) /
 		sizeof(struct jset_entry_dev_usage_type);
 }
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ