Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp388609rdb; Thu, 21 Dec 2023 12:05:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IGzwX/Hez2SCsuDAP+vCqAqEp36mjgxzipyzQWczDFVEZmZEnadkfKW1At2QN9lf1GCnwQQ X-Received: by 2002:a05:600c:518b:b0:40c:370d:71e1 with SMTP id fa11-20020a05600c518b00b0040c370d71e1mr108848wmb.22.1703189120632; Thu, 21 Dec 2023 12:05:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703189120; cv=none; d=google.com; s=arc-20160816; b=Emkl7FYKOf5HCamM3+JJVHUhWuGvtCmgjl2MpJMT43YbZiG8yTrG+7sT/DMZ08WSiv rHH+r+e90V6eTmavxBopW2EK51pbABz9cXqgFOnn28p3SRAOhKVhuEdz8SC66PQtyDpV hrepQEQ5ieeNviC/Ins4Qazv6hzsknqlnoNJi38IlBkx+wX0WNcp4C7aPLoK0rtVdwUr AZA3FZr0hXMla7ozInbOPmigxxIe8VpyAVTxIaEgm6WgKLk0AYmlY5TR6DvU97Df+xkM S6WW8mGO8tLNJzzvv8/trBM1i1YVs/tCOUNZIV8dHOKNornB4WnujImCdof88BqhdpL9 pgBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=25+JPAVVR93qloIeZBPh87TvRbXcdeZ++9g3nzTCJ2g=; fh=GyTEpUCUNPwsl1pqA0jDPXgvja+iZTM9USlQd9sQtQg=; b=GHDtkLRnvCrpYXZZDTpOatDumDuAHmhung8N7MQE4+yVGo5lUZy7KRPGiv1RiLa6BA glLuKYHlRALXvGC6Qy2/JRhOa+5gt5nqfVKdojnm3gwLtvvMR/RG3yfLcZyqwsoDnqga 8ZwaJ7YP3q0IjR3TpIqjR9OFlWJOYxvkcrweQ3z8Ot5eJVzMu/DGhDA77qSJNam9qJYg WgUBJFH8x3Epir1foFER0ZrcCUEi0zdi5PGIviINj/OffIS08djASCr6VeJuhBmANrhq UJ5tTrAWX3w2j6IaVPZl8U84R26c5OyaVGlSneDlFqL/UV8B53YFhosWobDJYhUKBYjZ /49w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=oUd4oho2; spf=pass (google.com: domain of linux-kernel+bounces-9020-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9020-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id ka21-20020a170907921500b00a26a5f808casi823033ejb.261.2023.12.21.12.05.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 12:05:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-9020-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=oUd4oho2; spf=pass (google.com: domain of linux-kernel+bounces-9020-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9020-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 6322F1F24F9B for ; Thu, 21 Dec 2023 20:05:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 827A2745F5; Thu, 21 Dec 2023 20:05:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="oUd4oho2" X-Original-To: linux-kernel@vger.kernel.org Received: from out-189.mta1.migadu.com (out-189.mta1.migadu.com [95.215.58.189]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BDEF973197 for ; Thu, 21 Dec 2023 20:05:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev 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=1703189099; 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=25+JPAVVR93qloIeZBPh87TvRbXcdeZ++9g3nzTCJ2g=; b=oUd4oho2PQFVBsMx441Y1BJ9xZLJRj3/NEa+HI+PvsMu+h8/Evf4eJR6JIIS7+fS93FGb7 Ih/Fyn0cbQWAZzwK+nS3P7ZRUaf95dp2MAee2vmD/jR6DwOerV5e/55LchsDaXoVGmFMIn 0QPWF12bI5PU1x2N2e+NkASW14dnAIM= From: andrey.konovalov@linux.dev To: Marco Elver Cc: Andrey Konovalov , Alexander Potapenko , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH mm 02/11] mm, kasan: use KASAN_TAG_KERNEL instead of 0xff Date: Thu, 21 Dec 2023 21:04:44 +0100 Message-Id: <71db9087b0aebb6c4dccbc609cc0cd50621533c7.1703188911.git.andreyknvl@google.com> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT From: Andrey Konovalov Use the KASAN_TAG_KERNEL marco instead of open-coding 0xff in the mm code. This macro is provided by include/linux/kasan-tags.h, which does not include any other headers, so it's safe to include it into mm.h without causing circular include dependencies. Signed-off-by: Andrey Konovalov --- include/linux/kasan.h | 1 + include/linux/mm.h | 4 ++-- mm/page_alloc.c | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/linux/kasan.h b/include/linux/kasan.h index d49e3d4c099e..dbb06d789e74 100644 --- a/include/linux/kasan.h +++ b/include/linux/kasan.h @@ -4,6 +4,7 @@ #include #include +#include #include #include #include diff --git a/include/linux/mm.h b/include/linux/mm.h index a422cc123a2d..8b2e4841e817 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1815,7 +1815,7 @@ static inline void vma_set_access_pid_bit(struct vm_area_struct *vma) static inline u8 page_kasan_tag(const struct page *page) { - u8 tag = 0xff; + u8 tag = KASAN_TAG_KERNEL; if (kasan_enabled()) { tag = (page->flags >> KASAN_TAG_PGSHIFT) & KASAN_TAG_MASK; @@ -1844,7 +1844,7 @@ static inline void page_kasan_tag_set(struct page *page, u8 tag) static inline void page_kasan_tag_reset(struct page *page) { if (kasan_enabled()) - page_kasan_tag_set(page, 0xff); + page_kasan_tag_set(page, KASAN_TAG_KERNEL); } #else /* CONFIG_KASAN_SW_TAGS || CONFIG_KASAN_HW_TAGS */ diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 7ea9c33320bf..51e85760877a 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1059,7 +1059,7 @@ static inline bool should_skip_kasan_poison(struct page *page, fpi_t fpi_flags) if (IS_ENABLED(CONFIG_KASAN_GENERIC)) return deferred_pages_enabled(); - return page_kasan_tag(page) == 0xff; + return page_kasan_tag(page) == KASAN_TAG_KERNEL; } static void kernel_init_pages(struct page *page, int numpages) -- 2.25.1