From patchwork Thu Dec 21 18:35:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: andrey.konovalov@linux.dev X-Patchwork-Id: 13502530 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B4EDC35274 for ; Thu, 21 Dec 2023 18:35:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E5DA96B007B; Thu, 21 Dec 2023 13:35:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DE7426B0080; Thu, 21 Dec 2023 13:35:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C87876B0085; Thu, 21 Dec 2023 13:35:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id B2D606B007B for ; Thu, 21 Dec 2023 13:35:51 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 7F1531C0C1F for ; Thu, 21 Dec 2023 18:35:51 +0000 (UTC) X-FDA: 81591679302.21.3A55C5C Received: from out-177.mta0.migadu.com (out-177.mta0.migadu.com [91.218.175.177]) by imf24.hostedemail.com (Postfix) with ESMTP id 9B37418000D for ; Thu, 21 Dec 2023 18:35:49 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=WarMWAg0; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf24.hostedemail.com: domain of andrey.konovalov@linux.dev designates 91.218.175.177 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1703183749; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=9xuoTXuQnTI+pN/bKZ3i8KybAohyAUoP+IGmtMicRak=; b=VF5HSyxsOc4IsmqMPLKPCy745WMT4sPdJW3RrMIr3w9IbLcbJm4gBCYDYn7FOR1V4AOln9 YxImP5kXlrOPSwfWOARWjarxRrT5jFgPen4nudXOb6W/dOkcTDWdPewD+k291mL1AnJlPm MgDI+5rPsjretiFNk8nVR9SzRGoJmi8= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=WarMWAg0; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf24.hostedemail.com: domain of andrey.konovalov@linux.dev designates 91.218.175.177 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703183749; a=rsa-sha256; cv=none; b=8cfEMTlIslq3ZClBvDJVZ1EIIE3fd/20m6M5jPTLiqvkjax2dV9GFDslHJfb+bUrkKyP+l 8OTVLjMWuXZH/hqELimugVNZygWeSunOv1naegwz+GRupwJBsFsfxiCbdZ0LKE+LSTxVv9 rCwtBIjvCxjhjofX3RxGslW2lvyHTj0= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1703183747; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9xuoTXuQnTI+pN/bKZ3i8KybAohyAUoP+IGmtMicRak=; b=WarMWAg0K7SHak78ygWtlpgqTMwt7mumTYTiIrRXvERxbmLV9b2mB09CJkEoY/kvKqecGT LJD1Iz9YrXuxQjpfGtqzVdMCmE1Di3rxLYHjeVLXbJ+cka5BV4sF8NvnLlPNSEtQ8xSxsE gYC+xeKuS4JVZvylLWKrrqmi4VV2GMA= From: andrey.konovalov@linux.dev To: Andrew Morton , Juntong Deng Cc: Andrey Konovalov , Marco Elver , Alexander Potapenko , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH mm 2/4] kasan: reuse kasan_track in kasan_stack_ring_entry Date: Thu, 21 Dec 2023 19:35:38 +0100 Message-Id: <20231221183540.168428-2-andrey.konovalov@linux.dev> In-Reply-To: <20231221183540.168428-1-andrey.konovalov@linux.dev> References: <20231221183540.168428-1-andrey.konovalov@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: 9B37418000D X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: ccywk1g3ng75j4mdba8w6jienzpehmqd X-HE-Tag: 1703183749-131537 X-HE-Meta: U2FsdGVkX1/Kgv8nOYEqqxCLyq6nV3B6CXJitTrGdCt9GquMXSWAHov+hX7IG84/sLeOW+brzHIqpjqE4qk0eYE1UHLaBmRMXLsHa7Ag0scU4r4GptOm2bxQhldsZviOWtMRPnDgtn4RxInu9rdrFCGK8H5H3ESy/jGTQCA/9lBqeDWfjrdU/LGaeqSM47bqKneZLgXpXX/lMOm4QRzIqMLQtDHDx5AsmwhJk7OtZGRJKbKaguplyw4R0zXy7tU4TSHy45aKKV+RoctZnXcpq0fNoWJeLApT975Mn8h+ErfD17M3T/FcVNwBJPKanXNk0jO7JHm9fNqVWStIEV0FKJYHbRkj9rOU1SebsaorZQVKw4lVrkamdMX9neUCzu+QJYfywHWrLIB/1jCVfh9+P0nvva+ohVNB60TM9AsNnLOl9pMyB5Olf9CDa3f8bzDFMIX6G3S8g9U1dTP2+MhnnVDDMM2D2nhQxDVQroNLPTu6yZeYVHBro0aUmXiOuB0rI23B0rHbM1hpvj/DS872Fk3uwBekG8qB59M3i3gaT8O5MhDCG6W3l+NCuR5wutSbqbl9Tlll7UojydUj0PU2P668YNA9RkxyZBdiq5/NLX6ul7vmVVZg7VVbMgcjmv8b3pAUX2tTauiTzmMokLRgGQ3W06O1mB8mzoLaLzL705vUKj5tUuUw5k13Sk8UkUrdw2VSIAA+0a5YucMkegMKxZeIwer9MJ6/jBeNdsJclFAhVD9VS6M7ucKfXG6xljDHXyH1px7wA+j6AUskYQ1jb/lLvQviNKJk+aQf4QGVV+Vw+HyB5r3leh9qBSi8J/g+J5W41ZRcZe3lVHeW3MFVFqlnhREphN3ri4XDkiOVBrv/0P2J3IHVA7rufZ+L1IuhlbxAH7ps7z3AngLIIEcXyT9AsNmJuzCs0TRZmwi7d5D+NvnPsbV8sp2bF9Ud/H1FJGKHPwRAlzDrZuf0Lg8 rGOG4ga4 YwaXlVLGV9GiyMaX26c8AVTSqnipruNeG26cu8LGwufPwebftZ4w8hGbaBM034Nad+mKq6wAr9ErgcViWBm/saJCVqSeIGIF6kod8uElPzpM9jIAckm7cSuUKtGj7Kmk2CDTyvF3tc7wQE1+gm3dV0jjzXKaOUfwgU83HIC1PuaHSBvhKA1IMhtE4IZ4FzXQSF63Mv9tvfaFZxkaRCq4/fXrNpHCzwxxUGLhu 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: List-Subscribe: List-Unsubscribe: From: Andrey Konovalov Avoid duplicating fields of kasan_track in kasan_stack_ring_entry: reuse the structure. Fixes: 5d4c6ac94694 ("kasan: record and report more information") Signed-off-by: Andrey Konovalov Reviewed-by: Marco Elver --- mm/kasan/kasan.h | 7 +------ mm/kasan/report_tags.c | 12 ++++++------ mm/kasan/tags.c | 12 ++++++------ 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h index 5e298e3ac909..9072ce4c1263 100644 --- a/mm/kasan/kasan.h +++ b/mm/kasan/kasan.h @@ -279,13 +279,8 @@ struct kasan_free_meta { struct kasan_stack_ring_entry { void *ptr; size_t size; - u32 pid; - depot_stack_handle_t stack; + struct kasan_track track; bool is_free; -#ifdef CONFIG_KASAN_EXTRA_INFO - u64 cpu:20; - u64 timestamp:44; -#endif /* CONFIG_KASAN_EXTRA_INFO */ }; struct kasan_stack_ring { diff --git a/mm/kasan/report_tags.c b/mm/kasan/report_tags.c index 979f284c2497..688b9d70b04a 100644 --- a/mm/kasan/report_tags.c +++ b/mm/kasan/report_tags.c @@ -31,8 +31,8 @@ static const char *get_common_bug_type(struct kasan_report_info *info) static void kasan_complete_extra_report_info(struct kasan_track *track, struct kasan_stack_ring_entry *entry) { - track->cpu = entry->cpu; - track->timestamp = entry->timestamp; + track->cpu = entry->track.cpu; + track->timestamp = entry->track.timestamp; } #endif /* CONFIG_KASAN_EXTRA_INFO */ @@ -80,8 +80,8 @@ void kasan_complete_mode_report_info(struct kasan_report_info *info) if (free_found) break; - info->free_track.pid = entry->pid; - info->free_track.stack = entry->stack; + info->free_track.pid = entry->track.pid; + info->free_track.stack = entry->track.stack; #ifdef CONFIG_KASAN_EXTRA_INFO kasan_complete_extra_report_info(&info->free_track, entry); #endif /* CONFIG_KASAN_EXTRA_INFO */ @@ -98,8 +98,8 @@ void kasan_complete_mode_report_info(struct kasan_report_info *info) if (alloc_found) break; - info->alloc_track.pid = entry->pid; - info->alloc_track.stack = entry->stack; + info->alloc_track.pid = entry->track.pid; + info->alloc_track.stack = entry->track.stack; #ifdef CONFIG_KASAN_EXTRA_INFO kasan_complete_extra_report_info(&info->alloc_track, entry); #endif /* CONFIG_KASAN_EXTRA_INFO */ diff --git a/mm/kasan/tags.c b/mm/kasan/tags.c index c13b198b8302..c4d14dbf27c0 100644 --- a/mm/kasan/tags.c +++ b/mm/kasan/tags.c @@ -100,8 +100,8 @@ static void save_extra_info(struct kasan_stack_ring_entry *entry) u32 cpu = raw_smp_processor_id(); u64 ts_nsec = local_clock(); - entry->cpu = cpu; - entry->timestamp = ts_nsec >> 3; + entry->track.cpu = cpu; + entry->track.timestamp = ts_nsec >> 3; } #endif /* CONFIG_KASAN_EXTRA_INFO */ @@ -134,15 +134,15 @@ static void save_stack_info(struct kmem_cache *cache, void *object, if (!try_cmpxchg(&entry->ptr, &old_ptr, STACK_RING_BUSY_PTR)) goto next; /* Busy slot. */ - old_stack = entry->stack; + old_stack = entry->track.stack; entry->size = cache->object_size; - entry->pid = current->pid; - entry->stack = stack; - entry->is_free = is_free; + entry->track.pid = current->pid; + entry->track.stack = stack; #ifdef CONFIG_KASAN_EXTRA_INFO save_extra_info(entry); #endif /* CONFIG_KASAN_EXTRA_INFO */ + entry->is_free = is_free; entry->ptr = object;