From: Jakub Kicinski <kubakici@wp.pl>
To: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Andy Lutomirski <luto@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@kernel.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: linux/master crashes on boot with KASAN=y
Date: Sat, 23 Dec 2017 17:22:04 -0800 [thread overview]
Message-ID: <20171223172204.1eb623cd@cakuba.netronome.com> (raw)
In-Reply-To: <41c68406-ad05-1db7-b0dd-a2e616448ee1@virtuozzo.com>
On Sat, 23 Dec 2017 15:41:27 +0300, Andrey Ryabinin wrote:
> On 12/23/2017 11:01 AM, Jakub Kicinski wrote:
> > Hi!
> >
> > I bisected a crash on boot to this:
> >
> > commit 21506525fb8ddb0342f2a2370812d47f6a1f3833 (HEAD, refs/bisect/bad)
> > Author: Andy Lutomirski <luto@kernel.org>
> > Date: Mon Dec 4 15:07:16 2017 +0100
> >
> > x86/kasan/64: Teach KASAN about the cpu_entry_area
>
>
> Thanks.
> There is nothing wrong with this patch, it just uncovered older bug.
> The actual problem comes from f06bdd4001c2 ("x86/mm: Adapt MODULES_END based on fixmap section size")
> which is made kasan_mem_to_shadow(MODULES_END) potentially unaligned to page boundary.
> And when we feed unaligned address to kasan_populate_zero_shadow() it doesn't do the right thing.
>
> Could you tell me if the fix bellow works for you?
Works for me, thank you!
Tested-by: Jakub Kicinski <jakub.kicinski@netronome.com>
> arch/x86/include/asm/kasan.h | 8 ++++++++
> arch/x86/include/asm/pgtable_64_types.h | 4 +++-
> 2 files changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/include/asm/kasan.h b/arch/x86/include/asm/kasan.h
> index b577dd0916aa..0c580e4b2ccc 100644
> --- a/arch/x86/include/asm/kasan.h
> +++ b/arch/x86/include/asm/kasan.h
> @@ -5,6 +5,14 @@
> #include <linux/const.h>
> #define KASAN_SHADOW_OFFSET _AC(CONFIG_KASAN_SHADOW_OFFSET, UL)
>
> +#ifndef KASAN_SHADOW_SCALE_SHIFT
> +# ifdef CONFIG_KASAN
> +# define KASAN_SHADOW_SCALE_SHIFT 3
> +# else
> +# define KASAN_SHADOW_SCALE_SHIFT 0
> +# endif
> +#endif
> +
> /*
> * Compiler uses shadow offset assuming that addresses start
> * from 0. Kernel addresses don't start from 0, so shadow
> diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
> index 6d5f45dcd4a1..d34a90d6c374 100644
> --- a/arch/x86/include/asm/pgtable_64_types.h
> +++ b/arch/x86/include/asm/pgtable_64_types.h
> @@ -6,6 +6,7 @@
>
> #ifndef __ASSEMBLY__
> #include <linux/types.h>
> +#include <asm/kasan.h>
> #include <asm/kaslr.h>
>
> /*
> @@ -96,7 +97,8 @@ typedef struct { pteval_t pte; } pte_t;
> #define VMALLOC_END (VMALLOC_START + _AC((VMALLOC_SIZE_TB << 40) - 1, UL))
> #define MODULES_VADDR (__START_KERNEL_map + KERNEL_IMAGE_SIZE)
> /* The module sections ends with the start of the fixmap */
> -#define MODULES_END __fix_to_virt(__end_of_fixed_addresses + 1)
> +#define MODULES_END (__fix_to_virt(__end_of_fixed_addresses + 1) & \
> + ~((PAGE_SIZE << KASAN_SHADOW_SCALE_SHIFT) - 1))
> #define MODULES_LEN (MODULES_END - MODULES_VADDR)
> #define ESPFIX_PGD_ENTRY _AC(-2, UL)
> #define ESPFIX_BASE_ADDR (ESPFIX_PGD_ENTRY << P4D_SHIFT)
next prev parent reply other threads:[~2017-12-24 1:22 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-23 8:01 linux/master crashes on boot with KASAN=y Jakub Kicinski
2017-12-23 8:19 ` Jakub Kicinski
2017-12-23 12:41 ` Andrey Ryabinin
2017-12-24 1:22 ` Jakub Kicinski [this message]
2017-12-24 1:48 ` Andy Lutomirski
2017-12-26 11:47 ` Andrey Ryabinin
2017-12-27 18:09 ` Thomas Gleixner
2017-12-28 16:06 ` [PATCH] x86/mm: Set MODULES_END to 0xffffffffff000000 Andrey Ryabinin
2018-01-04 22:09 ` [tip:x86/pti] " tip-bot for Andrey Ryabinin
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=20171223172204.1eb623cd@cakuba.netronome.com \
--to=kubakici@wp.pl \
--cc=aryabinin@virtuozzo.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@kernel.org \
--cc=tglx@linutronix.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox