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=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, USER_AGENT_GIT 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 E4D44C4743C for ; Mon, 21 Jun 2021 15:47:39 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A1B1D61042 for ; Mon, 21 Jun 2021 15:47:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A1B1D61042 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=P5Sfo0LNGgQ9uLJqwEh1zQGDQaALjLd7yRAvOfuAEys=; b=0ltZ+3yraY+3Kb qthMEuY12NwMAAU17JolXs/emMfAMJqrl5aEk1lwp9FD8iWAy+cTV3jbSq/r/DMfZandTs3aIghYG jShuA74q5/d0DhImthLzoKjXqy8PychQS0+yW5s8JRis5U1jRlWb4p6jfBuTPieOuUAFtrKmkV5ZJ LcCpQk3CH6aIWPTeW7oZafSwuxsz/6e4Pkdxnvty5OWAd8l/H55wxcZhTzNChoW1Kw42pE2IoE0+e subfpdcey4BZZ/ZCcE4Mo6IM9zWwZvwXCFhrJ4PwohLzIfJbCWNfqaQ3OwQJcROMIVxs/h02ZIj5R 1oJnUldLsqKRQk0VdFeQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lvM7M-003yVC-UR; Mon, 21 Jun 2021 15:45:45 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lvM7G-003yTS-KR; Mon, 21 Jun 2021 15:45:41 +0000 X-UUID: 99a207d761d74de18619e6fb87396b59-20210621 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=eng4MkXhF6IiAFDOMo+SUNDfxBp5P3RDBTYY52X5RQQ=; b=ilIoUoDy75VfcZUbvFapF5Nktz4WKIxmQ3QRc+1Gq5+pN7b1aqtl516x6Dt2tXyBM4xfhI2JJPto6oy7yuAdVf/y/RvRn4tcQIa1E2zdCeK6iBMRWMxwuGxjJQoK4xHNo2NnoSo5hzLYLvuRB+Ak3elymPKjtY3YKDNb4JgWgkE=; X-UUID: 99a207d761d74de18619e6fb87396b59-20210621 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 986400988; Mon, 21 Jun 2021 08:45:35 -0700 Received: from MTKMBS07N2.mediatek.inc (172.21.101.141) by MTKMBS62N2.mediatek.inc (172.29.193.42) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 21 Jun 2021 08:45:34 -0700 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 21 Jun 2021 23:45:32 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas10.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Mon, 21 Jun 2021 23:45:32 +0800 From: To: CC: , Yee Lee , "Andrey Ryabinin" , Alexander Potapenko , Dmitry Vyukov , Andrew Morton , Matthias Brugger , "open list:KASAN" , "open list:MEMORY MANAGEMENT" , open list , "moderated list:ARM/Mediatek SoC support" , "moderated list:ARM/Mediatek SoC support" Subject: [PATCH] kasan: unpoison use memset to init unaligned object size Date: Mon, 21 Jun 2021 23:44:41 +0800 Message-ID: <20210621154442.18463-1-yee.lee@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210621_084540_125892_2D107006 X-CRM114-Status: GOOD ( 12.04 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Yee Lee This patch adds a memset to initialize object of unaligned size. Duing to the MTE granulrity, the integrated initialization using hwtag instruction will force clearing out bytes in granular size, which may cause undesired effect, such as overwriting to the redzone of SLUB debug. In this patch, for the unaligned object size, function uses memset to initailize context instead of the hwtag instruction. Signed-off-by: Yee Lee --- mm/kasan/kasan.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h index 8f450bc28045..d8faa64614b7 100644 --- a/mm/kasan/kasan.h +++ b/mm/kasan/kasan.h @@ -387,8 +387,11 @@ static inline void kasan_unpoison(const void *addr, size_t size, bool init) if (WARN_ON((unsigned long)addr & KASAN_GRANULE_MASK)) return; + if (init && ((unsigned long)size & KASAN_GRANULE_MASK)) { + init = false; + memset((void *)addr, 0, size); + } size = round_up(size, KASAN_GRANULE_SIZE); - hw_set_mem_tag_range((void *)addr, size, tag, init); } -- 2.18.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel