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=-0.7 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED 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 1CAB6C31E45 for ; Thu, 13 Jun 2019 15:50:36 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 E6CED20851 for ; Thu, 13 Jun 2019 15:50:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Uc17y0tC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E6CED20851 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-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=bombadil.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:Date: Message-ID:From:References:To:Subject:Reply-To:Content-ID:Content-Description :Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=SLSbx+0zF6IST8qsY9P9oyc8xpXPCoLLEhFxYJe/xCo=; b=Uc17y0tC4Y0033 jO196wlIulMz/HjKXxdmVr7OaMNUfBpQP1aUaMZ6I7QuRQuOjiu+ZURvaKzRKiMGzbLiZbmbMxIuI Q8nckG1ItXp0pvGV2Zdrlp9vfdypYAnfh9SeYrPBXjFBwzlWkxpL6QF05c3TkzNFwBqKtcd5OhfEF la9akHWFMJMTenjuocD2/KZ8uRRAUD48VOP2LyNitaKxRjFrpWe1qSiTyFJkn6bm5/J5YG0Mfn6Pn Q4IC1GuoUaEOSi2f61U9RHjESsVa0FJS3D8Oxo9JxC8DBOMDGlkdDmizSa9+Nvq6HsSJsRr5tF8Q7 c3BFXb28887BxKONYAMw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hbRzg-0000wP-Nl; Thu, 13 Jun 2019 15:50:28 +0000 Received: from relay.sw.ru ([185.231.240.75]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hbRzb-0000t1-7L; Thu, 13 Jun 2019 15:50:25 +0000 Received: from [172.16.25.12] by relay.sw.ru with esmtp (Exim 4.92) (envelope-from ) id 1hbRzR-0002en-B5; Thu, 13 Jun 2019 18:50:13 +0300 Subject: Re: [PATCH v3] kasan: add memory corruption identification for software tag-based mode To: Dmitry Vyukov References: <20190613081357.1360-1-walter-zh.wu@mediatek.com> From: Andrey Ryabinin Message-ID: <278bd641-7d74-b9ac-1549-1e630ef3d38c@virtuozzo.com> Date: Thu, 13 Jun 2019 18:50:25 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190613_085023_265592_72F267E0 X-CRM114-Status: GOOD ( 15.08 ) 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: wsd_upstream , Walter Wu , Vasily Gorbik , Arnd Bergmann , Linux-MM , Andrey Konovalov , "Jason A . Donenfeld" , kasan-dev , LKML , Pekka Enberg , Martin Schwidefsky , Miles Chen , Alexander Potapenko , David Rientjes , Matthias Brugger , linux-mediatek@lists.infradead.org, Joonsoo Kim , Christoph Lameter , Linux ARM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 6/13/19 4:05 PM, Dmitry Vyukov wrote: > On Thu, Jun 13, 2019 at 2:27 PM Andrey Ryabinin wrote: >> On 6/13/19 11:13 AM, Walter Wu wrote: >>> This patch adds memory corruption identification at bug report for >>> software tag-based mode, the report show whether it is "use-after-free" >>> or "out-of-bound" error instead of "invalid-access" error.This will make >>> it easier for programmers to see the memory corruption problem. >>> >>> Now we extend the quarantine to support both generic and tag-based kasan. >>> For tag-based kasan, the quarantine stores only freed object information >>> to check if an object is freed recently. When tag-based kasan reports an >>> error, we can check if the tagged addr is in the quarantine and make a >>> good guess if the object is more like "use-after-free" or "out-of-bound". >>> >> >> >> We already have all the information and don't need the quarantine to make such guess. >> Basically if shadow of the first byte of object has the same tag as tag in pointer than it's out-of-bounds, >> otherwise it's use-after-free. >> >> In pseudo-code it's something like this: >> >> u8 object_tag = *(u8 *)kasan_mem_to_shadow(nearest_object(cacche, page, access_addr)); >> >> if (access_addr_tag == object_tag && object_tag != KASAN_TAG_INVALID) >> // out-of-bounds >> else >> // use-after-free > > But we don't have redzones in tag mode (intentionally), so unless I am > missing something we don't have the necessary info. Both cases look > the same -- we hit a different tag. We always have some redzone. We need a place to store 'struct kasan_alloc_meta', and sometimes also kasan_free_meta plus alignment to the next object. > There may only be a small trailer for kmalloc-allocated objects that > is painted with a different tag. I don't remember if we actually use a > different tag for the trailer. Since tag mode granularity is 16 bytes, > for smaller objects the trailer is impossible at all. > Smaller that 16-bytes objects have 16 bytes of kasan_alloc_meta. Redzones and freed objects always painted with KASAN_TAG_INVALID. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel