Message ID | cover.1597425745.git.andreyknvl@google.com (mailing list archive) |
---|---|
Headers | show |
Series | kasan: add hardware tag-based mode for arm64 | expand |
> This patchset adds a new hardware tag-based mode to KASAN [1]. The new mode > is similar to the existing software tag-based KASAN, but relies on arm64 > Memory Tagging Extension (MTE) [2] to perform memory and pointer tagging > (instead of shadow memory and compiler instrumentation). What does one need to do to enable MTE in the kernel? I am trying to color some kernel module data, but when I call mte_get_mem_tag after calling mte_set_mem_tag_range, I get an invalid value. I have assured that mte_assign_mem_tag_range has been called in mte_set_mem_tag_range, so the initial sanity checks pass. Thanks.
On Mon, Sep 14, 2020 at 9:06 PM Derrick McKee <derrick.mckee@gmail.com> wrote: > > > This patchset adds a new hardware tag-based mode to KASAN [1]. The new mode > > is similar to the existing software tag-based KASAN, but relies on arm64 > > Memory Tagging Extension (MTE) [2] to perform memory and pointer tagging > > (instead of shadow memory and compiler instrumentation). > > What does one need to do to enable MTE in the kernel? I am trying to > color some kernel module data, but when I call mte_get_mem_tag after > calling mte_set_mem_tag_range, I get an invalid value. I have assured > that mte_assign_mem_tag_range has been called in mte_set_mem_tag_range, > so the initial sanity checks pass. Thanks. Hi Derrick, One needs to use the latest QEMU master and provide "-machine virt,mte=on -cpu max" arguments to it. I'll add this information into the cover letter for v2. Thanks!
On 9/14/20 4:04 PM, Andrey Konovalov wrote: > One needs to use the latest QEMU master and provide "-machine > virt,mte=on -cpu max" arguments to it. I'll add this information into > the cover letter for v2. I am using the latest QEMU as of Sep. 8, and starting the system with virt,mte=on, and I have also checked that the appropriate bits are set in sctlr_el1 and ID_AA64PFR1_EL1. Finally, when I print out the tag immediately before and after mte_assign_mem_tag_range I get the same result.
On 9/14/20 5:36 PM, Derrick McKee wrote: > On 9/14/20 4:04 PM, Andrey Konovalov wrote: >> One needs to use the latest QEMU master and provide "-machine >> virt,mte=on -cpu max" arguments to it. I'll add this information into >> the cover letter for v2. > > I am using the latest QEMU as of Sep. 8, and starting the system with > virt,mte=on, and I have also checked that the appropriate bits are set > in sctlr_el1 and ID_AA64PFR1_EL1. Finally, when I print out the tag > immediately before and after mte_assign_mem_tag_range I get the same > result. I should also mention that CONFIG_KASAN_HW_TAGS=n in my configuration, but I have added my own macro to enable my code and added it to the conditional macro in memory.h:224. I have also ensured that mte_init_tags is called from setup_arch. But still the result of the ldg instruction to get the address tag is always 0, despite the desired tag of 2. Perhaps I am missing some other needed setup or configuration?
On Tue, Sep 15, 2020 at 12:41 AM Derrick McKee <derrick.mckee@gmail.com> wrote: > > On 9/14/20 5:36 PM, Derrick McKee wrote: > > On 9/14/20 4:04 PM, Andrey Konovalov wrote: > >> One needs to use the latest QEMU master and provide "-machine > >> virt,mte=on -cpu max" arguments to it. I'll add this information into > >> the cover letter for v2. > > > > I am using the latest QEMU as of Sep. 8, and starting the system with > > virt,mte=on, and I have also checked that the appropriate bits are set > > in sctlr_el1 and ID_AA64PFR1_EL1. Finally, when I print out the tag > > immediately before and after mte_assign_mem_tag_range I get the same > > result. > > I should also mention that CONFIG_KASAN_HW_TAGS=n in my configuration, > but I have added my own macro to enable my code and added it to the > conditional macro in memory.h:224. I have also ensured that > mte_init_tags is called from setup_arch. But still the result of the > ldg instruction to get the address tag is always 0, despite the desired > tag of 2. Perhaps I am missing some other needed setup or configuration? Hm, this should work I guess. Could you try CONFIG_KASAN_HW_TAGS=y and check if that works?
On 9/14/20 6:50 PM, Andrey Konovalov wrote: > Hm, this should work I guess. > > Could you try CONFIG_KASAN_HW_TAGS=y and check if that works? This seems to work, as the tags change appropriately. So I guess I need to figure out what I am doing differently. Thanks for the help.
On 9/15/20 5:46 AM, Derrick McKee wrote: > This seems to work, as the tags change appropriately. So I guess I need > to figure out what I am doing differently. Thanks for the help. The problem was that the kernel uses the PAGE_KERNEL flag when allocating memory for modules, and the solution was to change that to PAGE_KERNEL_TAGGED. It might be worth adding this new flag to the documentation somewhere.