From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70A52C4361B for ; Sat, 19 Dec 2020 01:16:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3B5CA23BCB for ; Sat, 19 Dec 2020 01:16:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725978AbgLSBQj (ORCPT ); Fri, 18 Dec 2020 20:16:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:37622 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725940AbgLSBQg (ORCPT ); Fri, 18 Dec 2020 20:16:36 -0500 Date: Fri, 18 Dec 2020 17:15:55 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1608340555; bh=Xw1lKYELAq5hwqNAxjLCVlvxw2FmIyrAIGsrRiublLM=; h=From:To:Subject:From; b=Z5D2xYGUy36WZhI9xg501soEZ3CCEBC2pGx4rjpayrMXe6Ja8gJAxPmISZKrE9by/ E8JRlgX1zpD9UBKk5EsJertMtyE+GUXDTAeAoScrlbShR8pqAantl4/6x2aK+FkIlo sNoeZY8JD9E7hrm+PKb5BzfTTytrFSS/cAjVU48A= From: akpm@linux-foundation.org To: mm-commits@vger.kernel.org, glider@google.com, elver@google.com, akpm@linux-foundation.org Subject: + kfence-kasan-make-kfence-compatible-with-kasan-fix.patch added to -mm tree Message-ID: <20201219011555.4fyht%akpm@linux-foundation.org> User-Agent: s-nail v14.9.10 Precedence: bulk Reply-To: linux-kernel@vger.kernel.org List-ID: X-Mailing-List: mm-commits@vger.kernel.org The patch titled Subject: revert kasan-remove-kfence-leftovers has been added to the -mm tree. Its filename is kfence-kasan-make-kfence-compatible-with-kasan-fix.patch This patch should soon appear at https://ozlabs.org/~akpm/mmots/broken-out/kfence-kasan-make-kfence-compatible-with-kasan-fix.patch and later at https://ozlabs.org/~akpm/mmotm/broken-out/kfence-kasan-make-kfence-compatible-with-kasan-fix.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: Andrew Morton Subject: revert kasan-remove-kfence-leftovers Signed-off-by: Marco Elver Signed-off-by: Alexander Potapenko Signed-off-by: Andrew Morton --- mm/kasan/kasan.h | 9 +++++++++ mm/kasan/shadow.c | 13 +++++++++++++ 2 files changed, 22 insertions(+) --- a/mm/kasan/kasan.h~kfence-kasan-make-kfence-compatible-with-kasan-fix +++ a/mm/kasan/kasan.h @@ -3,6 +3,7 @@ #define __MM_KASAN_KASAN_H #include +#include #include #ifdef CONFIG_KASAN_HW_TAGS @@ -304,12 +305,20 @@ static inline u8 random_tag(void) { retu static inline void poison_range(const void *address, size_t size, u8 value) { + /* Skip KFENCE memory if called explicitly outside of sl*b. */ + if (is_kfence_address(address)) + return; + hw_set_mem_tag_range(kasan_reset_tag(address), round_up(size, KASAN_GRANULE_SIZE), value); } static inline void unpoison_range(const void *address, size_t size) { + /* Skip KFENCE memory if called explicitly outside of sl*b. */ + if (is_kfence_address(address)) + return; + hw_set_mem_tag_range(kasan_reset_tag(address), round_up(size, KASAN_GRANULE_SIZE), get_tag(address)); } --- a/mm/kasan/shadow.c~kfence-kasan-make-kfence-compatible-with-kasan-fix +++ a/mm/kasan/shadow.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -84,6 +85,10 @@ void poison_range(const void *address, s address = kasan_reset_tag(address); size = round_up(size, KASAN_GRANULE_SIZE); + /* Skip KFENCE memory if called explicitly outside of sl*b. */ + if (is_kfence_address(address)) + return; + shadow_start = kasan_mem_to_shadow(address); shadow_end = kasan_mem_to_shadow(address + size); @@ -101,6 +106,14 @@ void unpoison_range(const void *address, */ address = kasan_reset_tag(address); + /* + * Skip KFENCE memory if called explicitly outside of sl*b. Also note + * that calls to ksize(), where size is not a multiple of machine-word + * size, would otherwise poison the invalid portion of the word. + */ + if (is_kfence_address(address)) + return; + poison_range(address, size, tag); if (size & KASAN_GRANULE_MASK) { _ Patches currently in -mm which might be from akpm@linux-foundation.org are kasan-remove-kfence-leftovers.patch mm.patch mm-fix-initialization-of-struct-page-for-holes-in-memory-layout-checkpatch-fixes.patch mm-vmstat-fix-proc-sys-vm-stat_refresh-generating-false-warnings-fix-2.patch kfence-kasan-make-kfence-compatible-with-kasan-fix.patch linux-next-rejects.patch kmap-stupid-hacks-to-make-it-compile.patch set_memory-allow-set_direct_map__noflush-for-multiple-pages-fix.patch arch-mm-wire-up-memfd_secret-system-call-were-relevant-fix.patch kernel-forkc-export-kernel_thread-to-modules.patch