From patchwork Wed Sep 13 17:14:43 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: 13383631 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 A948BEE01F1 for ; Wed, 13 Sep 2023 17:18:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4A1606B027C; Wed, 13 Sep 2023 13:18:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 451E76B027D; Wed, 13 Sep 2023 13:18:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 31A6E6B027E; Wed, 13 Sep 2023 13:18:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 1F44E6B027C for ; Wed, 13 Sep 2023 13:18:08 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id E451B80454 for ; Wed, 13 Sep 2023 17:18:07 +0000 (UTC) X-FDA: 81232232214.04.C37CA87 Received: from out-230.mta1.migadu.com (out-230.mta1.migadu.com [95.215.58.230]) by imf02.hostedemail.com (Postfix) with ESMTP id 2EAF780029 for ; Wed, 13 Sep 2023 17:18:05 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=Kykiqu4a; spf=pass (imf02.hostedemail.com: domain of andrey.konovalov@linux.dev designates 95.215.58.230 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=1694625486; 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=gGKJxtryqSg7zyzOR+J62w3w1hKrmZ/huaWffkkgHB8=; b=hHQ3AbbM/UtgRxHlWtvyPfxbwwdHs7FLjiTS2bWm4crnb2FHcNnqh4944EXK0Jesg6EDzt W0NxjXcELOXt2JaojiE6deCqzO0hJUHgpskH9eUu0ZfqjZa4Z6UF/rgKWUiCepR2m68/HV gmQa81o01X3gBvltQoBZQB9mpmGundI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694625486; a=rsa-sha256; cv=none; b=G7dcw70ao6PIHXAjFcATE+5nO63JoNwIAGg1D6mS+MAYRrJDvzDvToNiM5C7W0zUe/XNQ0 Q7av+c59tixf6chBUCgJC9HgBhpHdiBan51hUL9lQuyRG+DJ2iVy9NByfV0p5a69iKlCOa 777tpvD6O8V0hQanETYFZ4UQtE11es0= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=Kykiqu4a; spf=pass (imf02.hostedemail.com: domain of andrey.konovalov@linux.dev designates 95.215.58.230 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev; dmarc=pass (policy=none) header.from=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=1694625484; 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=gGKJxtryqSg7zyzOR+J62w3w1hKrmZ/huaWffkkgHB8=; b=Kykiqu4aZApYf03YebHa3Dl/Iiz3dyOXmVXrrBHmpydAQBwIdJhL3HLDTzwCu05bpW7SeU 7532l7l5s0ccuWBVga6HibBP/hh1Jt3T/r7Xexqvuo0EKwyd5lqVv2v2D3IiN0BK5IbTfw g5lfY7rNPM1SE6bV/kcFjLK6Jf0r1ds= 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 v2 18/19] kasan: check object_size in kasan_complete_mode_report_info Date: Wed, 13 Sep 2023 19:14:43 +0200 Message-Id: <293d73bcd89932bc026263d3df8ee281ad3f621f.1694625260.git.andreyknvl@google.com> In-Reply-To: References: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Stat-Signature: dm4ud9t1tj4nmgm1ztwe7e8u78akgzkf X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 2EAF780029 X-Rspam-User: X-HE-Tag: 1694625485-650634 X-HE-Meta: U2FsdGVkX19FY5ZzWrYYWSquRODlMXV9KOjfCjLGsqxoq8DXj+WfkgBx7u5pc2feYzfW2MuVZheXr7lozmTwvzibtIxOX3WQnsNSMoa5DTTsgLXUD/kcGl35/HKs9MSa2F5tEZp9rOj1t2cQeh9qgb7xVuX36CFXxba4d3+2jVhO9QUa7ggLV/EsQnLtkxCwSIglSC1yQ+ACzBab6/nTKz1FJtv2ZQ/CZiHY7UsjiNk3rWXiHCxqlTKhLpf7ez79DhDcxMp+1hNn2XVqcjf3/AmOhVTxOmFpA6tb4tTbbZIEBWb8yJZEiKahuQWAJEYL/C25Gx5O0RT0CNlLBT50WPhnboWfIvvJMH1EJGAi8w0B85Q1LrA4UG8cNa4sClSFvBGsJIs1l3ZwsCdolFrKfqcVF04pnkztbN9OOR2d7b3MmFHS+zuLlA5O6q9l6zaVVP+TWH0/PU6y8Po1Yl5nKV8eMuJ6YSXQ+U3PhkQLDVUA5hulW5e5aGYhq85lbEffLwwy5hpaakNOIc2FJmmCdx1wOBP4urjpyBTcsmXqCSmhA4SKZTWauixC09Ya9xElQ7NpOfZwqyIrNPCUq/46R+eB0aPBSX5eJlk+yLUzcwIl5uta2xg8tQj2bwOMR89VbwoLjsbSCvSgGuU/4V1W3yelDG4xfzr18cIy+OEU5dUnmKsizgXzZPDk5/X1t1IXQT9eQAfcyIVP+GB70LTxhXOqRlUJ2Yiw52P+aB7VYNg8Sa1SULPxrx8k3b7naKCRZ9nFQRYu+u6GR+SFGAvMXNg4ld47LnXsLqey7sQ4F9TvBRxQHB9tbfI3Is/orgHplQHZqcKduNqoSIB0KQ+bh6v8vpv41rEFuF304Es+MkEj6lCJCbZD9WPHeyK4ZsWHh9sOL8yhoFsNjMT6cI7Pvnt0Q9LcRGrE2AD0d6pNZ3BFUfT4hSJ5vN2uA229/FINXE9EcfPntXWxS/1Q0XR tiDq1zEE JGkCV+kBSNP8eu1xbTNNE5xLi1iCv2Js7gDfLI2VaV51SBKEKNe72qETU4jlCRUvltA+4K4sNhUCNGs3+RsxqhF6Ykyavt1XVun0L4SvautJ2vJFE8ghzaPZjqVuopBB63Psl2TD8hJDQLxvxRQnrj7/pBQ== 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: 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. Signed-off-by: Andrey Konovalov Reviewed-by: Alexander Potapenko --- Changes v1->v2: - This is a new patch. --- mm/kasan/report_tags.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/kasan/report_tags.c b/mm/kasan/report_tags.c index 78abdcde5da9..98c238ba3545 100644 --- a/mm/kasan/report_tags.c +++ b/mm/kasan/report_tags.c @@ -58,7 +58,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) {