From patchwork Thu Dec 21 20:04:44 2023 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: 13502597 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 5F2B3C46CCD for ; Thu, 21 Dec 2023 20:05:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BB92F6B0080; Thu, 21 Dec 2023 15:05:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B6F0F6B0083; Thu, 21 Dec 2023 15:05:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 970546B0085; Thu, 21 Dec 2023 15:05:03 -0500 (EST) 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 748F16B0083 for ; Thu, 21 Dec 2023 15:05:03 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 467A1A131F for ; Thu, 21 Dec 2023 20:05:03 +0000 (UTC) X-FDA: 81591904086.01.CA61C5F Received: from out-176.mta1.migadu.com (out-176.mta1.migadu.com [95.215.58.176]) by imf19.hostedemail.com (Postfix) with ESMTP id 5F6961A000A for ; Thu, 21 Dec 2023 20:05:01 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=oUd4oho2; spf=pass (imf19.hostedemail.com: domain of andrey.konovalov@linux.dev designates 95.215.58.176 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1703189101; 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=25+JPAVVR93qloIeZBPh87TvRbXcdeZ++9g3nzTCJ2g=; b=pd0YgiZOKCNkEIceSFzkyPvtOTM0TVXZ/NY9q+G9nnl6Jpb17qmNxyo7Tt1oK1XScZBTYT Yp6KoC37rIbZwdCjNrmEl0ZDSPFgHNdyqfUoZG2mLvTu6ZIEYVeg/s6nDGH1KVjkGUcr0H wSXPYy46OKmmzn/+Lxms7D+6pCx3SUw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703189101; a=rsa-sha256; cv=none; b=BlKVP/UQTDPbgWmS0HflNc8Q8N5FoAKYOE9y9Trhj2gZ37Byq92tfsGVFf0PMoMptt1995 L5wfnnsM5XAUqU2Ezz3fwbgDlQLQzyeCFw/t7y2pjlrFcQ/o8pP7mi4/8sPNXEaWIaRQUK AkovFBj9K9A++NWk61Vd04Uc1ajYpDM= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=oUd4oho2; spf=pass (imf19.hostedemail.com: domain of andrey.konovalov@linux.dev designates 95.215.58.176 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev; dmarc=pass (policy=none) header.from=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: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Stat-Signature: htk5uwabczakiu4hhqr9czeub9oq4f5m X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 5F6961A000A X-Rspam-User: X-HE-Tag: 1703189101-888792 X-HE-Meta: U2FsdGVkX1+9F07nKVIspvmOrtQreAOq7P9ufFztW0qeNVhyicNAgMSR0X3WvhiCsf8Qzw2qnNeCE54cJJ5ikkhAE0MuYxnr1O9S0iGYJHQGhXIJmVGD9jyC1MDiS/u8ndk3IiRGdiRdwNoR+DAyZi7fCo+BznH+D7+3wUmKhshNjLsFDJ+imd4qZvsctr5MHHSR0pZk757knUw11j3RqU5oBIJWq7cHOCtrp6tk/XMOpJ16JPktzQwOfAeySK+I0fden2u64SFiHfP/DszVm2bKsabvD6ElJJdDvSIxmS7u61HllVH6WMjTjIO82S34YIkvecO6Nxsr8qFip0ipvXFZIOL3TZSLyT24E+oC/B3YGPqtFq9U64dymqENxQ3zQNu/4Bm9xX/qmicNVFWSN26yf6ftJxQDGM6x3F0HAlkvpYposMA416a6t9/4pstlSwQV1o9wsNko61sW6uVJWMMb2R+DPZzkkOq71S7LbSw+68zuLNW82vksmvmpPx7U5L1S7u4M2FsjwT20UpLQPtfViurfnFWewIjRdQunA7YTegqoYacQOoIRxpx5HoYiI+PERbLD4MIweFmOwD3aWNfb8HlOHTQM0KUtD9TYpng9wfqatuMgRLQ5ChuFYJ5O/m9p5hHq58UjWbKlLwET2icGVxT9Yg7rn+QseuvEmmubYPaCMNyDdGeJ8mC3S72aD5ihHPhylMRZo9o4fhRgxWYntzLJ/yvEPPbPdddtmWDaJJ+shy3rV0HHKGwNKPXqPspCd/YFWM4VUpniTDVAKhOz7xts9rJxdoadZGpWDX7W+6IsUHx7BbGzuO268JX29eOqPU78GowF/fA/cadwsoWyZhTK5nvULDCbKo6LEeK8u4eO3YoYONu1Zof+5uSgWo9MHlBZh/MJPyncvSwnpMC+avM/qDW7+toAVflPG15sN2DHedMed9EwvYXPeO3oCZr5dVCeogvwlgzsIcX yERsPYFA 04lDCYuBNRtvvIe758EMMlpBVrXOH/5wAcRwQJj3K4hh0n4fC1WtgwXYu0kXCTNSxWUSk2cRm99VBp7qYU0tXL9/fy2vj1XoJCJ5humRYJ57iPN5IaP7jQ9uK2VuCZM+LEiRnaMxfkb8jCZbB1BWR3BRktvmCZQlwkE1qMfGjS6VhNah4yW/FB8hULEQqVuDkArmORr+k35L3z4p+lnuKIxfGalcSPQnXQgpQeIYRVM4+ZKQq3W+OXxEq+acjZksArDvA 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: List-Subscribe: List-Unsubscribe: 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)