mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Viacheslav Dubeyko <Slava.Dubeyko@ibm.com>
To: "penguin-kernel@I-love.SAKURA.ne.jp"
	<penguin-kernel@I-love.SAKURA.ne.jp>,
	"willy@infradead.org" <willy@infradead.org>
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: Fri, 25 Jul 2025 17:45:29 +0000	[thread overview]
Message-ID: <da34b1af424c855519b3e926c7bc891a338c327c.camel@ibm.com> (raw)
In-Reply-To: <d4abeee2-e291-4da4-9e0e-7880a9c213e3@I-love.SAKURA.ne.jp>

On Fri, 2025-07-25 at 08:20 +0900, Tetsuo Handa wrote:
> On 2025/07/25 7:05, Tetsuo Handa wrote:
> > > > But I can't be convinced that above change is sufficient, for if I do
> > > > 
> > > > +	            static u8 serial;
> > > > +               if (inode->i_ino < HFS_FIRSTUSER_CNID && ((1U << inode->i_ino) & bad_cnid_list))
> > > > +                       inode->i_ino = (serial++) % 16;
> > > 
> > > I don't see the point in flags introduction. It makes logic very complicated.
> > 
> > The point of this change is to excecise inode->i_ino for all values between 0 and 15.
> > Some of values between 0 and 15 must be valid as inode->i_ino , doesn't these? Then,
> 
> Background: I assume that the value of rec->dir.DirID comes from the hfs filesystem image in the
> reproducer (i.e. memfd file associated with /dev/loop0 ). But since I don't know the offset to modify
> the value if I want the reproducer to pass rec->dir.DirID == 1...15 instead of rec->dir.DirID == 0,
> I am modifying inode->i_ino here when rec->dir.DirID == 0.
> 
> > 
> > > 
> > > > 
> > > > instead of
> > > > 
> > > > +               if (inode->i_ino < HFS_FIRSTUSER_CNID && ((1U << inode->i_ino) & bad_cnid_list))
> > > > +                       make_bad_inode(inode);
> > > > 
> > > > , the reproducer still hits BUG() for 0, 1, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 and 15
> > > > because hfs_write_inode() handles only 2, 3 and 4.
> > > > 
> > > 
> > > How can we go into hfs_write_inode() if we created the bad inode for invalid
> > > inode ID? How is it possible?
> 
> Calling make_bad_inode() for some of values between 0...15 at hfs_read_inode() will prevent
> that inode from going into hfs_write_inode(). But regarding the values between 0...15 which
> were not calling make_bad_inode() at hfs_read_inode() will not prevent that inode from going
> into hfs_write_inode().
> 
> Since hfs_write_inode() calls BUG() for values 0...15 except 2...4, any values between 0...15
> except 2...4 which were not calling make_bad_inode() at hfs_read_inode() will hit BUG().
> 
> If we don't remove BUG(), the values which hfs_read_inode() does not need to call
> make_bad_inode() will be limited to only 2...4.
> 
> And since you say that hfs_read_inode() should call make_bad_inode() for 3...4, the only value
> hfs_read_inode() can accept (from the point of view of avoid hitting BUG() in hfs_write_inode())
> will be 2.
> 
> > 
> > are all of 0, 1, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 and 15 invalid value for hfs_read_inode() ?
> > 
> > If all of 0, 1, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 and 15 are invalid value for hfs_read_inode(),
> > and 3 and 4 are also invalid value for hfs_read_inode(), hfs_read_inode() would accept only 2.
> > Something is crazily wrong.
> > 
> > Can we really filter some of values between 0 and 15 at hfs_read_inode() ?
> > 
> 
> Can the attempt to filter some of values between 0 and 15 at hfs_read_inode() make sense,
> without the attempt to remove BUG() from hfs_write_inode() ?
> 
> I think that we need to remove BUG() from hfs_write_inode(), even if you try to filter
> at hfs_read_inode().

If we manage the inode IDs properly in hfs_read_inode(), then hfs_write_inode()
never will receive the invalid inode ID. I don't see the point to remove the
BUG() in hfs_write_inode().

Thanks,
Slava.

  parent reply	other threads:[~2025-07-25 17:45 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
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                                                   ` Viacheslav Dubeyko [this message]
2025-07-25 22:25                                                     ` [PATCH v3] hfs: remove BUG() from hfs_release_folio()/hfs_test_inode()/hfs_write_inode() 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=da34b1af424c855519b3e926c7bc891a338c327c.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®