From: Viacheslav Dubeyko <Slava.Dubeyko@ibm.com>
To: "willy@infradead.org" <willy@infradead.org>,
"penguin-kernel@i-love.sakura.ne.jp"
<penguin-kernel@i-love.sakura.ne.jp>
Cc: "glaubitz@physik.fu-berlin.de" <glaubitz@physik.fu-berlin.de>,
"frank.li@vivo.com" <frank.li@vivo.com>,
"slava@dubeyko.com" <slava@dubeyko.com>,
"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>
Subject: RE: [PATCH v3] hfs: remove BUG() from hfs_release_folio()/hfs_test_inode()/hfs_write_inode()
Date: Tue, 22 Jul 2025 18:08:09 +0000 [thread overview]
Message-ID: <9ac7574508df0f96d220cc9c2f51d3192ffff568.camel@ibm.com> (raw)
In-Reply-To: <aH-enGSS7zWq0jFf@casper.infradead.org>
On Tue, 2025-07-22 at 15:22 +0100, Matthew Wilcox wrote:
> On Tue, Jul 22, 2025 at 11:04:30PM +0900, Tetsuo Handa wrote:
> > On 2025/07/22 22:30, Matthew Wilcox wrote:
> > > On Tue, Jul 22, 2025 at 07:42:35PM +0900, Tetsuo Handa wrote:
> > > > I can update patch description if you have one, but I don't plan to try something like below.
> > >
> > > Why not? Papering over the underlying problem is what I rejected in v1,
> > > and here we are months later with you trying a v4.
> >
> > Because I don't know how HFS/HFS+ filesystems work.
The patch definitely should be rework. The phrase "I don't know how it works"
cannot be accepted as excuse. :)
> > I just want to close these nearly 1000 days old bugs.
> >
We are not in a hurry. We must fix the reason of the bug but
not try to hide the real reason of the issue.
> > You can write your patches.
>
> I don't understand this attitude at all. Are you in QA and being paid
> by "number of bugs closed per week"?
OK. Let's return to hfs_read_inode() again [1]. We have such logic here:
switch (rec->type) {
case HFS_CDR_FIL:
<skipped>
inode->i_ino = be32_to_cpu(rec->file.FlNum);
<skipped>
break;
case HFS_CDR_DIR:
inode->i_ino = be32_to_cpu(rec->dir.DirID);
<skipped>
break;
default:
make_bad_inode(inode);
}
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]:
/* Some special File ID numbers */
#define HFS_POR_CNID 1 /* Parent Of the Root */
#define HFS_ROOT_CNID 2 /* ROOT directory */
#define HFS_EXT_CNID 3 /* EXTents B-tree */
#define HFS_CAT_CNID 4 /* CATalog B-tree */
#define HFS_BAD_CNID 5 /* BAD blocks file */
#define HFS_ALLOC_CNID 6 /* ALLOCation file (HFS+) */
#define HFS_START_CNID 7 /* STARTup file (HFS+) */
#define HFS_ATTR_CNID 8 /* ATTRibutes file (HFS+) */
#define HFS_EXCH_CNID 15 /* ExchangeFiles temp id */
#define HFS_FIRSTUSER_CNID 16
Zero inode ID is completely invalid. And values from 1 - 15 are reserved
for HFS metadata structures.
Thanks,
Slava.
[1] https://elixir.bootlin.com/linux/v6.16-rc6/source/fs/hfs/inode.c#L350
[2] https://elixir.bootlin.com/linux/v6.16-rc6/source/fs/hfs/hfs.h#L40
next prev parent reply other threads:[~2025-07-22 18:08 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-23 13:32 [PATCH] hfs: don't use BUG() when we can continue Tetsuo Handa
2024-12-05 13:45 ` [PATCH (REPOST)] " Tetsuo Handa
2024-12-05 13:59 ` Matthew Wilcox
2024-12-05 14:14 ` Tetsuo Handa
2025-06-25 5:03 ` Tetsuo Handa
2025-07-15 6:51 ` [PATCH v2] hfs: remove BUG() from hfs_release_folio()/hfs_test_inode()/hfs_write_inode() Tetsuo Handa
2025-07-15 19:20 ` Viacheslav Dubeyko
2025-07-17 15:30 ` Tetsuo Handa
2025-07-17 15:32 ` [PATCH v3] " Tetsuo Handa
2025-07-17 18:25 ` Viacheslav Dubeyko
2025-07-17 19:35 ` Matthew Wilcox
2025-07-17 19:49 ` Viacheslav Dubeyko
2025-07-17 22:08 ` Tetsuo Handa
2025-07-21 17:04 ` Viacheslav Dubeyko
2025-07-22 10:42 ` Tetsuo Handa
2025-07-22 13:30 ` Matthew Wilcox
2025-07-22 14:04 ` Tetsuo Handa
2025-07-22 14:22 ` Matthew Wilcox
2025-07-22 18:08 ` Viacheslav Dubeyko [this message]
2025-07-23 1:07 ` Tetsuo Handa
2025-07-23 2:16 ` Tetsuo Handa
2025-07-23 18:19 ` Viacheslav Dubeyko
2025-07-23 18:43 ` Viacheslav Dubeyko
2025-07-24 6:55 ` Tetsuo Handa
2025-07-24 19:49 ` Viacheslav Dubeyko
2025-07-24 22:05 ` Tetsuo Handa
2025-07-24 23:20 ` Tetsuo Handa
2025-07-25 4:16 ` Tetsuo Handa
2025-07-25 17:47 ` Viacheslav Dubeyko
2025-07-25 21:52 ` Tetsuo Handa
2025-07-28 19:37 ` Viacheslav Dubeyko
2025-07-28 21:38 ` Tetsuo Handa
2025-07-29 23:21 ` [PATCH v4] hfs: update sanity check of the root record Tetsuo Handa
2025-07-30 19:24 ` Viacheslav Dubeyko
2025-07-30 22:02 ` Tetsuo Handa
2025-07-31 18:03 ` Viacheslav Dubeyko
2025-07-31 21:12 ` Tetsuo Handa
2025-08-01 18:26 ` Viacheslav Dubeyko
2025-08-01 21:52 ` Tetsuo Handa
2025-08-04 22:00 ` Viacheslav Dubeyko
2025-08-21 10:57 ` Tetsuo Handa
2025-07-25 17:45 ` [PATCH v3] hfs: remove BUG() from hfs_release_folio()/hfs_test_inode()/hfs_write_inode() Viacheslav Dubeyko
2025-07-25 22:25 ` Tetsuo Handa
2025-07-27 13:27 ` Tetsuo Handa
2025-07-25 17:42 ` Viacheslav Dubeyko
2025-07-25 22:22 ` Tetsuo Handa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9ac7574508df0f96d220cc9c2f51d3192ffff568.camel@ibm.com \
--to=slava.dubeyko@ibm.com \
--cc=akpm@linux-foundation.org \
--cc=frank.li@vivo.com \
--cc=glaubitz@physik.fu-berlin.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=penguin-kernel@i-love.sakura.ne.jp \
--cc=slava@dubeyko.com \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®