From patchwork Mon Oct 23 16:22:49 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: 13433198 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 2E99BC001E0 for ; Mon, 23 Oct 2023 16:26:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B9B866B0117; Mon, 23 Oct 2023 12:26:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B4ADF6B0118; Mon, 23 Oct 2023 12:26:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A3A3A6B0119; Mon, 23 Oct 2023 12:26:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 913A06B0117 for ; Mon, 23 Oct 2023 12:26:16 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 5EE24B5C49 for ; Mon, 23 Oct 2023 16:26:16 +0000 (UTC) X-FDA: 81377253552.12.CAFE17C Received: from out-194.mta1.migadu.com (out-194.mta1.migadu.com [95.215.58.194]) by imf10.hostedemail.com (Postfix) with ESMTP id 96C6CC001C for ; Mon, 23 Oct 2023 16:26:14 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=Ne3J1RXv; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf10.hostedemail.com: domain of andrey.konovalov@linux.dev designates 95.215.58.194 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=1698078374; 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=uhMrVBrzgAoT1gwViC8KxLkH9OMZhix/uhvoEc70W98=; b=cB4FiwHZpoFxe68+G+XodRVGwWmz9mJCBAhLreNnTMLkM2t15hDQev3lfiNeQgcVOEusuO oUcrXHcgSNPd/XdpXA6SXAsFn8UddkVsm5BrN5va4NTOwg1egQN9NQM6GE/+YzdocprXyF XA4ix5PI9VzNVHfSPm6BHLtGLZdywWw= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=Ne3J1RXv; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf10.hostedemail.com: domain of andrey.konovalov@linux.dev designates 95.215.58.194 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1698078374; a=rsa-sha256; cv=none; b=CoK/GZGPIuS7QNovPkcaQWeuONCN+7v25qmTL3Yb9fQns/gKR27oab9YMlF3yMFW/NcKmt WG2fuQ9XtVOUk5H1Z4MXrJPqIOckBaJZR6cTyk2t6oitFktbu1eZXToIjXC7kXM0OyrLvZ FVvrzzmkp5PAYkc1DT3thLIDORLJTq0= 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=1698078373; 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=uhMrVBrzgAoT1gwViC8KxLkH9OMZhix/uhvoEc70W98=; b=Ne3J1RXv7CfIkYMjEOEAo2MOXXrLjJl0MG/nn5TuOVSCeJC7ACQ8Zc+U0+7fVaprnL1TwV YcPWlAN0bBL1/0CJWM+oWPOfzdH5fmC91XjSmronfj3U3HMmSByKdvCQOOSWPbS9RJ3nc5 z58ccvrjKa1GY9FZizpTtMWzArqCzuI= From: andrey.konovalov@linux.dev To: Marco Elver , Alexander Potapenko Cc: Andrey Konovalov , Dmitry Vyukov , Vlastimil Babka , kasan-dev@googlegroups.com, Evgenii Stepanov , Oscar Salvador , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH v3 18/19] kasan: check object_size in kasan_complete_mode_report_info Date: Mon, 23 Oct 2023 18:22:49 +0200 Message-Id: <97721c54e9ccacc494dbcfcd0cbd5f5aaab6973b.1698077459.git.andreyknvl@google.com> In-Reply-To: References: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: 96C6CC001C X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 3zood9smphts91cx75uhckeasmownjyd X-HE-Tag: 1698078374-506509 X-HE-Meta: U2FsdGVkX1/HWsVfVT3tWUXlstqC0cPf5bjzu8dRhBEk8YIGuxkby9Ou9l/Cc11/EUlkS2ONuECuIrW5fIlNz45aDKBgOsGDQs5/OijzVYZxfboae8fAUbb5O883lM7IxkfSgvTgs8CT3OdGRsnU0ld693QG/z155/i9vZZyqirZzCzONlF2K66v9HflFb6Sa+mq7BbDkYh4+Z+/JEXaOxnGSLZqijSaoqvXmNcDwcTY9P8bOyE0hidEsWvix/nQXzAEjZXsjA97i53pPjM4HYW7y80eAkCEi1xBFLLer6RYbJwzBEVq8A96HmBEzV0WLYFCwNwLn9nLF42r317bhxElEiIjKsrmUe5os9RHDewYfMioghepxNOPsZn0vbxdPP2aqQNrUtTUEBYemic/zTqeLdBEfLooKrGzQ9FDx9wvdJHimm9BZizwHDAW65dfE6uO5MgkiKM99x0NFc4zTx9oqlEN7w/Y6y5+6B95X9I/5BWBBqIWiSnVPojjF8ZGW1zpFm73xVVnZPuyR0U6E7LdxqeC6fPhtapm8tkG1J9RX49w397U6YpfujBcWH2f4tk434L3mrNDv6JiJHfYd6cnbYl5sU/FDfMUu+Wd+iqoQLxLvUJDwQf6+Lt+lfnLtNyZoCp+q60+tOnCNBcIcfBOZCaTB4ZAdIc2lpB0eBCL21FU6f6DWrYHQQsOZq6EHJQ/m9OnFK6ZBVFr7NAPZ6IUoPTHIJ/Jihcqcs1pwpJZJhWLplhSH0fcBP/bm+wBU7k3ZLljMCKShtFnBbeb0lx/kNUiY0x/Tkk0un5t3iBCfmTGQzMsJRGIu6LJmPZ9jLvdVgmQV4PfWsR4AWfF9lqCrLDzVEwpdVsPzXu/5H2jPm48bOnq85JXwWlbjFTK9EsS3Zd2f/ht+7wBXK+RqcLEwY3mw8CN2F2xt2FU3KUjJrvkGpnSOck8vBo+NE8Se2ViGXQi8UB/IyIQFOf SkwRRngL SJk0YWRp6CIgK6XR+Psc/lwZ984Ay602x+zic6wZyVBN+CnoTB4Ju7bKRYWH43tTWDLk9IDrDqiC80Fidfm6RvnbcbcAdFbr02rp88tfyheNtPYcsBLx7V/3mpO51EP6QclBEOrajOdhiErhpVZT17X+2PBI41vc+lFGkqfE99M1TRA8drUVYQRrofw== 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 Check the object size when looking up entries in the stack ring. If the size of the object for which a report is being printed does not match the size of the object for which a stack trace has been saved in the stack ring, the saved stack trace is irrelevant. Reviewed-by: Alexander Potapenko Signed-off-by: Andrey Konovalov --- Changes v2->v3: - Added missing "../slab.h" include for accessing a kmem_cache field. Changes v1->v2: - This is a new patch. --- mm/kasan/report_tags.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mm/kasan/report_tags.c b/mm/kasan/report_tags.c index 78abdcde5da9..55154743f915 100644 --- a/mm/kasan/report_tags.c +++ b/mm/kasan/report_tags.c @@ -7,6 +7,7 @@ #include #include "kasan.h" +#include "../slab.h" extern struct kasan_stack_ring stack_ring; @@ -58,7 +59,8 @@ void kasan_complete_mode_report_info(struct kasan_report_info *info) entry = &stack_ring.entries[i % stack_ring.size]; if (kasan_reset_tag(entry->ptr) != info->object || - get_tag(entry->ptr) != get_tag(info->access_addr)) + get_tag(entry->ptr) != get_tag(info->access_addr) || + info->cache->object_size != entry->size) continue; if (entry->is_free) {