From patchwork Thu Dec 21 18:35:40 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: 182403 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp611550dyi; Thu, 21 Dec 2023 10:36:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IEw7FbsfGmJgMgsxhK68Z+J919TmOiqH+k+H+6I9yPo4WeYGMVqvXmDBjVUrfBShuc5xPas X-Received: by 2002:a50:c319:0:b0:553:2e38:5f26 with SMTP id a25-20020a50c319000000b005532e385f26mr23279edb.7.1703183816585; Thu, 21 Dec 2023 10:36:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703183816; cv=none; d=google.com; s=arc-20160816; b=cFB0rbLqehdXr1DeJdqy46/SSWPm8/l4kF7ETpBGCojcPASLwT8cqifvbjdDhg+FHQ fGNFxfDFJHmn+2UEH9wlCgWtcF/JlF+TY0RaJ/e1lOdg1oMKR7W7JI7P+QkeDJtCGBGu KOmaRteHGepzDhc55ygiCtPaVOjQf9FMZg5AqapyD+hoYNm9LC31EzQqOcFQDB1b1dhZ uBXcmRpseMGC8QZmAOmfY3/ng888Q4GUExV3Ch77Eskt39KMDWSC0bfFIjCzn7CozwSF gK2I6LXeTE4QxvaEZ0ZtLogB+rBkPKCTZzcRmmEQU2qy85iUyga3OYfJGzdO3LCPhpN+ V72w== 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8938-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id v28-20020a50a45c000000b0055390294599si1087975edb.660.2023.12.21.10.36.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 10:36:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-8938-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8938-ouuuleilei=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 21C451F227B8 for ; Thu, 21 Dec 2023 18:36:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3A7B976095; Thu, 21 Dec 2023 18:35:55 +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 X-Migadu-Flow: FLOW_OUT X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785917673639783275 X-GMAIL-MSGID: 1785917673639783275 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 Reviewed-by: Marco Elver --- 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; /*