Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1336591rda; Mon, 23 Oct 2023 09:26:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGbv3z/nHMB8zfq1may32nOvJFSDoJL57fWFR1tzaSHUHmwd3UNwQXjWCOxCOfEHrnGs2Fz X-Received: by 2002:a17:903:200d:b0:1ca:754a:692e with SMTP id s13-20020a170903200d00b001ca754a692emr8716811pla.30.1698078405160; Mon, 23 Oct 2023 09:26:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698078405; cv=none; d=google.com; s=arc-20160816; b=XPpoupEt/jNUIx675wD4tmxGZE/d2sldnLKD+as/LWf2ysK+4wqGHvljmLopUtWeNN dnn0SY55cUzE5CFO55VmL1FFsdJEuX4SY4cxRVQGqFOrCUc0+9QSHbkESdVyA9X3SzZC 1bpcXHBX6Js61ty9vpfLnR8YG8b5Qns7o+OyRuWJfeMvVrT20PCY1yQDEPgH1sJMPlul dYpzCTkTKsKdeHkOajyi1hUOwH9D+bPkOInepAlZ9N6PiehfWkIUefnqC3bK5UNr9on4 cZAJxASPJ4bf44c1Zb2H2+Yi8CfiE02vDLBkOa8xzo6rwZuLf12inY3trRjNCPHHiYvL MttA== 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=uhMrVBrzgAoT1gwViC8KxLkH9OMZhix/uhvoEc70W98=; fh=nfQSbTp1dWHt2Ier1Up8UhVNdXOqoJJLNvTrpT3jJEk=; b=gSNIWKjYAckIL2InUUcuEu4zFiFe1smdvtSveP2nwrf3LZCST9zfEytdkHmWfO4wx7 2v6nUplTmD0j+2SklOCAm5N426mnlJvQEohTqblYWWRlUaxU97UwJLSaC6rOxuz7mC7i syXitUfT4lblZCuef5VWQyzXq+A9JJGrEQ00lubcNNZNeMyEdgz4dQlfNsKlZ3XXuNkO iu2mJ1rscYL8+myIhmLoFKciZQwM9zk7BjP02lhKqKsZH5BX/sZBOAirK6TD1Ui/EtfA qHvl6KSjuPBJmS03DSI61Cu1OV3bRsLRHs1ifhEzszlUulnNxaUkiieDH21PmuS2MrQj yfYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=Ne3J1RXv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id j12-20020a170903024c00b001c9b15bf936si6870430plh.220.2023.10.23.09.26.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 09:26:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=Ne3J1RXv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id 03019808ABA2; Mon, 23 Oct 2023 09:26:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233142AbjJWQ0a (ORCPT + 99 others); Mon, 23 Oct 2023 12:26:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233582AbjJWQ0R (ORCPT ); Mon, 23 Oct 2023 12:26:17 -0400 X-Greylist: delayed 129 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 23 Oct 2023 09:26:15 PDT Received: from out-210.mta1.migadu.com (out-210.mta1.migadu.com [IPv6:2001:41d0:203:375::d2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18C2F10E for ; Mon, 23 Oct 2023 09:26:14 -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=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 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-0.8 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 groat.vger.email 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 (groat.vger.email [0.0.0.0]); Mon, 23 Oct 2023 09:26:41 -0700 (PDT) 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) { -- 2.25.1