From patchwork Tue Dec 15 11:28:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?S3Vhbi1ZaW5nIExlZSAo5p2O5Yag56mOKQ==?= X-Patchwork-Id: 11974603 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=-17.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MIME_BASE64_TEXT,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,USER_AGENT_GIT 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 294F4C4361B for ; Tue, 15 Dec 2020 11:28:20 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6AB6322258 for ; Tue, 15 Dec 2020 11:28:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6AB6322258 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6A18B6B0036; Tue, 15 Dec 2020 06:28:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 62B646B005D; Tue, 15 Dec 2020 06:28:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4F2F06B0068; Tue, 15 Dec 2020 06:28:18 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0185.hostedemail.com [216.40.44.185]) by kanga.kvack.org (Postfix) with ESMTP id 366DB6B0036 for ; Tue, 15 Dec 2020 06:28:18 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id ECBC0363C for ; Tue, 15 Dec 2020 11:28:17 +0000 (UTC) X-FDA: 77595293034.18.pies84_08115af27423 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin18.hostedemail.com (Postfix) with ESMTP id C2143100ED9DE for ; Tue, 15 Dec 2020 11:28:17 +0000 (UTC) X-HE-Tag: pies84_08115af27423 X-Filterd-Recvd-Size: 4051 Received: from mailgw01.mediatek.com (mailgw01.mediatek.com [216.200.240.184]) by imf22.hostedemail.com (Postfix) with ESMTP for ; Tue, 15 Dec 2020 11:28:16 +0000 (UTC) X-UUID: 73f69f3caadc4722839a24822256c9c6-20201215 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=FBZwTwjUtWcuegFv5ryU4xs4jFRXyRxysG/xgcg45C4=; b=ORf6a/xaE2xgj8d/E7ppVvzaGbm1QvhbRVvdM2hFINxBoUhSvv0YDBkuc8gVmPxzB3uHugVTrmEXr8uH8YnyvedKvbyEeEr8/4zT30bGPwYUlUoqNuYSbpoDzVspd0A++/6dKsEaiL0lxn+o3Z3yXHEI8jk1RTeF1tHi2f1yxHg=; X-UUID: 73f69f3caadc4722839a24822256c9c6-20201215 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 229614273; Tue, 15 Dec 2020 03:28:11 -0800 Received: from MTKMBS01N1.mediatek.inc (172.21.101.68) by MTKMBS62N1.mediatek.inc (172.29.193.41) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 15 Dec 2020 03:28:10 -0800 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkmbs01n1.mediatek.inc (172.21.101.68) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 15 Dec 2020 19:28:07 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas10.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 15 Dec 2020 19:28:08 +0800 From: Kuan-Ying Lee To: Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , Andrew Morton , Matthias Brugger CC: , , , , , , , Kuan-Ying Lee Subject: [PATCH 1/1] kasan: fix memory leak of kasan quarantine Date: Tue, 15 Dec 2020 19:28:03 +0800 Message-ID: <1608031683-24967-2-git-send-email-Kuan-Ying.Lee@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1608031683-24967-1-git-send-email-Kuan-Ying.Lee@mediatek.com> References: <1608031683-24967-1-git-send-email-Kuan-Ying.Lee@mediatek.com> MIME-Version: 1.0 X-MTK: N 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: When cpu is going offline, set q->offline as true and interrupt happened. The interrupt may call the quarantine_put. But quarantine_put do not free the the object. The object will cause memory leak. Add qlink_free() to free the object. Signed-off-by: Kuan-Ying Lee Cc: Andrey Ryabinin Cc: Alexander Potapenko Cc: Dmitry Vyukov Cc: Andrew Morton Cc: Matthias Brugger Cc: [5.10-] --- mm/kasan/quarantine.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/kasan/quarantine.c b/mm/kasan/quarantine.c index 0e3f8494628f..cac7c617df72 100644 --- a/mm/kasan/quarantine.c +++ b/mm/kasan/quarantine.c @@ -191,6 +191,7 @@ void quarantine_put(struct kasan_free_meta *info, struct kmem_cache *cache) q = this_cpu_ptr(&cpu_quarantine); if (q->offline) { + qlink_free(&info->quarantine_link, cache); local_irq_restore(flags); return; }