From patchwork Mon Sep 5 21:05:37 2022 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: 12966561 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 56A32C6FA83 for ; Mon, 5 Sep 2022 21:09:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5479C8021D; Mon, 5 Sep 2022 17:09:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4586E80214; Mon, 5 Sep 2022 17:09:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 234B68021D; Mon, 5 Sep 2022 17:09:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id EF16A80214 for ; Mon, 5 Sep 2022 17:09:12 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id C9E5E1406FE for ; Mon, 5 Sep 2022 21:09:12 +0000 (UTC) X-FDA: 79879272144.09.A572993 Received: from out0.migadu.com (out0.migadu.com [94.23.1.103]) by imf06.hostedemail.com (Postfix) with ESMTP id 64C64180063 for ; Mon, 5 Sep 2022 21:09:12 +0000 (UTC) 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=1662412151; 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=i+QvTW07XA+L+c+k80OvSUNhWYirWKC1C/9s/Xy3OVY=; b=XC2G9nUXtuhWtEyTfaC8n6A+yQ9xpjcSlFv2sYPA2wJTQOOybIvCvCXup6v8UWAKabZ3Tn 5PKm1aYNHdVdoZqTBj+l7DtBdN6drpIsdc0Cq2DCuXGD/mMWRtgz2t1iWl3KJ9vGQLvUBI A9m81lpA5Bb6ZwjWJZVe/sE2jxivapg= 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 22/34] kasan: use virt_addr_valid in kasan_addr_to_page/slab Date: Mon, 5 Sep 2022 23:05:37 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662412152; 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=i+QvTW07XA+L+c+k80OvSUNhWYirWKC1C/9s/Xy3OVY=; b=I5rO34sI/MDP6ZJkAredO1BRSWljJ/zijWZV+3UPMFeWeh0vhe6a/Ns/asKbAbPFUhmkdG 0z3jgON+00xMSsJKi4zEEmx7mw77Z6c0mgtURBqCJeOdK+pgrLy4ENl2O4BOjl5+gdILuW Prrq5SD7hR9ioB+wgNEMwYkYT1MEZS8= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=XC2G9nUX; spf=pass (imf06.hostedemail.com: domain of andrey.konovalov@linux.dev designates 94.23.1.103 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662412152; a=rsa-sha256; cv=none; b=GcXNrzmTWczkKSrMXo/hL+0s/8rEnHuXBIovIk2d7pD7vuO6jmkgLrsvngIyUSwzAIQWG8 sMNpi2BLm5m/bzuiHYk+5eb5KH/nYiWRsc+n0UlZWzRn9Hc29elZGG3d5RMImOhtcDkuGm 9C1QOMcOMAz/UxBSB1x0/MTAZ2t796A= X-Stat-Signature: uuprpbske7t159ig8tt5s5gjar4cakd5 X-Rspamd-Queue-Id: 64C64180063 Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=XC2G9nUX; spf=pass (imf06.hostedemail.com: domain of andrey.konovalov@linux.dev designates 94.23.1.103 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev; dmarc=pass (policy=none) header.from=linux.dev X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1662412152-793856 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: From: Andrey Konovalov Instead of open-coding the validity checks for addr in kasan_addr_to_page/slab(), use the virt_addr_valid() helper. Reviewed-by: Marco Elver Signed-off-by: Andrey Konovalov --- Changes v1->v2: - This is a new patch. --- mm/kasan/report.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/kasan/report.c b/mm/kasan/report.c index 83f420a28c0b..570f9419b90c 100644 --- a/mm/kasan/report.c +++ b/mm/kasan/report.c @@ -208,14 +208,14 @@ static void print_track(struct kasan_track *track, const char *prefix) struct page *kasan_addr_to_page(const void *addr) { - if ((addr >= (void *)PAGE_OFFSET) && (addr < high_memory)) + if (virt_addr_valid(addr)) return virt_to_head_page(addr); return NULL; } struct slab *kasan_addr_to_slab(const void *addr) { - if ((addr >= (void *)PAGE_OFFSET) && (addr < high_memory)) + if (virt_addr_valid(addr)) return virt_to_slab(addr); return NULL; }