All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Xi Ruoyao <xry111@xry111.site>
To: Guenter Roeck <linux@roeck-us.net>, loongarch@lists.linux.dev
Cc: Huacai Chen <chenhuacai@kernel.org>,
	WANG Xuerui <kernel@xen0n.name>,
	 Alexander Potapenko <glider@google.com>,
	Marco Elver <elver@google.com>,
	Dmitry Vyukov <dvyukov@google.com>,
	kasan-dev@googlegroups.com
Subject: Re: Kernel BUG with loongarch and CONFIG_KFENCE and CONFIG_DEBUG_SG
Date: Thu, 28 Mar 2024 03:33:03 +0800	[thread overview]
Message-ID: <4d2373e3f0694fd02137a72181d054ee2ebcca45.camel@xry111.site> (raw)
In-Reply-To: <c352829b-ed75-4ffd-af6e-0ea754e1bf3d@roeck-us.net>

On Wed, 2024-03-27 at 12:11 -0700, Guenter Roeck wrote:
> Hi,
> 
> when enabling both CONFIG_KFENCE and CONFIG_DEBUG_SG, I get the following
> backtraces when running loongarch images in qemu.
> 
> [    2.496257] kernel BUG at include/linux/scatterlist.h:187!
> ...
> [    2.501925] Call Trace:
> [    2.501950] [<9000000004ad59c4>] sg_init_one+0xac/0xc0
> [    2.502204] [<9000000004a438f8>] do_test_kpp+0x278/0x6e4
> [    2.502353] [<9000000004a43dd4>] alg_test_kpp+0x70/0xf4
> [    2.502494] [<9000000004a41b48>] alg_test+0x128/0x690
> [    2.502631] [<9000000004a3d898>] cryptomgr_test+0x20/0x40
> [    2.502775] [<90000000041b4508>] kthread+0x138/0x158
> [    2.502912] [<9000000004161c48>] ret_from_kernel_thread+0xc/0xa4
> 
> The backtrace is always similar but not exactly the same. It is always
> triggered from cryptomgr_test, but not always from the same test.
> 
> Analysis shows that with CONFIG_KFENCE active, the address returned from
> kmalloc() and friends is not always below vm_map_base. It is allocated by
> kfence_alloc() which at least sometimes seems to get its memory from an
> address space above vm_map_base. This causes virt_addr_valid() to return
> false for the affected objects.

Oops, Xuerui has been haunted by some "random" kernel crashes only
occurring with CONFIG_KFENCE=y for months but we weren't able to triage
the issue:

https://github.com/loongson-community/discussions/issues/34

Maybe the same issue or not.

> I have only seen this if CONFIG_DEBUG_SG is enabled because sg_set_buf()
> otherwise does not call virt_addr_valid(), but I found that many memory
> allocation calls return addresses above vm_map_base, making this a
> potential problem when running loongarch images with CONFIG_KFENCE enabled
> whenever some code calls virt_addr_valid().
> 
> I don't know how to solve the problem, but I did notice that virt_to_page()
> does handle situations with addr >= vm_map_base. Maybe a similar solution
> would be possible for virt_addr_valid().
> 
> Thanks,
> Guenter
> 

-- 
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University

  reply	other threads:[~2024-03-27 19:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-27 19:11 Kernel BUG with loongarch and CONFIG_KFENCE and CONFIG_DEBUG_SG Guenter Roeck
2024-03-27 19:33 ` Xi Ruoyao [this message]
2024-03-27 23:38   ` Guenter Roeck
2024-03-29  2:17     ` Huacai Chen
2024-03-29 16:32       ` Guenter Roeck

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=4d2373e3f0694fd02137a72181d054ee2ebcca45.camel@xry111.site \
    --to=xry111@xry111.site \
    --cc=chenhuacai@kernel.org \
    --cc=dvyukov@google.com \
    --cc=elver@google.com \
    --cc=glider@google.com \
    --cc=kasan-dev@googlegroups.com \
    --cc=kernel@xen0n.name \
    --cc=linux@roeck-us.net \
    --cc=loongarch@lists.linux.dev \
    /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.