Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp3574505rwb; Mon, 5 Sep 2022 14:28:07 -0700 (PDT) X-Google-Smtp-Source: AA6agR5fwrwLxAh+IjRhETCPT49XFz7RKHww8M7j0Y7AipuM7D/U/CKYjU0NoqLW+KVwBcTVCYN5 X-Received: by 2002:a17:90b:4b81:b0:1fd:bc88:680b with SMTP id lr1-20020a17090b4b8100b001fdbc88680bmr21328352pjb.19.1662413287440; Mon, 05 Sep 2022 14:28:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662413287; cv=none; d=google.com; s=arc-20160816; b=01agzILFdYBz/xlnn+tU9Pg0eYLLUIBQ/bAJkPsZQ+N34kUVe5MoRQtKYVbUwgK2pQ 6PRC/4duVZ0u7hePxZ+I5vjndNCIjM+CoHlwGiL97FMp4iCK9FWhDyw6UG9pKN9nJNDp 7kVtC2rrh2KAyxwoCft3fYD0NM2Nz0P1uOwLfKAtMf7AeGHj8DJzZEJQrGr2bYGzOuOG qiXQfNeopFqMJSJFzsh4ETAKPT40QWT2Q5aMITFsVbg+Kjagzh3gJweVerrJMSzyB3M8 pkWjHZijmtc5fAe0Z8TK+1WHJE1j1XjbxI/AGfEdgaBi61sGs/7y8IR4Uk9YK6IJYGSN z0jw== 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=vX65IvaMkEV2nE74f0VGWlIcO5REzzEOQVG3jlGiFU0=; b=yCP1+MjdjFqLlVZu4Oi/Hwqfd5P58MRvcKWguvoCWBkcrlScfkUddu/7CFE+2v/MX0 XH9Yoobbx9Kj3l5+CxDII71dftVhdxeb3AnKiCfhaC5F0quMOPFj1lAOa+QNNzNkCAFX S47Edn0BTQV5X2LXobQsN56e/YMH5lguACTYT0pjhEb0UtoSUV/UJ7OXHfCw0kRkXg6u G2eLpTfTYTc0b6pHMP8qEfKWAcnTi5HFQVyiyvfovagE/FnYH+zP722X+EZD/+hPPvd1 7mn/t+81dLXq6VQao5mE7T/jt9m0JWB+jBqYQa8v08vfBPGOoIZBeZl/IQB/+jOBWZv5 xh2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=iLcEJBbW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k6-20020a632406000000b0042bbc9f4459si11339684pgk.471.2022.09.05.14.27.52; Mon, 05 Sep 2022 14:28:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=iLcEJBbW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232169AbiIEVLS (ORCPT + 99 others); Mon, 5 Sep 2022 17:11:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237440AbiIEVLB (ORCPT ); Mon, 5 Sep 2022 17:11:01 -0400 Received: from out1.migadu.com (out1.migadu.com [IPv6:2001:41d0:2:863f::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59DB72250C for ; Mon, 5 Sep 2022 14:10:23 -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=1662412216; 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=vX65IvaMkEV2nE74f0VGWlIcO5REzzEOQVG3jlGiFU0=; b=iLcEJBbWrHxEvOCEUW0Nx+EFmd6xHROIvcpb5oFWtuLWNS3j4x85eWyhS/nQCqKvhQFY+9 DZlhZZ6zIR0Jqhe/YPyXARUvqFh4uR/0eIygdiza2I+gSgeBeN1AdVl6C6TLGQEnT5e8r/ xpqrVEk1zG6Wg7hVB7ThRMhkc/m8S3w= From: andrey.konovalov@linux.dev To: Andrew Morton Cc: Andrey Konovalov , Marco Elver , Alexander Potapenko , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Peter Collingbourne , Evgenii Stepanov , Florian Mayer , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH mm v3 26/34] kasan: introduce complete_report_info Date: Mon, 5 Sep 2022 23:05:41 +0200 Message-Id: <8eb1a9bd01f5d31eab4524da54a101b8720b469e.1662411799.git.andreyknvl@google.com> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrey Konovalov Introduce a complete_report_info() function that fills in the first_bad_addr field of kasan_report_info instead of doing it in kasan_report_*(). This function will be extended in the next patch. Reviewed-by: Marco Elver Signed-off-by: Andrey Konovalov --- mm/kasan/kasan.h | 5 ++++- mm/kasan/report.c | 17 +++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h index 4fddfdb08abf..7e07115873d3 100644 --- a/mm/kasan/kasan.h +++ b/mm/kasan/kasan.h @@ -153,12 +153,15 @@ enum kasan_report_type { }; struct kasan_report_info { + /* Filled in by kasan_report_*(). */ enum kasan_report_type type; void *access_addr; - void *first_bad_addr; size_t access_size; bool is_write; unsigned long ip; + + /* Filled in by the common reporting code. */ + void *first_bad_addr; }; /* Do not change the struct layout: compiler ABI. */ diff --git a/mm/kasan/report.c b/mm/kasan/report.c index dc38ada86f85..0c2e7a58095d 100644 --- a/mm/kasan/report.c +++ b/mm/kasan/report.c @@ -413,6 +413,17 @@ static void print_report(struct kasan_report_info *info) } } +static void complete_report_info(struct kasan_report_info *info) +{ + void *addr = kasan_reset_tag(info->access_addr); + + if (info->type == KASAN_REPORT_ACCESS) + info->first_bad_addr = kasan_find_first_bad_addr( + info->access_addr, info->access_size); + else + info->first_bad_addr = addr; +} + void kasan_report_invalid_free(void *ptr, unsigned long ip, enum kasan_report_type type) { unsigned long flags; @@ -430,11 +441,12 @@ void kasan_report_invalid_free(void *ptr, unsigned long ip, enum kasan_report_ty info.type = type; info.access_addr = ptr; - info.first_bad_addr = kasan_reset_tag(ptr); info.access_size = 0; info.is_write = false; info.ip = ip; + complete_report_info(&info); + print_report(&info); end_report(&flags, ptr); @@ -463,11 +475,12 @@ bool kasan_report(unsigned long addr, size_t size, bool is_write, info.type = KASAN_REPORT_ACCESS; info.access_addr = ptr; - info.first_bad_addr = kasan_find_first_bad_addr(ptr, size); info.access_size = size; info.is_write = is_write; info.ip = ip; + complete_report_info(&info); + print_report(&info); end_report(&irq_flags, ptr); -- 2.25.1