Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3952182imw; Mon, 18 Jul 2022 18:15:39 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t5eQOgPIxb8c2GHA0WxjEW6iwNM3UeQxelxIVSRF3EGUEw25hK7sleWREJoeJ7E4O5Z0Om X-Received: by 2002:a05:6402:54:b0:43b:5cbd:d5db with SMTP id f20-20020a056402005400b0043b5cbdd5dbmr14339878edu.264.1658193339771; Mon, 18 Jul 2022 18:15:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658193339; cv=none; d=google.com; s=arc-20160816; b=mchaoRlKlIKvLYkzTSLBiwpsT7egNFu0rVAMPYbeACv7ICp3amwiJ+HlzgrP+pVXbX fPCM3XrI2fBkkAvaAjZ8Dm0GH9ZHSnY1683ctraD+rZLN1uEhQDsWpk3ocH2AhVS0iPA UdBc2u3wx5yzb5fwgKpx6x5A82gWi5+jdmLRlXtSIEvR7LYrBTFHi4TEct9RW1qb8nZc WhA2h+UDXVI5n6FRZR9G4dVIQWD7kdkgSB19uFRxFHDnpDUv6bJodW13hBu0nA3ClZHL AxPcn3yp//yax8a947H6kqAjzRJZIDm/AH5NBOG42pVwCdzdCQuGwo6O76dhtErqI63z vB1w== 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=1v1m9FmRS/rLhFe38ENkOT8DlGvSMLAmXg64oTGrtEU=; b=DCxbwlrKe/cMfhctUU5bghyNy+JA04V7BM3oZzrIvZaVI7eWoj3qlyOVycCgi4XZbx RzjjJ0cOv/lfBfgtk6kDzEVssJZL5LBZngkOwdXpXkcr1jSBArWUuwjaLzdoY0afGIVk UFnj0spXLvtzB/Pp6xSE0uEByBX9J739HHul0U5OcDzyParCdLtv/89Ozfccf7MvobNb n+48UmDNlocmCUYurrq/Suej6i2oiQ28TEc/QbI+h0PhfT/dcGpsMqxFz04RLGCB/ru6 2Sw9coVlxdZnM+usRNdG40+MHlKdX92mbFaFW8RnIB1yNpCqiHtHsF5BnAfvJhUR11mg baYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=Hz61K3OE; 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 t10-20020a056402240a00b0042dd469b483si1113504eda.146.2022.07.18.18.15.15; Mon, 18 Jul 2022 18:15:39 -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=Hz61K3OE; 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 S236389AbiGSANr (ORCPT + 99 others); Mon, 18 Jul 2022 20:13:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236616AbiGSANj (ORCPT ); Mon, 18 Jul 2022 20:13:39 -0400 Received: from out0.migadu.com (out0.migadu.com [IPv6:2001:41d0:2:267::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6752E357C9 for ; Mon, 18 Jul 2022 17:13:38 -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=1658189617; 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=1v1m9FmRS/rLhFe38ENkOT8DlGvSMLAmXg64oTGrtEU=; b=Hz61K3OELw7/RLdZWw95Dm+7jXjxVz3VcDfsTd0onVN5I3KbvEYRmVvTGnIYt4kbCXB3zI nDUflcZ3CJaUXskpg3dfvcQvb/H8iJBInxDhMlxeYmVqvSUrxSlQ2CfaEgUnyKBC8Un3hy 3hjBfBly+wSRWoWkkOUNrcX1DP1irJM= 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 22/33] kasan: use virt_addr_valid in kasan_addr_to_page/slab Date: Tue, 19 Jul 2022 02:10:02 +0200 Message-Id: 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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,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 Instead of open-coding the validity checks for addr in kasan_addr_to_page/slab(), use the virt_addr_valid() helper. 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; } -- 2.25.1