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=-23.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, 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,USER_IN_DEF_DKIM_WL 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 4B001C2B9F4 for ; Tue, 22 Jun 2021 09:01:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EEDB061353 for ; Tue, 22 Jun 2021 09:01:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EEDB061353 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3514C6B0036; Tue, 22 Jun 2021 05:01:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2EEE46B006C; Tue, 22 Jun 2021 05:01:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 141C46B0070; Tue, 22 Jun 2021 05:01:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0199.hostedemail.com [216.40.44.199]) by kanga.kvack.org (Postfix) with ESMTP id CB2056B0036 for ; Tue, 22 Jun 2021 05:01:34 -0400 (EDT) Received: from smtpin38.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 6A3C5181AEF10 for ; Tue, 22 Jun 2021 09:01:34 +0000 (UTC) X-FDA: 78280766508.38.669E8EC Received: from mail-ot1-f42.google.com (mail-ot1-f42.google.com [209.85.210.42]) by imf08.hostedemail.com (Postfix) with ESMTP id A097B8019128 for ; Tue, 22 Jun 2021 09:01:33 +0000 (UTC) Received: by mail-ot1-f42.google.com with SMTP id g19-20020a9d12930000b0290457fde18ad0so6642868otg.1 for ; Tue, 22 Jun 2021 02:01:33 -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=E3vujFtQzQ6HHb36nCRkPnI6sILbeapGxmxAb4EfnkI=; b=CB752prxx4dAwLiJh978X4UEniRLciLoj78ygr06BhzO9Zg7gd4UEFbVgZXdlVMHDt p2vaKWQ1OJcHnvkvP5Tu45vm8+XZy0OhLLxui1fAfHsP5/d4JeU6Idj+wyDXEF93AVl6 SUMEwVJYMziAOsHVQ9vDsGCZHT873ntwOguGUK2ALiLzW6WBKUyUDKWOrMmyiu0C17s5 RP8HZEa2qe1olyrZy6gNVC1IJ3jJ58ILo6TsaqFcAlBXYK6PmUJPOyIpNV8Jpwvgvlut xYAdLL+t/fKOXk9CaBN/ZTnLpMInTCxfXCSoqiVG3oc34ZJ6Q5DFL97vyZEHdqRQCBpJ kOuQ== 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=E3vujFtQzQ6HHb36nCRkPnI6sILbeapGxmxAb4EfnkI=; b=l+PwNG6E/oLE+0uUiqorkQy7QZSlCZ89rVxyZxZjDcBSKhOKBUD5tZ2K+5D28wVoRr fC/Mcc3QHHWvDUpk9pa9HuMboVhGEw904BVBBANhoH1dhrvkfgemb1LbHV+bvp8dcF8G ZCXLmVaYF7FuFvISL0Iyz7w8WRRgz3Po2Yqcs1GokCMpbyZTQbMCFYZeOpxWlVu6JUuw f8Z3BKVP7gtJWWGz3PnlKUvERpU600mxdIanW/QapqxGXexH2+/mp+B7yaENEyqlFaLT WUvgonnco84pzVcDIx6FgcIyajfEsKVbZE5Udye+LKj8rmTm23ad6SlwNMCHckH4jDdy xNgw== X-Gm-Message-State: AOAM530i8mb9ZEM+DDUwIv9EP5bJYCPIq0kZXuvfpWs1HihWCWQW+IhS ceOLbvsZUo+bZVWPmDGo0g093sDaIYxEFgQ15rR0Pw== X-Google-Smtp-Source: ABdhPJz6x9ikQTihlpl50ySejohRlYsuuYzk1020DWbzWFDGxvVI6FgPvghPiE/lufEm9zK+hYyHAKWDluvyY14hCZw= X-Received: by 2002:a05:6830:1bcb:: with SMTP id v11mr2292496ota.251.1624352492722; Tue, 22 Jun 2021 02:01:32 -0700 (PDT) MIME-Version: 1.0 References: <20210622084723.27637-1-yee.lee@mediatek.com> In-Reply-To: <20210622084723.27637-1-yee.lee@mediatek.com> From: Marco Elver Date: Tue, 22 Jun 2021 11:01:21 +0200 Message-ID: Subject: Re: [PATCH] kasan: [v2]unpoison use memzero to init unaligned object To: yee.lee@mediatek.com Cc: andreyknvl@gmail.com, wsd_upstream@mediatek.com, 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" Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: A097B8019128 Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=google.com header.s=20161025 header.b=CB752prx; spf=pass (imf08.hostedemail.com: domain of elver@google.com designates 209.85.210.42 as permitted sender) smtp.mailfrom=elver@google.com; dmarc=pass (policy=reject) header.from=google.com X-Stat-Signature: pjzzb19k1teqb8ifs1z64jj68wngb5pe X-HE-Tag: 1624352493-623220 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: On Tue, 22 Jun 2021 at 10:48, wrote: > > From: Yee Lee > > Follows the discussion: https://patchwork.kernel.org/project/linux-mediatek/list/?series=504439 The info about the percentage of how frequent this is could have been provided as a simple reply to the discussion. > This patch Add memzero_explict to initialize unaligned object. This patch does not apply to anything (I see it depends on the previous patch). What you need to do is modify the original patch, and then send a [PATCH v2] (git helps with that by passing --reroll-count or -v) that applies cleanly to your base kernel tree. The commit message will usually end with '---' and then briefly denote what changed since the last version. https://www.kernel.org/doc/html/latest/process/submitting-patches.html#the-canonical-patch-format > Based on the integrateion of initialization in kasan_unpoison(). The hwtag instructions, constrained with its granularity, has to overwrite the data btyes in unaligned objects. This would cause issue when it works with SLUB debug redzoning. > > In this patch, an additional initalizaing path is added for the unaligned objects. It contains memzero_explict() to clear out the data and disables its init flag for the following hwtag actions. > > In lab test, this path is executed about 1.1%(941/80854) within the overall kasan_unpoison during a non-debug booting process. Nice, thanks for the data. If it is somehow doable, however, I'd still recommend to additionally guard the new code path by a check if debug-support was requested. Ideally with an IS_ENABLED() config check so that if it's a production kernel the branch is simply optimized out by the compiler. > Lab test: QEMU5.2 (+mte) / linux kernel 5.13-rc7 > > Signed-off-by: Yee Lee > --- > mm/kasan/kasan.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h > index d8faa64614b7..edc11bcc3ff3 100644 > --- a/mm/kasan/kasan.h > +++ b/mm/kasan/kasan.h > @@ -389,7 +389,7 @@ static inline void kasan_unpoison(const void *addr, size_t size, bool init) > return; > if (init && ((unsigned long)size & KASAN_GRANULE_MASK)) { > init = false; > - memset((void *)addr, 0, size); > + memzero_explicit((void *)addr, size); > } > size = round_up(size, KASAN_GRANULE_SIZE); > hw_set_mem_tag_range((void *)addr, size, tag, init); > 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/20210622084723.27637-1-yee.lee%40mediatek.com.