Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp342487rdb; Thu, 21 Dec 2023 10:36:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IFiQkclHqaWSAFViK0OX0SLCBKXA8dHr3Roj/3kem4E7n80AhMaIWAQweVmCtt+C8ggcrOz X-Received: by 2002:a05:6a20:8e0d:b0:18a:da5a:3b17 with SMTP id y13-20020a056a208e0d00b0018ada5a3b17mr131847pzj.5.1703183813498; Thu, 21 Dec 2023 10:36:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703183813; cv=none; d=google.com; s=arc-20160816; b=0NZ+x5EwuZ+p6aBAHMikw1q4r5nNIrrucOnv6nITK4JaP3C9y+8qg/TWCp4ezxww+8 46VynYfiQNGTzO2V9sV/hFRSq8Z8yS5G4w4iYxUtEcwXdbBoEXXKAXCxAG9Yfbp26dbb rkNwgPNHYMw9d/uwDiDXZWlYkdS8vH6fjvHL1ECgEDH65pmkb+lKD2JDiOairIdKT0/g GSyORISJDzitGj6JfoyuSqSuD2jY23BJF9HVkyUiDQfDvB/kxPwyck7uVU6mKmD0Dl23 A/yq7/Why9Hxn56jSsyW4Fnb9GsXXdNnZ7j6jPb05dvGqeaOzVz63SMttdR2QuF9Yiiq 7pXQ== 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=FiI0FbwykV/2XbgOuJsaOX93jnuQZGsyNc8LlrDSdxY=; fh=E9W45FwZb6Id+g4Lg+hTR4TMK1PXvrXS/qWrVP2FBRY=; b=xDrxlQ/ydFRxi0gIeAmDQ1oCKITzHv157tJpKJYr7vfjWjEBgVcLOUuVCQ67Ddwwwy fcsfP9zinA05CfVYKOWWrSabXyGxv58MYccVBtJlZWomsDXGOgu9aQT+E7H0Kj12LWtQ rw552AtBQBkobtC4j0xikyKyMZ5pttMrM9Z+MV6wArteYWsLMKtKzLz7SdZlIbuRncMz C/Otaisio068Oi/jDAeagKC9SbSfunq/yb8GjbaUMgAjaZnmp4fvz1zk6ETKzKx396Ir Vax+RWS/qvRo71OmtFj32LF6wtQFJWJ336qDiVyVsq4SEK93jIvaoso7ofqxDb4YGamw 9IhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=iZOz0xdv; spf=pass (google.com: domain of linux-kernel+bounces-8938-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8938-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id m8-20020a17090a3f8800b0028bf094cad8si1424531pjc.173.2023.12.21.10.36.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 10:36:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-8938-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=iZOz0xdv; spf=pass (google.com: domain of linux-kernel+bounces-8938-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8938-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 015112882D0 for ; Thu, 21 Dec 2023 18:36:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 659A6651A4; Thu, 21 Dec 2023 18:35:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="iZOz0xdv" X-Original-To: linux-kernel@vger.kernel.org Received: from out-177.mta0.migadu.com (out-177.mta0.migadu.com [91.218.175.177]) (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 19DA8BA5F for ; Thu, 21 Dec 2023 18:35:50 +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=1703183749; 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=FiI0FbwykV/2XbgOuJsaOX93jnuQZGsyNc8LlrDSdxY=; b=iZOz0xdvhazUGbDD/nkQ4ayAtlGnpXZBnWnzL0gh008WaAjCs/ptKU+lof1bjeEEnJT4H3 m/04qiY03QGGFOPq+9Um1KjCZvu3EYR64rQmdOa8BsiMcU4UbcAkLwg4eDeQRQK3p7PEb3 QlQ59oWVTbABhYd7X+p6qVYXgnw5aDw= 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 4/4] kasan: simplify kasan_complete_mode_report_info for tag-based modes Date: Thu, 21 Dec 2023 19:35:40 +0100 Message-Id: <20231221183540.168428-4-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 memcpy the alloc/free tracks when collecting the information about a bad access instead of copying fields one by one. Fixes: 5d4c6ac94694 ("kasan: record and report more information") Signed-off-by: Andrey Konovalov --- mm/kasan/report_tags.c | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/mm/kasan/report_tags.c b/mm/kasan/report_tags.c index 688b9d70b04a..d15f8f580e2c 100644 --- a/mm/kasan/report_tags.c +++ b/mm/kasan/report_tags.c @@ -27,15 +27,6 @@ static const char *get_common_bug_type(struct kasan_report_info *info) return "invalid-access"; } -#ifdef CONFIG_KASAN_EXTRA_INFO -static void kasan_complete_extra_report_info(struct kasan_track *track, - struct kasan_stack_ring_entry *entry) -{ - track->cpu = entry->track.cpu; - track->timestamp = entry->track.timestamp; -} -#endif /* CONFIG_KASAN_EXTRA_INFO */ - void kasan_complete_mode_report_info(struct kasan_report_info *info) { unsigned long flags; @@ -80,11 +71,8 @@ void kasan_complete_mode_report_info(struct kasan_report_info *info) if (free_found) break; - 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 */ + memcpy(&info->free_track, &entry->track, + sizeof(info->free_track)); free_found = true; /* @@ -98,11 +86,8 @@ void kasan_complete_mode_report_info(struct kasan_report_info *info) if (alloc_found) break; - 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 */ + memcpy(&info->alloc_track, &entry->track, + sizeof(info->alloc_track)); alloc_found = true; /* -- 2.25.1