From: Gao Xiang <hsiangkao@linux.alibaba.com>
To: Stefan Kerkmann <s.kerkmann@pengutronix.de>,
linux-erofs@lists.ozlabs.org
Subject: Re: [bug report] data corruption of init process
Date: Tue, 21 Jan 2025 11:33:07 +0800 [thread overview]
Message-ID: <a3aa2b25-be6c-4c4f-aaad-b62417a14da5@linux.alibaba.com> (raw)
In-Reply-To: <1e6554d0-5b46-47c0-a9e1-8c26dafa29b3@linux.alibaba.com>
On 2025/1/21 11:27, Gao Xiang wrote:
>
>
> On 2025/1/21 01:36, Stefan Kerkmann wrote:
>> Hi Gao,
>>
>> I have enabled KASAN and applied your requested changes, but nothing suspicious happened.
>
> Sigh...
>
>>
>>> - Could we get the exact file offset of `init` which init process is
>>> crashed? It will help us to chase down the the primary scene.
>>
>> I'll try to track that down. If you have any hints how to-do that let me know :-).
>
> Many thanks for the test...
> I just hacked some code but un-tested as below:
>
> diff --git a/kernel/exit.c b/kernel/exit.c
> index 1dcddfe537ee..868fea16732f 100644
> --- a/kernel/exit.c
> +++ b/kernel/exit.c
> @@ -873,6 +873,8 @@ static void synchronize_group_exit(struct task_struct *tsk, long code)
> spin_unlock_irq(&sighand->siglock);
> }
>
> +extern struct inode *erofs_iget(struct super_block *sb, u64 nid);
> +
> void __noreturn do_exit(long code)
> {
> struct task_struct *tsk = current;
> @@ -903,9 +905,59 @@ void __noreturn do_exit(long code)
> * If the last thread of global init has exited, panic
> * immediately to get a useable coredump.
> */
> - if (unlikely(is_global_init(tsk)))
> + if (unlikely(is_global_init(tsk))) {
> + struct path path;
> + struct inode *inode;
> +
> + get_fs_pwd(tsk->fs, &path);
> +
> + inode = d_inode(path.dentry);
> + if (inode && inode->i_sb->s_magic == EROFS_SUPER_MAGIC_V1) {
> + struct inode *inode;
> + int i = 0;
> +
> + inode = erofs_iget(inode->i_sb, 190291);
> + if (IS_ERR(inode))
> + goto skip;
> +
> + for (i = 0; i < 30; ++i) {
> + struct page *page = find_get_page(inode->i_mapping, i);
> + void *data;
> +
> + if (!page)
> + continue;
> + data = kmap_local_page(page);
> +
> + hash = fnv_32_buf(data, PAGE_SIZE, FNV1_32_INIT);
> + pr_err("%px i_ino %lu, index %lu dst %px (%x) err %d",
> + page, page->mapping->host->i_ino, i, ptr, hash);
maybe use some different style in this print message:
"exit: %px i_ino %lu, index %lu dst %px (%x)"
likewise.
Anyway, it's somewhat hack code, just wonder if it works, and
the output is helpful for us to know which page is corrupt.
> + kunmap_local(data);
> + }
> + iput(inode);
> +
> + inode = erofs_iget(inode->i_sb, 868416);
> + if (IS_ERR(inode))
> + goto skip;
> +
> + for (i = 0; i < 19; ++i) {
> + struct page *page = find_get_page(inode->i_mapping, i);
> + void *data;
> +
> + if (!page)
> + continue;
> + data = kmap_local_page(page);
> + hash = fnv_32_buf(data, PAGE_SIZE, FNV1_32_INIT);
> + pr_err("%px i_ino %lu, index %lu dst %px (%x) err %d",
> + page, page->mapping->host->i_ino, i, ptr, hash);
> + kunmap_local(data);
> + }
> + iput(inode);
> + }
> +skip:
> panic("Attempted to kill init! exitcode=0x%08x\n",
> tsk->signal->group_exit_code ?: (int)code);
> + }
> +
>
> #ifdef CONFIG_POSIX_TIMERS
> hrtimer_cancel(&tsk->signal->real_timer);
>
> You could follow the idea to dump the page cache data when init
> is killed, I wonder the output...
>
>
> Thanks,
> Gao Xiang
next prev parent reply other threads:[~2025-01-21 3:33 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-27 10:44 [bug report] data corruption of init process Stefan Kerkmann
2024-12-27 13:24 ` Gao Xiang
2025-01-19 12:07 ` Stefan Kerkmann
2025-01-19 12:48 ` Gao Xiang
2025-01-20 1:45 ` Gao Xiang
2025-01-20 1:55 ` Gao Xiang
2025-01-20 17:36 ` Stefan Kerkmann
2025-01-21 3:27 ` Gao Xiang
2025-01-21 3:33 ` Gao Xiang [this message]
2025-01-21 17:21 ` Stefan Kerkmann
2025-01-22 1:41 ` Gao Xiang
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=a3aa2b25-be6c-4c4f-aaad-b62417a14da5@linux.alibaba.com \
--to=hsiangkao@linux.alibaba.com \
--cc=linux-erofs@lists.ozlabs.org \
--cc=s.kerkmann@pengutronix.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.