From patchwork Fri Feb 5 02:32:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12069207 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 122A8C433E0 for ; Fri, 5 Feb 2021 02:33:00 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9FAE564FBE for ; Fri, 5 Feb 2021 02:32:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9FAE564FBE Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 318FE6B0081; Thu, 4 Feb 2021 21:32:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2A1FB6B0082; Thu, 4 Feb 2021 21:32:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 191296B0083; Thu, 4 Feb 2021 21:32:59 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0039.hostedemail.com [216.40.44.39]) by kanga.kvack.org (Postfix) with ESMTP id F32666B0081 for ; Thu, 4 Feb 2021 21:32:58 -0500 (EST) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id C466E8249980 for ; Fri, 5 Feb 2021 02:32:58 +0000 (UTC) X-FDA: 77782641636.26.14C7871 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf06.hostedemail.com (Postfix) with ESMTP id 1E902D6D663B for ; Fri, 5 Feb 2021 02:32:57 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id DC56D64FB5; Fri, 5 Feb 2021 02:32:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1612492374; bh=jQ+DXJ4ZL2hgEpB00QbfV5p2Sb3FWJrL6IpfKeneeHI=; h=Date:From:To:Subject:In-Reply-To:From; b=YkjHqO0Yn4QekSMwSln1PfK7uwXoSRMBUklfLbBL8hZZuuAC3G/jPqDFZcCisDbal 68GsGvm1OBqGWIW7lisSslG9ZLnyMyIn56VUYmnMp7T9SDeoskw3WuKswUUJ7xF3si p/94eFcoEXlnGfVbbpsKhypEsVybZ8PO0HMYEhjo= Date: Thu, 04 Feb 2021 18:32:53 -0800 From: Andrew Morton To: akpm@linux-foundation.org, andreyknvl@google.com, aryabinin@virtuozzo.com, catalin.marinas@arm.com, dvyukov@google.com, glider@google.com, leonro@mellanox.com, linux-mm@kvack.org, mark.rutland@arm.com, mm-commits@vger.kernel.org, naresh.kamboju@linaro.org, paulmck@kernel.org, torvalds@linux-foundation.org, vincenzo.frascino@arm.com, will@kernel.org Subject: [patch 15/18] kasan: make addr_has_metadata() return true for valid addresses Message-ID: <20210205023253.FkY5Q84ML%akpm@linux-foundation.org> In-Reply-To: <20210204183135.e123f0d6027529f2cf500cf2@linux-foundation.org> User-Agent: s-nail v14.8.16 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 1E902D6D663B X-Stat-Signature: rfppnguguzu6gsxiuufq68zdhnt31g4w Received-SPF: none (linux-foundation.org>: No applicable sender policy available) receiver=imf06; identity=mailfrom; envelope-from=""; helo=mail.kernel.org; client-ip=198.145.29.99 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1612492377-578256 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: Vincenzo Frascino Subject: kasan: make addr_has_metadata() return true for valid addresses Currently, addr_has_metadata() returns true for every address. An invalid address (e.g. NULL) passed to the function when, KASAN_HW_TAGS is enabled, leads to a kernel panic. Make addr_has_metadata() return true for valid addresses only. Note: KASAN_HW_TAGS support for vmalloc will be added with a future patch. Link: https://lkml.kernel.org/r/20210126134409.47894-3-vincenzo.frascino@arm.com Fixes: 2e903b91479782b7 ("kasan, arm64: implement HW_TAGS runtime") Signed-off-by: Vincenzo Frascino Reviewed-by: Andrey Konovalov Cc: Andrey Ryabinin Cc: Alexander Potapenko Cc: Dmitry Vyukov Cc: Leon Romanovsky Cc: Catalin Marinas Cc: Mark Rutland Cc: Naresh Kamboju Cc: "Paul E . McKenney" Cc: Will Deacon Signed-off-by: Andrew Morton --- mm/kasan/kasan.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/mm/kasan/kasan.h~kasan-make-addr_has_metadata-return-true-for-valid-addresses +++ a/mm/kasan/kasan.h @@ -209,7 +209,7 @@ bool check_memory_region(unsigned long a static inline bool addr_has_metadata(const void *addr) { - return true; + return (is_vmalloc_addr(addr) || virt_addr_valid(addr)); } #endif /* CONFIG_KASAN_GENERIC || CONFIG_KASAN_SW_TAGS */