+ kasan-slub-fix-more-conflicts-with-config_slab_freelist_hardened.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled
     Subject: kasan, slub: fix more conflicts with CONFIG_SLAB_FREELIST_HARDENED
has been added to the -mm tree.  Its filename is
     kasan-slub-fix-more-conflicts-with-config_slab_freelist_hardened.patch

This patch should soon appear at
    http://ozlabs.org/~akpm/mmots/broken-out/kasan-slub-fix-more-conflicts-with-config_slab_freelist_hardened.patch
and later at
    http://ozlabs.org/~akpm/mmotm/broken-out/kasan-slub-fix-more-conflicts-with-config_slab_freelist_hardened.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next and is updated
there every 3-4 working days

------------------------------------------------------
From: Andrey Konovalov <andreyknvl@xxxxxxxxxx>
Subject: kasan, slub: fix more conflicts with CONFIG_SLAB_FREELIST_HARDENED

When CONFIG_KASAN_SW_TAGS is enabled, ptr_addr might be tagged.  Normally,
this doesn't cause any issues, as both set_freepointer() and
get_freepointer() are called with a pointer with the same tag.  However,
there are some issues with CONFIG_SLUB_DEBUG code.  For example, when
__free_slub() iterates over objects in a cache, it passes untagged
pointers to check_object().  check_object() in turns calls
get_freepointer() with an untagged pointer, which causes the freepointer
to be restored incorrectly.

Add kasan_reset_tag to freelist_ptr(). Also add a detailed comment.

Link: http://lkml.kernel.org/r/bf858f26ef32eb7bd24c665755b3aee4bc58d0e4.1550103861.git.andreyknvl@xxxxxxxxxx
Signed-off-by: Andrey Konovalov <andreyknvl@xxxxxxxxxx>
Reported-by: Qian Cai <cai@xxxxxx>
Tested-by: Qian Cai <cai@xxxxxx>
Cc: Andrey Ryabinin <aryabinin@xxxxxxxxxxxxx>
Cc: Alexander Potapenko <glider@xxxxxxxxxx>
Cc: Dmitry Vyukov <dvyukov@xxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 mm/slub.c |   13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

--- a/mm/slub.c~kasan-slub-fix-more-conflicts-with-config_slab_freelist_hardened
+++ a/mm/slub.c
@@ -249,7 +249,18 @@ static inline void *freelist_ptr(const s
 				 unsigned long ptr_addr)
 {
 #ifdef CONFIG_SLAB_FREELIST_HARDENED
-	return (void *)((unsigned long)ptr ^ s->random ^ ptr_addr);
+	/*
+	 * When CONFIG_KASAN_SW_TAGS is enabled, ptr_addr might be tagged.
+	 * Normally, this doesn't cause any issues, as both set_freepointer()
+	 * and get_freepointer() are called with a pointer with the same tag.
+	 * However, there are some issues with CONFIG_SLUB_DEBUG code. For
+	 * example, when __free_slub() iterates over objects in a cache, it
+	 * passes untagged pointers to check_object(). check_object() in turns
+	 * calls get_freepointer() with an untagged pointer, which causes the
+	 * freepointer to be restored incorrectly.
+	 */
+	return (void *)((unsigned long)ptr ^ s->random ^
+			(unsigned long)kasan_reset_tag((void *)ptr_addr));
 #else
 	return ptr;
 #endif
_

Patches currently in -mm which might be from andreyknvl@xxxxxxxxxx are

kasan-fix-assigning-tags-twice.patch
kasan-kmemleak-pass-tagged-pointers-to-kmemleak.patch
kmemleak-account-for-tagged-pointers-when-calculating-pointer-range-v2.patch
kasan-slub-move-kasan_poison_slab-hook-before-page_address.patch
kasan-slub-move-kasan_poison_slab-hook-before-page_address-v2.patch
kasan-slub-fix-conflicts-with-config_slab_freelist_hardened.patch
kasan-slub-fix-more-conflicts-with-config_slab_freelist_hardened.patch




[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux