Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4007178pxk; Tue, 29 Sep 2020 11:38:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmhKLl6twr3tcxevQa0hWoe9Zcm8U1bwgSsgJ1lSQVp1ElDhqEPiQhWdciNZaN+zkElzhl X-Received: by 2002:a17:906:9353:: with SMTP id p19mr5159302ejw.403.1601404728475; Tue, 29 Sep 2020 11:38:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601404728; cv=none; d=google.com; s=arc-20160816; b=lhNxBTIr+Qc1/0dwaMi4QuWNL1ZFFuei4GCbbKAXUWmWSCUjecWJtGGMizEd5ihsJz YpbktcJWfHMNTD72b6AFfOrEkTq5ULDNn4h+oBzbcwccOHxeyAco/MJ0JjLF+Se0C6sc B8Cj0wYdGjsxSBzMg52BplwdqkImaEoGDvwaSf8w6iXsOePCHeMd6kA8SHZIILIXhGbs gic6ua9YZiAucBipk0KQqn9/mixY4Q3D1Pc1Pgkk8YVwdTH6DEH8DjDSXqbzVZBt/s7U ZGdEfKddZQlJ3MpZQ118wv3Zv6hXlxf90V25b8lsiYperoAmkszJXfaPcQU7AjAiJLcT NuGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=G75o1vtwJEJqsn4jLLLjWPJ87JkHTslNJiSKbRH/W+U=; b=PJTSzMrQooMUZPHtybhVNU85HU+WwK/laCR4WH2KdWawlei3mrWUZgaTDkr2inAUKs B3rCXpyPwXrso9KYKmgq1ZyekZiavlxynfntfZCAMp/Npjl8YSw5oByFVY+fEHLiuF28 C8XxEtHK+AvxupKeOBsig5B7J5Qg2+z6wcMVMdxY4SM0zBCzmTUQoAzSnxSM6hgxBEd0 w4lUk+g5VNzEk5i2FKBaacqpAhPNy87EoCaxhrxjlaDAC1Zf8F2H+pmJNk2uQxlz2cXl dlBAzSMoXf8Uk1T76P43EKx+nMr3ZqiVPOiMGbL28a8h7ZTfGn1laieROnEeXpkTpBB+ qV1g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bu5si3262865ejb.750.2020.09.29.11.38.24; Tue, 29 Sep 2020 11:38:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728377AbgI2SgL (ORCPT + 99 others); Tue, 29 Sep 2020 14:36:11 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:37314 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728361AbgI2SgH (ORCPT ); Tue, 29 Sep 2020 14:36:07 -0400 Received: by mail-wr1-f67.google.com with SMTP id z4so6575279wrr.4 for ; Tue, 29 Sep 2020 11:36:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=G75o1vtwJEJqsn4jLLLjWPJ87JkHTslNJiSKbRH/W+U=; b=bUj1+avKaSFc1eXz+D+DAri2xiUkIrYaziGBi1iUF0IQdHCiTSENwugzXzzMT1fnit pX8f7MnwAs+CHwyfLbkL4ZEfzMjkLouR+QET7yc0nRwwOJfwK4EypIVsfz7fWuV0Dsj7 bjnFzC7Bx+A3ZwtdStHi55tYuUIyhcOE3LgmNtLjXp+M+VpYEnpgoLiVulLHQA4W/vPz h9woMQkHQvdTern8AwUU89dQjDpgSg/FmnX3Ln9nfZJCIRNwm4/jrEHEl/bMpS6iY4Z7 EuCcwlus399wxFPCVjJ31sISfb6QZC2w0e8ljzt0iDZgYh3Wnwir71gZpfGmVhLjrpdH 5wcg== X-Gm-Message-State: AOAM533hnNABMBORZ+7GRuTSteLl3k7D8WViwnsEnmUT9wUokNY3fwRw +4oBuptrwrASF23zRKw3J4A= X-Received: by 2002:adf:e58b:: with SMTP id l11mr6203909wrm.210.1601404565480; Tue, 29 Sep 2020 11:36:05 -0700 (PDT) Received: from localhost.localdomain ([185.248.161.177]) by smtp.gmail.com with ESMTPSA id b188sm12151271wmb.2.2020.09.29.11.36.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Sep 2020 11:36:04 -0700 (PDT) From: Alexander Popov To: Kees Cook , Jann Horn , Will Deacon , Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Masahiro Yamada , Masami Hiramatsu , Steven Rostedt , Peter Zijlstra , Krzysztof Kozlowski , Patrick Bellasi , David Howells , Eric Biederman , Johannes Weiner , Laura Abbott , Arnd Bergmann , Greg Kroah-Hartman , Daniel Micay , Andrey Konovalov , Matthew Wilcox , Pavel Machek , Valentin Schneider , kasan-dev@googlegroups.com, linux-mm@kvack.org, kernel-hardening@lists.openwall.com, linux-kernel@vger.kernel.org, Alexander Popov Cc: notify@kernel.org Subject: [PATCH RFC v2 6/6] mm: Add heap quarantine verbose debugging (not for merge) Date: Tue, 29 Sep 2020 21:35:13 +0300 Message-Id: <20200929183513.380760-7-alex.popov@linux.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200929183513.380760-1-alex.popov@linux.com> References: <20200929183513.380760-1-alex.popov@linux.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add verbose debugging for deeper understanding of the heap quarantine inner workings (this patch is not for merge). Signed-off-by: Alexander Popov --- mm/kasan/quarantine.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/mm/kasan/quarantine.c b/mm/kasan/quarantine.c index 4ce100605086..98cd6e963755 100644 --- a/mm/kasan/quarantine.c +++ b/mm/kasan/quarantine.c @@ -203,6 +203,12 @@ void quarantine_put(struct kasan_free_meta *info, struct kmem_cache *cache) qlist_move_all(q, &temp); raw_spin_lock(&quarantine_lock); + + pr_info("quarantine: PUT %zu to tail batch %d, whole sz %zu, batch sz %lu\n", + temp.bytes, quarantine_tail, + READ_ONCE(quarantine_size), + READ_ONCE(quarantine_batch_size)); + WRITE_ONCE(quarantine_size, quarantine_size + temp.bytes); qlist_move_all(&temp, &global_quarantine[quarantine_tail]); if (global_quarantine[quarantine_tail].bytes >= @@ -313,7 +319,22 @@ void quarantine_reduce(void) quarantine_head = get_random_int() % QUARANTINE_BATCHES; } while (quarantine_head == quarantine_tail); qlist_move_random(&global_quarantine[quarantine_head], &to_free); + pr_info("quarantine: whole sz exceed max by %lu, REDUCE head batch %d by %zu, leave %zu\n", + quarantine_size - quarantine_max_size, + quarantine_head, to_free.bytes, + global_quarantine[quarantine_head].bytes); WRITE_ONCE(quarantine_size, quarantine_size - to_free.bytes); + + if (quarantine_head == 0) { + unsigned long i; + + pr_info("quarantine: data level in batches:"); + for (i = 0; i < QUARANTINE_BATCHES; i++) { + pr_info(" %lu - %lu%%\n", + i, global_quarantine[i].bytes * + 100 / quarantine_batch_size); + } + } } #endif -- 2.26.2