From patchwork Mon Nov 20 17:47:17 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: 13461833 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 C2212C2BB3F for ; Mon, 20 Nov 2023 17:50:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5B0D76B0384; Mon, 20 Nov 2023 12:50:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 513D76B0386; Mon, 20 Nov 2023 12:50:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 254716B0388; Mon, 20 Nov 2023 12:50:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 086D56B0384 for ; Mon, 20 Nov 2023 12:50:47 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id CE5F91CAEAF for ; Mon, 20 Nov 2023 17:50:46 +0000 (UTC) X-FDA: 81479072892.09.D5FA36B Received: from out-174.mta1.migadu.com (out-174.mta1.migadu.com [95.215.58.174]) by imf17.hostedemail.com (Postfix) with ESMTP id 1C34B4001F for ; Mon, 20 Nov 2023 17:50:44 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=lATFUJLN; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf17.hostedemail.com: domain of andrey.konovalov@linux.dev designates 95.215.58.174 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=1700502645; 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=RMWEKcj6s/0VSN2juwyup7FFFhOwiUHGtBmePB/+CEpJ/yafg311vA0NnNZ+bbx2lpNk2y ynonv7RWcFyXuBXBNlBiKfYw7nttSj9uAXPIoa1aJd+BD2F/5j3m8rQ4bOuL680tPsWO+E gYXGoSO9eb5dajMDHW3G8UU/8O0E618= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=lATFUJLN; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf17.hostedemail.com: domain of andrey.konovalov@linux.dev designates 95.215.58.174 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700502645; a=rsa-sha256; cv=none; b=eds7kq8eGCcWGLS0fkVbsCxvFxGvq2XH6CESg5mXLnbUGB2tL1ZZd7wBjflL5BQa0sjyg3 Pm6dvvuSSQ1JDlkHEyp58gaTo4HisJDM2XQC3RfGK2851ItSn8K5JO2Zf9d+Wthy/+MohA vVuFoxjj9cI1+o9EQwBaIp9GHNk1MSk= 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=1700502643; 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=lATFUJLNYsof+QZ6G2sBXsnC9Q+wIKDyc8lFVJDjx9RK2nGA9FoeQs6kQO+6hjM8HBefIP eURADnY2Rf+gcAsebe+mW3WuHxDxbtNbYaSjhKQqLHNAk7mVow4Kb9CTZdG5zssygETF+r BwY3IBxnt51rdnlRs7VhwlO0TNcSVR8= From: andrey.konovalov@linux.dev To: Andrew Morton Cc: Andrey Konovalov , Marco Elver , Alexander Potapenko , Dmitry Vyukov , Vlastimil Babka , kasan-dev@googlegroups.com, Evgenii Stepanov , Oscar Salvador , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH v4 19/22] kasan: check object_size in kasan_complete_mode_report_info Date: Mon, 20 Nov 2023 18:47:17 +0100 Message-Id: <68c6948175aadd7e7e7deea61725103d64a4528f.1700502145.git.andreyknvl@google.com> In-Reply-To: References: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: 1C34B4001F X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 45zsud6kppy1u749nfep7mdonygpdhyr X-HE-Tag: 1700502644-319821 X-HE-Meta: U2FsdGVkX19Mg/g8zgucnyidCEUYw4UDUaYivh9ax/8R7oQmS6fsnPTkN8ASKt5Qm0SCB1QZ5fPTPZk+Yh/jlUYeOqK1OPsMXV8FDj5A2NFb2oVvjD8hqGc9KfulDPm5bFQXNRXILlJUMJ0zO1Pze++2A/QlvyVridZIthUJ8xjTT32TaOOVs8kpP7U4ziH5VjBx53motOvoMtfbzIidTdyjQh6fyZiYPZ7f46XR+DRT3NTIRYXzfDixcB012pHo0YlJwXwFtVYt9n3k4o45gaIa6lyKXHg+k8YpC14DXOV+3lTjdgklkCTH15bw4TASIxD6IoKsH/ZiO2A1CiSOT3Wn7QMYnJedlxVhViNHoHQZ2nn5xpdJisFskm5I8LsYOG/aDD1B0aVGEQH5wILT/1fyUDwDMOMV7qUeEg/7FX1TqStKJIx/zciqP3NieOGass+QFLpGjj3XRiKVGQTECcVQF7jJ9oow0RynKbATadDeykV8gn3N5X+StGrmOHEbQklPSZYrQ0OEKI3ou1fh8xJlP2FWFdQK5tFwqdm+Oh+Xr0gQIj3pACNrZF2n074uqi0bcfuDkfx3IGiLaL6+CBiTucUtpW84uqT5qpEY4ADRj/D7UyiqWWa/pyqWDjZ/GEv3eI/Ke2NXBmcaCB58YzJoPuepgQPlOMJ6Rlxe5xWF0u6G0zrb//yKDHrC2eLL4PqoupKleyz/Jw3OcLymLrJ14C8CoxbQkt4jkHixnvBf6YRg8pibXvQ2aE7VC2CjOsoAjvKoL99JQk4zgUWPPgXVXmSnmgMFEjtfklDH7/xvY8G6dnPWCIFEFxuzIYaMDSzlt+zzEpKUxzk+mb7IKXkrAClDMmbQ8/m66uFOlG1GUla4T1o+gxYLaSNdZvDR+sQAtMS1WMLer6foDgKeFmnFD3162g7FCsGqoHvyb+0HSx0vBgky+DJpJ+K40mbCs+gLx1UGWZxS0pZThdM CsyhEjV3 0SI/ug98CEwxnmqLfjpdmhvwHwu3wkqzCMjq04eznwCpLULhx0aN8G5Kh45FOaVcTz0pv2kH8VhCEWtNOGDUNGEFi2u3eCne4Nv2+JofaFIUEB/vql64KXF7WsBpIPXRxRZcPDW02QTQSo5o= 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) {