Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp303220ybl; Wed, 21 Aug 2019 19:44:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqypIINYv16+9782Yz9WoJYUmR1ZK+dUQoX/IeiGhAH8X5h1Rp0Ic46+nGmfa2AU0VTRo4yw X-Received: by 2002:a17:902:4d45:: with SMTP id o5mr33619932plh.146.1566441883559; Wed, 21 Aug 2019 19:44:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566441883; cv=none; d=google.com; s=arc-20160816; b=ZGlCERCJ5sxe+Mwz+G0bSgY8icjcynb6yETOBh7RU+ySN9KW9CKncAcCyDEd5xihic 1LOL6nITjh5mUjzFA/XcyhJRzvv8d+rDt7+SMuSaUnv+zmHe52ejzj1bd+Vs9E0Y9/Bs mEJ6409dq+bPSDZBglSFgIDa28W4husHaHnMnFv1hOVybWzfPVhmgJ+HQJYULvgqb6kE XDIAup2HzN9UA6VnsNW9spJyWjgyTiYVgR67XCMh81gkIpvqd+RLl7CIg7Y365k9DiuS DZJVAeucl1o8d1zbi0JXtFYmMbqFAiDOuUyHnx4a/NfTUK/j+fLIgYpvj85fCNSYmLr9 KwQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :references:in-reply-to:date:cc:to:from:subject:message-id; bh=4zTXT8np2oEv+GXqFGZA51ND/MraAhQ+aSBA7OKvwwk=; b=EzY4kxfjC74Qba9kyyOgxY/H2U7rKxokTOdtJ2qprVXx4eY4OytUaJuZPQlPdmJjtx ZF7GDNOcpMe9VXo5N1UjtN8KIarZYEDLLMssIXR3sWvOPJ3TyBWjxtovkikV3wm5v+oQ /lgNPldTtJmtuvVqM2Zb5GZBBZU/GL83t0pqNK/aeLr7DPf5rf0O8+ydii6cCU/O6ACa eaa8N+XW08gLhjo9RmJU+TTfhoaw579ClehlQQHdqzu9gFOyx2mEi1bm5R8jIBZvgzRg V6IvXaTFd20rTj7+ce53sPWecGkttcWhIBK5OWwwDqLBVHCvjXd2viXce0f3JkauQeYd 0Jmg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id 98si16333631plb.345.2019.08.21.19.44.28; Wed, 21 Aug 2019 19:44:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1730030AbfHVBWK (ORCPT + 99 others); Wed, 21 Aug 2019 21:22:10 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:51888 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727316AbfHVBWK (ORCPT ); Wed, 21 Aug 2019 21:22:10 -0400 X-UUID: 2740e10b36dc499fa5282ce2d54ec53c-20190822 X-UUID: 2740e10b36dc499fa5282ce2d54ec53c-20190822 Received: from mtkmrs01.mediatek.inc [(172.21.131.159)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0707 with TLS) with ESMTP id 1416285409; Thu, 22 Aug 2019 09:22:02 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs06n1.mediatek.inc (172.21.101.129) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Thu, 22 Aug 2019 09:22:02 +0800 Received: from [172.21.84.99] (172.21.84.99) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Thu, 22 Aug 2019 09:21:58 +0800 Message-ID: <1566436922.27117.0.camel@mtksdccf07> Subject: Re: [PATCH v4] kasan: add memory corruption identification for software tag-based mode From: Walter Wu To: Andrey Ryabinin CC: Alexander Potapenko , Dmitry Vyukov , Matthias Brugger , "Andrew Morton" , Martin Schwidefsky , Arnd Bergmann , Thomas Gleixner , Vasily Gorbik , Andrey Konovalov , Miles Chen , , , , , , Date: Thu, 22 Aug 2019 09:22:02 +0800 In-Reply-To: <3318f9d7-a760-3cc8-b700-f06108ae745f@virtuozzo.com> References: <20190806054340.16305-1-walter-zh.wu@mediatek.com> <1566279478.9993.21.camel@mtksdccf07> <3318f9d7-a760-3cc8-b700-f06108ae745f@virtuozzo.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3-0ubuntu6 Content-Transfer-Encoding: 7bit MIME-Version: 1.0 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2019-08-21 at 20:52 +0300, Andrey Ryabinin wrote: > > On 8/20/19 8:37 AM, Walter Wu wrote: > > On Tue, 2019-08-06 at 13:43 +0800, 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. > >> > >> We extend the slab to store five old free pointer tag and free backtrace, > >> we can check if the tagged address is in the slab record and make a > >> good guess if the object is more like "use-after-free" or "out-of-bound". > >> therefore every slab memory corruption can be identified whether it's > >> "use-after-free" or "out-of-bound". > >> > >> ====== Changes > >> Change since v1: > >> - add feature option CONFIG_KASAN_SW_TAGS_IDENTIFY. > >> - change QUARANTINE_FRACTION to reduce quarantine size. > >> - change the qlist order in order to find the newest object in quarantine > >> - reduce the number of calling kmalloc() from 2 to 1 time. > >> - remove global variable to use argument to pass it. > >> - correct the amount of qobject cache->size into the byes of qlist_head. > >> - only use kasan_cache_shrink() to shink memory. > >> > >> Change since v2: > >> - remove the shinking memory function kasan_cache_shrink() > >> - modify the description of the CONFIG_KASAN_SW_TAGS_IDENTIFY > >> - optimize the quarantine_find_object() and qobject_free() > >> - fix the duplicating function name 3 times in the header. > >> - modify the function name set_track() to kasan_set_track() > >> > >> Change since v3: > >> - change tag-based quarantine to extend slab to identify memory corruption > > > > Hi,Andrey, > > > > Would you review the patch,please? > > > I didn't notice anything fundamentally wrong, but I find there are some > questionable implementation choices that makes code look weirder than necessary > and harder to understand. So I ended up with cleaning it up, see the diff bellow. > I'll send v5 with that diff folded. > Thanks your review and suggestion. Walter