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: <20230307135740.13209-1-congmingyi@gmail.com>
Date:   Tue,  7 Mar 2023 21:57:40 +0800
From:   MIngyi Cong <congmingyi@...il.com>
To:     linkinjeon@...nel.org, senozhatsky@...omium.org, sfrench@...ba.org,
        tom@...pey.com
Cc:     congmingyi@...il.com, linux-kernel@...r.kernel.org,
        linux-cifs@...r.kernel.org
Subject: [PATCH v2] fs: add the tuncate check of hfs, exfat and hfsplus

HFS, EXFAT and HFSPLUS will fill zero data in truncated range.
Fix this by adding *_SUPER_MAGIC check.

Signed-off-by: MIngyi Cong <congmingyi@...il.com>
---
V1 -> V2: add the truncate check of hfs and remove EXFAT_SUPER_MAGIC in magic.h
 fs/ksmbd/smb2pdu.c         | 5 ++++-
 include/uapi/linux/magic.h | 2 ++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c
index 0685c1c77b9f..881a2b37fab0 100644
--- a/fs/ksmbd/smb2pdu.c
+++ b/fs/ksmbd/smb2pdu.c
@@ -5746,7 +5746,10 @@ static int set_end_of_file_info(struct ksmbd_work *work, struct ksmbd_file *fp,
 	 * truncate of some filesystem like FAT32 fill zero data in
 	 * truncated range.
 	 */
-	if (inode->i_sb->s_magic != MSDOS_SUPER_MAGIC) {
+	if (inode->i_sb->s_magic != MSDOS_SUPER_MAGIC ||
+		inode->i_sb->s_magic != EXFAT_SUPER_MAGIC ||
+		inode->i_sb->s_magic != HFSPLUS_SUPER_MAGIC ||
+		inode->i_sb->s_magic != HFS_SUPER_MAGIC) {
 		ksmbd_debug(SMB, "truncated to newsize %lld\n", newsize);
 		rc = ksmbd_vfs_truncate(work, fp, newsize);
 		if (rc) {
diff --git a/include/uapi/linux/magic.h b/include/uapi/linux/magic.h
index 6325d1d0e90f..db2c81755025 100644
--- a/include/uapi/linux/magic.h
+++ b/include/uapi/linux/magic.h
@@ -46,6 +46,8 @@
 
 #define MSDOS_SUPER_MAGIC	0x4d44		/* MD */
 #define EXFAT_SUPER_MAGIC	0x2011BAB0
+#define HFSPLUS_SUPER_MAGIC	0x482b		/* HFSPLUS */
+#define HFS_SUPER_MAGIC	0x4244		/* "BD": HFS MDB (super block) */
 #define NCP_SUPER_MAGIC		0x564c		/* Guess, what 0x564c is :-) */
 #define NFS_SUPER_MAGIC		0x6969
 #define OCFS2_SUPER_MAGIC	0x7461636f
-- 
2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ