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: <65009dff-dd9d-4c99-aa53-5e87e2777017@I-love.SAKURA.ne.jp>
Date: Wed, 23 Jul 2025 10:07:01 +0900
From: Tetsuo Handa <penguin-kernel@...ove.SAKURA.ne.jp>
To: Viacheslav Dubeyko <Slava.Dubeyko@....com>,
        "willy@...radead.org" <willy@...radead.org>
Cc: "glaubitz@...sik.fu-berlin.de" <glaubitz@...sik.fu-berlin.de>,
        "frank.li@...o.com" <frank.li@...o.com>,
        "slava@...eyko.com" <slava@...eyko.com>,
        "linux-fsdevel@...r.kernel.org" <linux-fsdevel@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "akpm@...ux-foundation.org" <akpm@...ux-foundation.org>
Subject: Re: [PATCH v3] hfs: remove BUG() from
 hfs_release_folio()/hfs_test_inode()/hfs_write_inode()

On 2025/07/23 3:08, Viacheslav Dubeyko wrote:
> So, if rec->type is OK (HFS_CDR_FIL, HFS_CDR_DIR) then we process
> a particular type of record, otherwise, we create the bad inode. So, we simply
> need to extend this logic. If rec->file.FlNum or rec->dir.DirID is equal or
> bigger than HFS_FIRSTUSER_CNID, then we can create normal inode. Otherwise,
> we need to create the bad inode. We simply need to add the checking logic
> here. Tetsuo, does it make sense to you? :) Because, if we have corrupted value
> of rec->file.FlNum or rec->dir.DirID, then it doesn't make sense to create
> the normal inode with invalid i_ino. Simply, take a look here [2]:

Something is wrong with below change; legitimate HFS filesystem images can no longer be mounted.
I guess that several reserved IDs have to be excluded from make_bad_inode() conditions.

# hformat testfile.img
# mount -t hfs -o loop testfile.img /mnt/
mount: /mnt: filesystem was mounted, but any subsequent operation failed: Operation not permitted.

--- a/fs/hfs/inode.c
+++ b/fs/hfs/inode.c
@@ -358,6 +358,8 @@ static int hfs_read_inode(struct inode *inode, void *data)
                inode->i_op = &hfs_file_inode_operations;
                inode->i_fop = &hfs_file_operations;
                inode->i_mapping->a_ops = &hfs_aops;
+               if (unlikely(inode->i_ino < HFS_FIRSTUSER_CNID))
+                       make_bad_inode(inode);
                break;
        case HFS_CDR_DIR:
                inode->i_ino = be32_to_cpu(rec->dir.DirID);
@@ -368,6 +370,8 @@ static int hfs_read_inode(struct inode *inode, void *data)
                                      inode_set_atime_to_ts(inode, inode_set_ctime_to_ts(inode, hfs_m_to_utime(rec->dir.MdDat))));
                inode->i_op = &hfs_dir_inode_operations;
                inode->i_fop = &hfs_dir_operations;
+               if (unlikely(inode->i_ino < HFS_FIRSTUSER_CNID))
+                       make_bad_inode(inode);
                break;
        default:
                make_bad_inode(inode);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ