Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp3592616rwb; Mon, 5 Sep 2022 14:54:59 -0700 (PDT) X-Google-Smtp-Source: AA6agR42BloeZoNBTCM2DO/uPVcrNAmFNNEt0wRzoA0SaOdSd8/aKx9hl23tEK75mOnkAasSKzB/ X-Received: by 2002:a17:902:b58a:b0:16e:f91a:486b with SMTP id a10-20020a170902b58a00b0016ef91a486bmr52451625pls.119.1662414899179; Mon, 05 Sep 2022 14:54:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662414899; cv=none; d=google.com; s=arc-20160816; b=CLAUlj1Y9SILbk+C/QB5alyr25I1GRQruKrAM16c34N//+9nCT8Q+XdRkiwnVC3ozJ e41Xyv2GV5eDHw/zl3wiYlkbIfw/tiOiEoZFspKRU2B5qQrk8n43cP+/M7sY49CCiiTG qEbVUFMhk5Qg9eK+hohHbT6aAv6jWd1DZRad0G1pmNcmsGqDz5PRM+r26ij2X1tHBPsm HkN+npfGYgr7Arok2bouDfA/wIvBQap9g/zFh8zzQ0zw5562jUQcmqjKuQqT53mR4Klj FSQoGrezarQjDe6DtG8hgLJc+NErWUVYxTELG81W2femaWD5DnJGZKzSX+ZdZ8fkrgpJ MJ+A== 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=i+QvTW07XA+L+c+k80OvSUNhWYirWKC1C/9s/Xy3OVY=; b=KUjug+6Z0tRiWoc7/ZGNKEiDAQMqg9i17cNkOZ64ZaIzMHFxrRooq3jmK8c7desKw0 vq9cNixd6mWvtbQ5ceWvfKLJRmanCapzSWu5Ik8Y4NpRCWQWgFDSLa3VlUJdfPbH7Shw ePFeNrRO+XhnyqxnXXIo45seZ8kzYfIsaZnqluVpZA7M7+tfJLZUHWWQAqbipEtdn5xC ameiezu99uweFI1bDUJnD1dn2UM7sobTWr64OgMzGLordDWuEx1iAY5inqj69yascsnR ow6Wy9ctukCqXLBINAgVGeQpzeDF9WYD8PSt7HQVyEyq3pgSCJRbFA/AyGGu2nXkn4ZY HRPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=XC2G9nUX; 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 l13-20020a170903244d00b001751d0ac52asi8852622pls.435.2022.09.05.14.54.48; Mon, 05 Sep 2022 14:54:59 -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=XC2G9nUX; 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 S237655AbiIEVJw (ORCPT + 99 others); Mon, 5 Sep 2022 17:09:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237896AbiIEVJZ (ORCPT ); Mon, 5 Sep 2022 17:09:25 -0400 Received: from out0.migadu.com (out0.migadu.com [IPv6:2001:41d0:2:267::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 504466557B for ; Mon, 5 Sep 2022 14:09:13 -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=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 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,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 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; } -- 2.25.1