From: Guenter Roeck <linux@roeck-us.net>
To: Jan Kara <jack@suse.cz>
Cc: Jim Zhao <jimzhao.ai@gmail.com>,
akpm@linux-foundation.org, willy@infradead.org,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-mm@kvack.org
Subject: Re: [PATCH] mm/page-writeback: Consolidate wb_thresh bumping logic into __wb_calc_thresh
Date: Thu, 16 Jan 2025 08:05:59 -0800 [thread overview]
Message-ID: <897b426d-7ca7-4bfe-8342-d2af910f8202@roeck-us.net> (raw)
In-Reply-To: <2xndprbkr5k5qer4zb6ov35fa5ym7c36q6mcyapdh22ypqxivh@ahuvuqs47yd4>
On Thu, Jan 16, 2025 at 03:56:57PM +0100, Jan Kara wrote:
...
> >
> > Interesting. Is there some endianness issue, by any chance ? I only see the problem
> > with sheb (big endian), not with sh (little endian). I'd suspect that it is an
> > emulation bug, but it is odd that the problem did not show up before.
>
> So far I don't have a good explanation. Let me write down here the facts,
> maybe it will trigger the aha effect.
>
> 1) Ext2 stores the metadata in little endian ordering. We observe the
> problem with the first directory entry in the folio. Both entry->rec_len
> (16-bit) and entry->inode (32-bit) appear to be seen in wrong endianity
>
> 2) The function that fails is ext2_check_folio(). We kmap_local() the folio
> in ext2_get_folio(), then in ext2_check_folio() we do:
>
> ext2_dirent *p;
>
> p = (ext2_dirent *)(kaddr + 0);
> rec_len = ext2_rec_len_from_disk(p->rec_len);
> ^^^ value 3072 == 0x0c00 seen here instead of correct 0x000c
> this value is invalid so we go to:
> ext2_error(sb, __func__, "bad entry in directory #%lu: : %s - "
> "offset=%llu, inode=%lu, rec_len=%d, name_len=%d",
> dir->i_ino, error, folio_pos(folio) + offs,
> (unsigned long) le32_to_cpu(p->inode),
> rec_len, p->name_len);
>
> Here rec_len is printed so we see the wrong value. Also
> le32_to_cpu(p->inode) is printed which also shows number with swapped byte
> ordering (the message contains inode number 27393 == 0x00006b01 but the
> proper inode number is 363 == 0x0000016b). This actually releals more about
> the problem because only the two bytes were swapped in the inode number
> although we always treat it as 32-bit entity. So this would indeed point
> more at some architectural issue rather than a problem in the filesystem /
> MM.
>
> Note that to get at this point in the boot we must have correctly
> byteswapped many other directory entries in the filesystem. So the problem
> must be triggered by some parallel activity happening in the system or
> something like that.
>
> 3) The problem appears only with MTD storage, not with IDE/SATA on the same
> system + filesystem image. It it unclear how the storage influences the
> reproduction, rather than that it influences timing of events in the
> system.
>
> 4) The problem reliably happens with "mm/page-writeback: Consolidate wb_thresh
> bumping logic into __wb_calc_thresh", not without it. All this patch does
> is that it possibly changes a limit at which processes dirtying pages in
> the page cache get throttled. Thus there are fairly limited opportunities
> for how it can cause damage (I've checked for possible UAF issues or memory
> corruption but I don't really see any such possibility there, it is just
> crunching numbers from the mm counters and takes decision based on the
> result). This change doesn't have direct on the directory ext2 code. The only
> thing it does is that it possibly changes code alignment of ext2 code if it
> gets linked afterwards into vmlinux image (provided ext2 is built in). Another
> possibility is again that it changes timing of events in the system due to
> differences in throttling of processes dirtying page cache.
>
> So at this point I don't have a better explanation than blame the HW. What
> really tipped my conviction in this direction is the 16-bit byteswap in a
> 32-bit entity. Hence I guess I'll ask Andrew to put Jim's patch back into
> tree if you don't object.
I agree that this is most likely an emulation problem (it would not be the
first one), so please go ahead.
Thanks,
Guenter
next prev parent reply other threads:[~2025-01-16 16:06 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-21 10:05 Jim Zhao
2025-01-13 23:05 ` Guenter Roeck
2025-01-14 13:19 ` Jan Kara
2025-01-14 15:01 ` Guenter Roeck
2025-01-15 16:07 ` Jan Kara
2025-01-15 16:28 ` Jan Kara
2025-01-15 16:52 ` Guenter Roeck
2025-01-15 16:41 ` Guenter Roeck
2025-01-16 14:56 ` Jan Kara
2025-01-16 16:05 ` Guenter Roeck [this message]
2025-10-07 16:17 ` Joshua Watt
2025-10-08 11:14 ` Jan Kara
2025-10-08 14:49 ` Joshua Watt
2025-10-08 23:14 ` Joshua Watt
2025-10-09 8:38 ` Jan Kara
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=897b426d-7ca7-4bfe-8342-d2af910f8202@roeck-us.net \
--to=linux@roeck-us.net \
--cc=akpm@linux-foundation.org \
--cc=jack@suse.cz \
--cc=jimzhao.ai@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--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®