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=-12.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable 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 A40AAC433E6 for ; Fri, 28 Aug 2020 11:13:58 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 738F4207DF for ; Fri, 28 Aug 2020 11:13:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="TtPrnX/O"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="PjUoFCsQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 738F4207DF Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.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=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=TYeC21BZrcujn6lVJzcLvS9nvLZGpCJ8HLB/B5cSbo4=; b=TtPrnX/OLhUmj6iQwZ+yi9hxP r8MaKP+xbqlvC9tOi57HNAY9HLbnRnRj8taqYaDtySA814Gl+Ol0F6/VglzHxy+y8n8yVoyPLCavS BDsxJLAIuhQ6VmbSDvZmnga56WXajbkopSu4/c5TSUjMlVuPwqUdUEZYZdMlSqgBeCzRhKM6Q4U/0 Uk99+IjQP1HvXqUh3SISrGdnkTmQ+qtNViZ0iYJvycr2BYaX7T6+Igmh3Z5eKgBthC/odyhGhJXGx oyVw6/BHisgPBgz8J9Izjn/qTedl6TrnzJmci0Qv4YFfV6txwN33zEihUv7uLdhaaa6vPs8P6goEa 1Rbi+rK/Q==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kBcJ6-0003BV-1j; Fri, 28 Aug 2020 11:12:32 +0000 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kBcJ3-0003Ar-HT for linux-arm-kernel@lists.infradead.org; Fri, 28 Aug 2020 11:12:30 +0000 Received: by mail-wm1-x342.google.com with SMTP id t2so578208wma.0 for ; Fri, 28 Aug 2020 04:12:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=+4JiaYoS0HndrreBr2XTvIDvJUjGSip4KNY5rXBxq20=; b=PjUoFCsQIiBw798tVdvlNcVfbGwaZ/NnQkuUreKmIJcf5Eic+xteObdrqCyCZLeMyH FknyTtV0W5zJXvj7kzAoI3BIAg0CuJy7+gs6Zo1vIgbJprPCFQiE2l+SuC8KDyUZWI/o b2oUIMGaJnsushXZ5ogsjyadieMxykjFFQJ+bh5GWS3Sx/e0vBYbtHmmsdOs3ByvsKIm v8mDvcvYnc4Gk4isSC5pdnoKIeGF8Y8VOT1JzbT23keLO5XM5PldL8V2sPPwWRJH6NHB pb4c6SN/cYoYJiRFXjm1yXkl3SQ2pIrReBIj3VQJcJJeF8YQZtOwgV70/KmzKF7yfUzi nwtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=+4JiaYoS0HndrreBr2XTvIDvJUjGSip4KNY5rXBxq20=; b=T6hBkDz6Uc9inLjKIuUEE7RjICquONy+kWoCs5TOZqSf9WtvQMxt4DgPBWa79ugrrK 3jnE+yGWxR4I4FaW4t13lkn3IJ4oFEaVt75d2wB0aVtR+duPyutwsC/p0X1vOvSil+MK pjGl400W1LhLjJ0dm6j5nMOTHIJhFHfnf7LKbO8cMackzmFjCceihZLYFLiQI2mk9+e1 0h65sPSajvUyc4GRtORiPBn62zx9bTld9BaSjnafE8ocoMqgYU1hCLuf5DRUsQRe0fUX ph2iqAYFAW80rhhOrv6g7nGKfQT/8GP3PFtmo++mAV7K5KvmJndHnn5U5bi+f6wg+V9l vayw== X-Gm-Message-State: AOAM530hpDpCGi2boZtYUIyvHu7OPNP1o4VFh5LrQyW4C5mV6s20s1xx umr86l+tygPUjUqKx45EbzXUQw== X-Google-Smtp-Source: ABdhPJxwEdKAhCgV5UaEJGnDRILZnD/7YgaprlH2rfjyxiJodnAvFOjmY5uPay3ayBT/x4tgoL5qug== X-Received: by 2002:a1c:ed0e:: with SMTP id l14mr1090553wmh.140.1598613147805; Fri, 28 Aug 2020 04:12:27 -0700 (PDT) Received: from elver.google.com ([100.105.32.75]) by smtp.gmail.com with ESMTPSA id o128sm1639658wmo.39.2020.08.28.04.12.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Aug 2020 04:12:26 -0700 (PDT) Date: Fri, 28 Aug 2020 13:12:21 +0200 From: Marco Elver To: Andrey Konovalov Subject: Re: [PATCH 35/35] kasan: add documentation for hardware tag-based mode Message-ID: <20200828111221.GA185387@elver.google.com> References: <5d0f3c0ee55c58ffa9f58bdea6fa6bf4f6f973a4.1597425745.git.andreyknvl@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <5d0f3c0ee55c58ffa9f58bdea6fa6bf4f6f973a4.1597425745.git.andreyknvl@google.com> User-Agent: Mutt/1.14.4 (2020-06-18) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200828_071229_662286_80E24A35 X-CRM114-Status: GOOD ( 26.67 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, Branislav Rankov , Elena Petrova , Catalin Marinas , Kevin Brodsky , Will Deacon , linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, Alexander Potapenko , Evgenii Stepanov , Andrey Ryabinin , Andrew Morton , Vincenzo Frascino , Dmitry Vyukov 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 On Fri, Aug 14, 2020 at 07:27PM +0200, Andrey Konovalov wrote: > Add documentation for hardware tag-based KASAN mode and also add some > clarifications for software tag-based mode. > > Signed-off-by: Andrey Konovalov > --- > Documentation/dev-tools/kasan.rst | 73 +++++++++++++++++++++---------- > 1 file changed, 51 insertions(+), 22 deletions(-) > > diff --git a/Documentation/dev-tools/kasan.rst b/Documentation/dev-tools/kasan.rst > index a3030fc6afe5..aeed89d6eaf5 100644 [...] > -Tag-based KASAN uses the Top Byte Ignore (TBI) feature of modern arm64 CPUs to > -store a pointer tag in the top byte of kernel pointers. Like generic KASAN it > -uses shadow memory to store memory tags associated with each 16-byte memory > -cell (therefore it dedicates 1/16th of the kernel memory for shadow memory). > +Software tag-based KASAN uses the Top Byte Ignore (TBI) feature of modern arm64 > +CPUs to store a pointer tag in the top byte of kernel pointers. Like generic > +KASAN it uses shadow memory to store memory tags associated with each 16-byte > +memory cell (therefore it dedicates 1/16th of the kernel memory for shadow > +memory). It might be helpful to be more specific vs. saying "modern arm64 CPUs". Does the "modern" qualifier suggest not all arm64 CPUs support the feature? (HW tag-based KASAN below is specific, and mentions ARMv8.5.) > +On each memory allocation software tag-based KASAN generates a random tag, tags > +the allocated memory with this tag, and embeds this tag into the returned > +pointer. > > -On each memory allocation tag-based KASAN generates a random tag, tags the > -allocated memory with this tag, and embeds this tag into the returned pointer. > Software tag-based KASAN uses compile-time instrumentation to insert checks > before each memory access. These checks make sure that tag of the memory that > is being accessed is equal to tag of the pointer that is used to access this > -memory. In case of a tag mismatch tag-based KASAN prints a bug report. > +memory. In case of a tag mismatch software tag-based KASAN prints a bug report. > > Software tag-based KASAN also has two instrumentation modes (outline, that > emits callbacks to check memory accesses; and inline, that performs the shadow > @@ -215,9 +222,31 @@ simply printed from the function that performs the access check. With inline > instrumentation a brk instruction is emitted by the compiler, and a dedicated > brk handler is used to print bug reports. > > -A potential expansion of this mode is a hardware tag-based mode, which would > -use hardware memory tagging support instead of compiler instrumentation and > -manual shadow memory manipulation. > +Software tag-based KASAN uses 0xFF as a match-all pointer tag (accesses aren't > +checked). > + > +Software tag-based KASAN currently only supports tagging of slab memory. > + > +Hardware tag-based KASAN > +~~~~~~~~~~~~~~~~~~~~~~~~ > + > +Hardware tag-based KASAN is similar to the software mode in concept, but uses > +hardware memory tagging support instead of compiler instrumentation and > +shadow memory. > + > +Hardware tag-based KASAN is based on both arm64 Memory Tagging Extension (MTE) > +introduced in ARMv8.5 Instruction Set Architecture, and Top Byte Ignore (TBI). Is there anything inherently tying tag-based KASAN to arm64? I guess if some other architecture supports MTE, they just have to touch arch/, right? You could reword to say that "Hardware tag-based KASAN is currently only supported on the ARM64 architecture. On the ARM64 architecture, tag-based KASAN is based on both ..." Thanks, -- Marco _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel