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: 13502533 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 00266C46CD4 for ; Thu, 21 Dec 2023 18:35:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C8AD16B0088; Thu, 21 Dec 2023 13:35:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AB4656B008A; Thu, 21 Dec 2023 13:35:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 905136B008C; Thu, 21 Dec 2023 13:35:52 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 5EFF26B008A for ; Thu, 21 Dec 2023 13:35:52 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 31D4E807CE for ; Thu, 21 Dec 2023 18:35:52 +0000 (UTC) X-FDA: 81591679344.11.558BDF7 Received: from out-175.mta0.migadu.com (out-175.mta0.migadu.com [91.218.175.175]) by imf04.hostedemail.com (Postfix) with ESMTP id 90DC64000A for ; Thu, 21 Dec 2023 18:35:50 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=iZOz0xdv; spf=pass (imf04.hostedemail.com: domain of andrey.konovalov@linux.dev designates 91.218.175.175 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1703183750; 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=FiI0FbwykV/2XbgOuJsaOX93jnuQZGsyNc8LlrDSdxY=; b=JsyAODUybcDxmVujtdi/rPnonMBiNLiPBBDNlP7JTZXS95xMnxqIIR60BxUkpp0KIVbfwr k8Yc286L+GFFVYuv2/PFJrWBssG95Qt873Zgf/sTbFUcRFfGqGvi63JqP+teQv9f/zVIF4 zVN5ytiQeikAw7Z/MWhPW3cfrSlRhFo= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=iZOz0xdv; spf=pass (imf04.hostedemail.com: domain of andrey.konovalov@linux.dev designates 91.218.175.175 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703183750; a=rsa-sha256; cv=none; b=p4G8sQ397W6pNdTd5qHQCaER50PqpHbJYd/s8J4ZpIxACuFijJUouTDfVvh0fdJqKDekRH ajQZNKWLBzKW/X+JEek8x39ur2PhpRChYjy1nVS5K4UWN5KMAx7jU1BxzOmANyTfNZ+Jqd 1/sAplKJpJUNCV3PoBsWjYYW2MvhIM4= 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> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: 90DC64000A X-Rspam-User: X-Stat-Signature: jfcfu3zz5do9rqfhg8ip313aua9u8175 X-Rspamd-Server: rspam01 X-HE-Tag: 1703183750-729480 X-HE-Meta: U2FsdGVkX19+nMmFrcTbHGvjyLELV7CaM8d3t3ECToy6/A2s0JpNbZn15ATHCKP0+ToCTHtUNsJzrkxc9SU6UQs8NxibWLQqHkJibtx5r0tIppnD/D6RcHCC7EmXhJqFvQwU/hxjD+Po+3KFtai1L6zXGYklx9yyK2wjHkX4L2mohG/hqOL+RcBx7ZSdebH3LKWvAa36buTxA+QfuezZ2Qgl2zgXCsm1CoRNZkPwHH41ZUVLwBcg6YvOjFurenKqrl2l42nO6nS6Sd7fYAAqJN7m/10+AECND9gWhI1wNGmJwWigXesqUgaecoZVayITfuEYIVOVkxFJ9kqWEnZJd+7diIhs0riBcoXJnk0zs7LT7M6oFbslv+EgC9mDnNyVfh0vbGxAxcK05v/WAsXbTgZidFwDLThUgHupLisd27y1f48CnoIBEQRb/1JgtlC+vhVs0VTKdgmVRqG9L857UwGcoslH+x0LCUpN7jWI7nWejtv/MDShvX3xKqgn/4vhachscFkFdJI1S4rxMJZhjzeViMt9oOM1TW7TCagiM3a+63PEcOIsM9UNxKRcTk3aPDr3r6BwmgsIU3cdEvwgz5sf1J1WsE22Mvl1ldwKGcEqoixgw27HtN/aHu3NKBue97h/QmC57GHLGAiD/zXxYYH0sUB1ys8QCaQ5ah+SYUVYmX3OajgfqTUGN8p/7P9rGVPaPKQxMG8b+5M/ZqIcdp9wBfcNlLrpWEDUCYpdeC/XnAcUrDg1AFSXmEdB97EEtoMZR+WF9paXy8lDL2tQZ0F3qn8z73Y58vuI3mnNEOVWnB0RRQkxxntN8Audq+S/WFNtyQCKG6yFyjIC7YW+cj5OXjT+BU87EnsbESWIdWmQhxZYIFDVzMmJ2bCN16HjmHKyxNbV/16zMsOzg92YPtpm7XkqRND5zazsQB4A07Ch894gF6I1dIwahM/BR8D14RxOJBRUBsY= 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 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; /*