Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4176395pxv; Tue, 27 Jul 2021 00:12:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJycW5GDrgGcN8iBwCXhvLsZwtzFSo2HG6HHSIuC3a1wlwMFze3rGrMZZPz08ZcCzR/KQ2IE X-Received: by 2002:a6b:490d:: with SMTP id u13mr18210246iob.176.1627369923402; Tue, 27 Jul 2021 00:12:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627369923; cv=none; d=google.com; s=arc-20160816; b=BGmSYuEO5Zl08KQiI5iIkPC/MVTScYOKo1Veo2K7I8g8vVATwx4Te/RDigNz9hNEHc ZwlA7AmjEWesTeqEkHv5/nbw8iMIteRGD9IAIT0Ka5aIDCLVqBBYeen297eNxIUglw5+ QVw+8NCRN4ByQxUWDJa4ccXwc5ORcecYqN0asB644KpeDxb1+PwNBwFm05werVk2sbL2 sUIENVP3MtOZk+mvp8pl3RFVx4IXCjKjTdznsPIJxT1IkW+tEndoucd2D/5HUNP2xHMX JdTCXU7QsPoAobRT/Jgn0nnIOqXLuwd3+P+ZPO+Ig/Ceq2jo3PmhyzdkdzsR5B1PJy1a JVnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=T4jXR1i3kQRbLOtYJPUwTyuXvag/F8LgWkncG8JS3kw=; b=RtTwG9C/HOVAXol6XPo0KbPSoKk0Mxf5EVA+txf3HEy0Oy+6AN12rEXIp90kLQEbiN qNy7rMrz29mo4tstNJmn3bERFKftoDkeZUwFGnRKmR0CjKp5OT6xjT8gyzhKOTMTw7dG j+6H2QT1MhY5yTwggJLNs5aoEK1HeFTbf0Nbye2umTPiTEF9QubdtpM8Y80HY84opHne IROhx9/ukLlcrUuKD36IFsxKBKidqxmc0/p98Ja05Yil4XIn57AHLJHFbnLMoa89EVsR Q6HzIzPNbMOO2yhN2UkgijOtayJie27z0FSNca1ZE1OlAUJO98jO0wm+nRMaCRgP+I0R OZrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ez4vH2iS; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u16si2442418jat.19.2021.07.27.00.11.48; Tue, 27 Jul 2021 00:12:03 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=ez4vH2iS; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235762AbhG0HLF (ORCPT + 99 others); Tue, 27 Jul 2021 03:11:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235612AbhG0HLE (ORCPT ); Tue, 27 Jul 2021 03:11:04 -0400 Received: from mail-ot1-x335.google.com (mail-ot1-x335.google.com [IPv6:2607:f8b0:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4E24C061757 for ; Tue, 27 Jul 2021 00:11:03 -0700 (PDT) Received: by mail-ot1-x335.google.com with SMTP id 68-20020a9d0f4a0000b02904b1f1d7c5f4so11579730ott.9 for ; Tue, 27 Jul 2021 00:11:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=T4jXR1i3kQRbLOtYJPUwTyuXvag/F8LgWkncG8JS3kw=; b=ez4vH2iSyB0oa1ojnnUH/oppE2vInZw2DCUOsIJMczkkbCo0ZS4HOfnR+wwt08JB1/ 7q1jjUTru/9XpQaSTbBlRwAZtowDWooKcMqnfiEfIf1Dr8CKgwrQCM/qlxXAhd7KKXkf rU7MWbV7FnnRDNoOH5oR5N8n5zhUCreFiQaVQaR+w5K5l34zgfnqfD8MBJGoWoqZfyfM Nu7zTgE2WC5ZGRr6Pevcop7KacBGQyqippbdLEG86KFE9yVcfj4cdhkbsSXLb+YuJG6O AfhzUPokeRZQcTgonnXM/FDIkMgo7udEpWmVphlhnRQSPhM0vZsM21fHWLj//wG5unao Tukg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=T4jXR1i3kQRbLOtYJPUwTyuXvag/F8LgWkncG8JS3kw=; b=sYsH9UMjVRfE76rAT4DyKpwh4LL6NTkAVHOHcoxclnm45/TCwMr7i5gNVQpavzhRmz luIxDkF0HEyh18FQytLLydSH0+c5X6kBRkuSH0SDmGiA9hBdadNJAZYwXCjgSgiTxMNg QQFtP6cngP7/ZtBpTzDgiishZ7Z3EaFNXPprVIKSEi3oog3Nw82ktLJ6JLI//Rl4W5vQ xq5kl2q8dV62N4iMPceETSBmKFvtGbfy3xxg9nvPVlx63iN+KZ8kcKtQzIHsRyuIlBci OeEDv7HTyeqK/y9H8ToI+rJcucFhrTQ3rYpnT8CkVSqgYfaU9TivcopNRSDpvv7tKMK4 SBJg== X-Gm-Message-State: AOAM531bUI27ljCkRv/PttSRriJ1xYonimg8b1x/HwOAakbrkDokI7EP ESw1hsN3smpo77RMNrWA1jqtStv+44BOr60EM5O89Q== X-Received: by 2002:a9d:d04:: with SMTP id 4mr15077003oti.251.1627369862852; Tue, 27 Jul 2021 00:11:02 -0700 (PDT) MIME-Version: 1.0 References: <20210727040021.21371-1-Kuan-Ying.Lee@mediatek.com> <20210727040021.21371-2-Kuan-Ying.Lee@mediatek.com> In-Reply-To: <20210727040021.21371-2-Kuan-Ying.Lee@mediatek.com> From: Marco Elver Date: Tue, 27 Jul 2021 09:10:51 +0200 Message-ID: Subject: Re: [PATCH 1/2] kasan, mm: reset tag when access metadata To: Kuan-Ying Lee Cc: Nicholas Tang , Andrew Yang , Andrey Konovalov , Andrey Ryabinin , Alexander Potapenko , Chinwen Chang , Andrew Morton , kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Catalin Marinas Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org +Cc Catalin On Tue, 27 Jul 2021 at 06:00, Kuan-Ying Lee wrote: > > 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 This looks reasonable, but the patch title is not saying this is kmemleak, nor does the description say what the problem is. What problem did you encounter? Was it a false positive? Perhaps this should have been "kmemleak, kasan: reset pointer tags to avoid false positives" ? > --- > 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 > > -- > You received this message because you are subscribed to the Google Groups "kasan-dev" group. > To unsubscribe from this group and stop receiving emails from it, send an email to kasan-dev+unsubscribe@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgid/kasan-dev/20210727040021.21371-2-Kuan-Ying.Lee%40mediatek.com.