Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4087295pxv; Mon, 26 Jul 2021 21:06:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwl1ojl2iD4Q612ER2dV21O0vLZ6ygKFQTmt1+pEBU/jg2oZWD/0evNvI4fdeEdRUdH1BRH X-Received: by 2002:a17:907:2d8e:: with SMTP id gt14mr19648564ejc.159.1627358779353; Mon, 26 Jul 2021 21:06:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627358779; cv=none; d=google.com; s=arc-20160816; b=0aOxfKwK8l639b/J+DLUzFDAhrJkRwiUQ0zKXLsnichNfGLbnYHx86b1H9n0w9pt9U /1VASUR3gbTUvTWnKYF/mFiUOb82agQ6Tjf1M0ECP32zbl3jD3vVMYayWyXkh9V0RB2J MBd4xxkLvN/+OmjyYg1qzRJY9b52r7GV7oPxMCrxpYCdQwHT4kYEA+7aRDBIN2Lpbwdp JjLhtXXHktLmoQogrqvg5C2qalrTUyCKMf9ccN7mn5VCtnQS8rrtlNy3O0HwvZXnhBsR iWZVfB0J2pwiA4YR1B+IPK2DrDvoL4LRWfRtiMg7r1eiViLk/WdODZ+LMZpjOuCBbst1 iQUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=+dhNLQwJBZaFDzsd70sVJ2R33ODovzhGvUebF9/mxLM=; b=nHg7fak2HF9spDo5qtfpyZdOAnU4F/6Pfl8u1JjLdaA+/pWaRlKYrWIdwKBH6KMDHO A2XPe7vJyOo2D5MZavRR80G1+4HkShd8JqdI1XJJWM3X3eOgPm3MCOTHw21IWqkyOGBP phdT1M7Rr9dE40OSvPe3Ar+7emLddVd2NfJD7QQDQMUZ8vl5f+4hKkjkVD/TTYznA5eK rjH7veRoS9CiUln1ixrG0pMiHYK2Ru7O4pKfcng3BleCRuYTYj9ZR+2RONElpTgBdS71 CDVNvsExVrpu/OwtWDc6XkAdhQIiyJFgPH9QFTKRH6D8nFZPdTATL8CHhRX2moV73pms Ewwg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id js9si1882026ejc.433.2021.07.26.21.05.52; Mon, 26 Jul 2021 21:06:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230130AbhG0EAr (ORCPT + 99 others); Tue, 27 Jul 2021 00:00:47 -0400 Received: from mailgw01.mediatek.com ([60.244.123.138]:36164 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S229441AbhG0EAp (ORCPT ); Tue, 27 Jul 2021 00:00:45 -0400 X-UUID: c2a56f32e34b4b9181147212f965d081-20210727 X-UUID: c2a56f32e34b4b9181147212f965d081-20210727 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 875007197; Tue, 27 Jul 2021 12:00:43 +0800 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 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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); -- 2.18.0