From patchwork Tue Jul 27 04:00:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?S3Vhbi1ZaW5nIExlZSAo5p2O5Yag56mOKQ==?= X-Patchwork-Id: 12401439 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.0 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,MIME_BASE64_TEXT,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,URIBL_BLOCKED,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 886A9C4338F for ; Tue, 27 Jul 2021 04:10:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2B88460EB2 for ; Tue, 27 Jul 2021 04:10:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2B88460EB2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id BB9096B0036; Tue, 27 Jul 2021 00:10:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B41176B005D; Tue, 27 Jul 2021 00:10:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A09398D0001; Tue, 27 Jul 2021 00:10:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0240.hostedemail.com [216.40.44.240]) by kanga.kvack.org (Postfix) with ESMTP id 826546B0036 for ; Tue, 27 Jul 2021 00:10:51 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 2BA0A18559 for ; Tue, 27 Jul 2021 04:10:51 +0000 (UTC) X-FDA: 78407041902.01.C5BBF47 Received: from mailgw01.mediatek.com (mailgw01.mediatek.com [216.200.240.184]) by imf09.hostedemail.com (Postfix) with ESMTP id 9AE3430025AE for ; Tue, 27 Jul 2021 04:10:49 +0000 (UTC) X-UUID: c72817ba518c4cbe9ccfcbb31318ee77-20210726 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:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=Hxt3KJSiksSLT61csNYyDNidMjF1j3Q6QzzOsWfpmaY=; b=QgP4upqSe6hMAt3YMKthN3mT2v4Bhz2BkrItnpTCnkxBPZSct1K+AIAUa4A2rzuanNfFhs0AZerXdwRHppFS5cz0RS33wDXRJRqDj9X2NcakXWH+t+26SkPPUuFc6gUMiHSyxCacxxsH4tA8hW+/m2ZucldyP21X3t+2QouTRx0=; X-UUID: c72817ba518c4cbe9ccfcbb31318ee77-20210726 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 454653061; Mon, 26 Jul 2021 21:10:45 -0700 Received: from MTKMBS01N1.mediatek.inc (172.21.101.68) by MTKMBS62N2.mediatek.inc (172.29.193.42) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 26 Jul 2021 21:00:43 -0700 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs01n1.mediatek.inc (172.21.101.68) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 27 Jul 2021 12:00:42 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 27 Jul 2021 12:00:42 +0800 From: Kuan-Ying Lee To: Nicholas Tang , Andrew Yang , Andrey Konovalov , "Andrey Ryabinin" , Alexander Potapenko , Marco Elver , Chinwen Chang , Andrew Morton CC: , , , , , Kuan-Ying Lee Subject: [PATCH 1/2] kasan, mm: reset tag when access metadata Date: Tue, 27 Jul 2021 12:00:20 +0800 Message-ID: <20210727040021.21371-2-Kuan-Ying.Lee@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210727040021.21371-1-Kuan-Ying.Lee@mediatek.com> References: <20210727040021.21371-1-Kuan-Ying.Lee@mediatek.com> MIME-Version: 1.0 X-MTK: N Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=mediatek.com header.s=dk header.b=QgP4upqS; spf=pass (imf09.hostedemail.com: domain of kuan-ying.lee@mediatek.com designates 216.200.240.184 as permitted sender) smtp.mailfrom=kuan-ying.lee@mediatek.com; dmarc=pass (policy=none) header.from=mediatek.com X-Rspamd-Server: rspam02 X-Stat-Signature: 79cgntbjx9f53fqqz7gzobnkbmppidcc X-Rspamd-Queue-Id: 9AE3430025AE X-HE-Tag: 1627359049-720697 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Hardware tag-based KASAN doesn't use compiler instrumentation, we can not use kasan_disable_current() to ignore tag check. Thus, we need to reset tags when accessing metadata. Signed-off-by: Kuan-Ying Lee Acked-by: Catalin Marinas --- mm/kmemleak.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/kmemleak.c b/mm/kmemleak.c index 228a2fbe0657..73d46d16d575 100644 --- a/mm/kmemleak.c +++ b/mm/kmemleak.c @@ -290,7 +290,7 @@ static void hex_dump_object(struct seq_file *seq, warn_or_seq_printf(seq, " hex dump (first %zu bytes):\n", len); kasan_disable_current(); warn_or_seq_hex_dump(seq, DUMP_PREFIX_NONE, HEX_ROW_SIZE, - HEX_GROUP_SIZE, ptr, len, HEX_ASCII); + HEX_GROUP_SIZE, kasan_reset_tag((void *)ptr), len, HEX_ASCII); kasan_enable_current(); } @@ -1171,7 +1171,7 @@ static bool update_checksum(struct kmemleak_object *object) kasan_disable_current(); kcsan_disable_current(); - object->checksum = crc32(0, (void *)object->pointer, object->size); + object->checksum = crc32(0, kasan_reset_tag((void *)object->pointer), object->size); kasan_enable_current(); kcsan_enable_current(); @@ -1246,7 +1246,7 @@ static void scan_block(void *_start, void *_end, break; kasan_disable_current(); - pointer = *ptr; + pointer = *(unsigned long *)kasan_reset_tag((void *)ptr); kasan_enable_current(); untagged_ptr = (unsigned long)kasan_reset_tag((void *)pointer); From patchwork Tue Jul 27 04:00:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?S3Vhbi1ZaW5nIExlZSAo5p2O5Yag56mOKQ==?= X-Patchwork-Id: 12401425 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.0 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,MIME_BASE64_TEXT,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 E89F7C4338F for ; Tue, 27 Jul 2021 04:00:59 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 593DD60184 for ; Tue, 27 Jul 2021 04:00:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 593DD60184 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id E83226B0036; Tue, 27 Jul 2021 00:00:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E32586B005D; Tue, 27 Jul 2021 00:00:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D48658D0001; Tue, 27 Jul 2021 00:00:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0063.hostedemail.com [216.40.44.63]) by kanga.kvack.org (Postfix) with ESMTP id BCEA66B0036 for ; Tue, 27 Jul 2021 00:00:58 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 6769D1CFC5 for ; Tue, 27 Jul 2021 04:00:58 +0000 (UTC) X-FDA: 78407016996.09.0E2ABD3 Received: from mailgw01.mediatek.com (mailgw01.mediatek.com [216.200.240.184]) by imf07.hostedemail.com (Postfix) with ESMTP id 331D410022C1 for ; Tue, 27 Jul 2021 04:00:57 +0000 (UTC) X-UUID: c3879a71e49e46afbec061b49527a67e-20210726 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:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=mpXC/mrthXiEWq0igGvtpzzqWviS71zqDtVkSBpa2Lo=; b=V9ts2a4iCZooE8OWKLlFsx4qC1CR7O0VSICWxtNOS7OdUKyQg9S0c1JzILejiVv9tS47C9s554Cv3+95qGmwS3F6xRsGnaoswGn0PvWyw9qUr1xjqJWKriSBEUUop03h/6Qvg7xNi8u+lmUecLrJgYCvl0YztxXoUaItngVLVmw=; X-UUID: c3879a71e49e46afbec061b49527a67e-20210726 Received: from mtkcas67.mediatek.inc [(172.29.193.45)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 232804081; Mon, 26 Jul 2021 21:00:51 -0700 Received: from mtkmbs07n1.mediatek.inc (172.21.101.16) by MTKMBS62DR.mediatek.inc (172.29.94.18) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 26 Jul 2021 21:00:50 -0700 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 27 Jul 2021 12:00:48 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 27 Jul 2021 12:00:43 +0800 From: Kuan-Ying Lee To: Nicholas Tang , Andrew Yang , Andrey Konovalov , "Andrey Ryabinin" , Alexander Potapenko , Marco Elver , Chinwen Chang , Andrew Morton CC: , , , , , Kuan-Ying Lee Subject: [PATCH 2/2] kasan, mm: reset tag for hex dump address Date: Tue, 27 Jul 2021 12:00:21 +0800 Message-ID: <20210727040021.21371-3-Kuan-Ying.Lee@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210727040021.21371-1-Kuan-Ying.Lee@mediatek.com> References: <20210727040021.21371-1-Kuan-Ying.Lee@mediatek.com> MIME-Version: 1.0 X-MTK: N Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=mediatek.com header.s=dk header.b=V9ts2a4i; spf=pass (imf07.hostedemail.com: domain of kuan-ying.lee@mediatek.com designates 216.200.240.184 as permitted sender) smtp.mailfrom=kuan-ying.lee@mediatek.com; dmarc=pass (policy=none) header.from=mediatek.com X-Rspamd-Server: rspam02 X-Stat-Signature: 1mnt67wu1qwyy46ngan8ufomw3dy8hxi X-Rspamd-Queue-Id: 331D410022C1 X-HE-Tag: 1627358456-714170 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Text is a string. We need to move this kasan_reset_tag() to address but text. Signed-off-by: Kuan-Ying Lee --- mm/slub.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index 6dad2b6fda6f..d20674f839ba 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -576,8 +576,8 @@ static void print_section(char *level, char *text, u8 *addr, unsigned int length) { metadata_access_enable(); - print_hex_dump(level, kasan_reset_tag(text), DUMP_PREFIX_ADDRESS, - 16, 1, addr, length, 1); + print_hex_dump(level, text, DUMP_PREFIX_ADDRESS, + 16, 1, kasan_reset_tag((void *)addr), length, 1); metadata_access_disable(); }