Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp342094rdb; Thu, 21 Dec 2023 10:36:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IGy/g7EI1gv9iNB1TVtQrVTqa2I/E2iRYInzsfMrAD29WZuYILdMSkXdhITkv51t0Npjjhl X-Received: by 2002:a05:622a:190:b0:427:7e6e:d597 with SMTP id s16-20020a05622a019000b004277e6ed597mr255435qtw.53.1703183770028; Thu, 21 Dec 2023 10:36:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703183770; cv=none; d=google.com; s=arc-20160816; b=lShgroJQi2HmTQcCPjxk2Tfypacy5fjOvDmqdijQCCRZTFwMlPgLQLlo559WV8/BmA /J4ig0aLhTu8lNXpiNDjdI73ozBHbSpQ5B/9JfcGDZVfEf7UL+Q1ezSbW84uV1+gZMOm bRYlB1eyNh9ViFquKLafOkq1B5xIsuV54EnZc8FVYsEzAxxSaUvhh+JXHSVA3IJ42NL2 9mMcE/arXCmKJ9E1RMLWqy35b/nxi/zInp5FbSVVu7JLGcPDrzOsZUFtAXw+hg6U0ixQ L0ScutJKoc96eTEq/GknLVy7OR1YHExvOlqsE1Sf+shhtk8f3EdboGbakVvc1CQMYg+L HyuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=9xuoTXuQnTI+pN/bKZ3i8KybAohyAUoP+IGmtMicRak=; fh=E9W45FwZb6Id+g4Lg+hTR4TMK1PXvrXS/qWrVP2FBRY=; b=GL6IfK/MQaxkQ1oHBV9ew1sexO78MpfWXB7bcYaibnRM6mtlSD4QWOAEh2NOvx8HNA 5XF6KABFcOdovBTx9lc6ytJjTDKPQsI3OLqkjY3/rIou2Y0vnY6z7o3rY/DF/qB0hZ6z yqXUreIAqFu+QqleSFSlR4dkMEKjqaNc9NE7Je5J6msVAri/iXoej4XfN/TmZrqJV+Fx JDhZNu6JfrbHwJYkZJKu+PTsNwxLaFTwNUCgrugx47uZc4Gsh8NKuvl1DF+l6hceJsu+ oplsG1BlnPWTMbVRlMOuWPjx3c4KHSUZ8/n4LsIVUFFjg0inTTluyZCSYULpYgTKorKc GuZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=WarMWAg0; spf=pass (google.com: domain of linux-kernel+bounces-8936-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8936-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id c4-20020ac87dc4000000b00423a5a04647si2554875qte.467.2023.12.21.10.36.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 10:36:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-8936-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=WarMWAg0; spf=pass (google.com: domain of linux-kernel+bounces-8936-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8936-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id BF5341C247CE for ; Thu, 21 Dec 2023 18:36:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2D1DD6518C; Thu, 21 Dec 2023 18:35:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="WarMWAg0" X-Original-To: linux-kernel@vger.kernel.org Received: from out-184.mta0.migadu.com (out-184.mta0.migadu.com [91.218.175.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B97F76280C for ; Thu, 21 Dec 2023 18:35:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT 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 --- 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; -- 2.25.1