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: 139029 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:a8d:b0:3f2:4152:657d with SMTP id gr13csp10597vqb; Wed, 13 Sep 2023 11:42:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF7hS22u/MPVF7YC3W89Vpl8CDghfYIL6DPE6xR9eCsEvTQ46os4Umq/jYsC3S1osHYKiQr X-Received: by 2002:a17:902:dacd:b0:1c3:3f7b:9cf1 with SMTP id q13-20020a170902dacd00b001c33f7b9cf1mr4908623plx.0.1694630524910; Wed, 13 Sep 2023 11:42:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694630524; cv=none; d=google.com; s=arc-20160816; b=XqGYi3EkU6P1rkwjILUkOn+mSE3MRDEeCdaAz1qA5ZFd0sINDH+5PbS5WKRYW+B4pn wtPW3jdACFoVzn77GjBLjZnO5EA/sUYbSzPHuFEY7jCthx3Iei6YERyYqcNL0w9Zke2d m2aLCLlKoaWqyx8xxT/UPeeU1hD7jWY7JihZ5nCHj8Z5SHhR/CPHYN79SnQLO2UbwEci k1djK/3D67XvBbawtKiaDFo9tfFlHHW2zz8g9+ybzsoUmI98S3siyZkdmsJRUTlTjbKl jx56rndSU5Z8iAVSCbqWK08rTQmf++KnCLH2596A+yCYBE2K2nJncogbbfQcqCS2vKgY k7XQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gGKJxtryqSg7zyzOR+J62w3w1hKrmZ/huaWffkkgHB8=; fh=nfQSbTp1dWHt2Ier1Up8UhVNdXOqoJJLNvTrpT3jJEk=; b=RAhJqh4Z2q3+XxTWKSEOB2DgxOjAMa+TntACN0PET+UDUrXf6anhgtynFXHIFZrKJw d8hyOkecI0HdiN0amVy0Eq9RUay8SAgghMA3eVJK0POCnK3nwIAWylJJbFX9lsBOAWSv 8XM7LhOK30vpchTYDNUjLlhX3R8yfISa1lu8SQ6s4NIcd5QJpyTk0aVvT88G5mjMjjH7 jW9eeT+J1L9ETekii9U5Yi+3bKLxS1tKpqJp9GskwVWevqPnCqUibhvbjd+lStwZ7qxJ DGkUI7N0E0WLjUFDrJj6j0ot+aBIWENZKZic9SsZyvZJrMB5EaAQ7ArOn9ePaCfjRipu 5piQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=Kykiqu4a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id cp6-20020a170902e78600b001b89ce303e4si10716151plb.195.2023.09.13.11.42.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 11:42:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=Kykiqu4a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 65C308311B5B; Wed, 13 Sep 2023 10:18:54 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231777AbjIMRSt (ORCPT + 34 others); Wed, 13 Sep 2023 13:18:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231202AbjIMRSd (ORCPT ); Wed, 13 Sep 2023 13:18:33 -0400 Received: from out-227.mta1.migadu.com (out-227.mta1.migadu.com [95.215.58.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64A0A1FD4 for ; Wed, 13 Sep 2023 10:18:06 -0700 (PDT) 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 13 Sep 2023 10:18:54 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776948897101690339 X-GMAIL-MSGID: 1776948897101690339 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) {