Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3933037imw; Mon, 18 Jul 2022 17:48:12 -0700 (PDT) X-Google-Smtp-Source: AGRyM1st6vvFFNp0oz3/VH+Eldsk8qrQp46piMy05+aIagSKjm7BkX5Svu6n6RMeLG9OI/MuUgcA X-Received: by 2002:a05:6870:42c3:b0:101:c31d:c40e with SMTP id z3-20020a05687042c300b00101c31dc40emr19064896oah.39.1658191692133; Mon, 18 Jul 2022 17:48:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658191692; cv=none; d=google.com; s=arc-20160816; b=uN8+InUatMGZEaVcOzRPrLIBO3mCyhk0VuBVs8wF3w2iOXPxxgePcZ7W6NzU8vO2kp DONtjiRAlLCiFri99+HK6T22mFb1u7s/pRjQMrmWb13j+ReWQtSFKvwIY/6Z2z+W9nuY PaUwwwcTV99X+95iEm4Ms/lMgcBvyj2eNEeaYsh4T71RuUiPaI8wEagDJEJALKWm+SLm Fcx1AFSkKLTiK5mtYSTfJW3EF2ps5v9ZHv6ppt8SV3HAredtVGzGYoSt51XRPRzKT8R2 5QXxP4tq5G8vmw6h02dmgyhOd6EgsNKb3MNETTdiXeKUtyexp9eLAW0X9+U8+njbasvk eznQ== 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=zHx81bpzjWOxKC5pKO2LKT22RGKsdl7WhMonqA7gxhs=; b=EnjmZxKqfBDTa0L8Oae9rj/elsx6gy9aUhozlX5O1mrgs8p7TRkX5LbPLnEi3BpkK/ qmpZrW0+eMZ1UHYgrPIsaHJYt7QkPoXIF5Gy478P5GyQGbmp+I/ckGMgp1Gz37XwfQoo x6Ni66Ea4zJLoFfE4+PZ7k8dERfOkYrVGGhJ3qYju+/fkP9UwZ2LgmIasCx+WaLikq8a l9mR/3UqX81c6g/oeJT5ozxgAWo7k1yHCMZ0Baw3DgxONGHFrxsH7PDtXFu+/6nc/cTF wqysLZh6j9Uie7JgUjpYhwDkHLlsQgIUkD6W23YtNX32lf9hxDxzQPDCVuZdhN10k+a7 n9pQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=YAVfPvux; 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 ch4-20020a0568081c0400b0033553be2385si14541190oib.185.2022.07.18.17.47.59; Mon, 18 Jul 2022 17:48:12 -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=YAVfPvux; 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 S236680AbiGSAOt (ORCPT + 99 others); Mon, 18 Jul 2022 20:14:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236616AbiGSAOm (ORCPT ); Mon, 18 Jul 2022 20:14:42 -0400 Received: from out2.migadu.com (out2.migadu.com [188.165.223.204]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B9A720F for ; Mon, 18 Jul 2022 17:14:42 -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=1658189680; 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=zHx81bpzjWOxKC5pKO2LKT22RGKsdl7WhMonqA7gxhs=; b=YAVfPvuxRs6wvf02tGViw9mrXesCywMRt5a/mMyG6EVzzUWP4dYPec6nG8dgtAh//2bzev S2S3SltYgn5EhlOd0ebcTaES7j8evddGMUOCbG7QF0GuHWTj+RRGc1GjKqjDODT3eZniLe TYdLSjvJcHhUUoVU8vuvu/uP+AxPxhw= From: andrey.konovalov@linux.dev To: Marco Elver , Alexander Potapenko Cc: Andrey Konovalov , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Peter Collingbourne , Evgenii Stepanov , Florian Mayer , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH mm v2 26/33] kasan: introduce complete_report_info Date: Tue, 19 Jul 2022 02:10:06 +0200 Message-Id: <5ed013df1b173806eb7aecccd2254aa46d3abe56.1658189199.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,SPF_HELO_PASS,SPF_PASS 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. 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