Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp679550iol; Thu, 9 Jun 2022 11:33:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzK/4c/pBCQkDU2qURjHyCBOiCNANsCxzFi/sc7gnq0pa+Yr1szzjKIrObxj/slBzLva1Pb X-Received: by 2002:a05:6402:4246:b0:42f:3a4b:cc71 with SMTP id g6-20020a056402424600b0042f3a4bcc71mr37628737edb.107.1654799628312; Thu, 09 Jun 2022 11:33:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654799628; cv=none; d=google.com; s=arc-20160816; b=tYBwCpIol27SeW31Jkvb6rY6xA4b+fM0yZ67jhbrI1kTuQgJ5h5T1Q28dE3nOoajZC uO4LatDlFS6N4J7puSIiJsVp7kVi2siPMmhBgt8yb9OqFBXT8WhO8gHq7Jnm4kmhV39R bxxUng66M/SJUjh2BDmnGJZ7pc7k63fec8tICBJVLkq//4EsVlkt7rY6o48ZUlLucEFI LVIQz/djSfgxLZOxrXfOQtqa2eYHB0hMeYu48G2D2GXoot/MMe9zb8bjsy+dJpClmfa6 hmaoHlkQZ1gwFuXwkSG+iF3y0d0D4QSlKzCQeC2uX1u8a75dheXbioOI+QUjKYUi0Cqr GCsg== 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=fO4jbpVApVQcfTPwx9gBa9O1ee1UTzsQG3M5HGLfNnA=; b=TLTswiYQB0GL4zc4QQdGZo6ZubHN6+Iso4WvgDFGfOycTvIm5NzsJF2V7UojOoUDWb Hpka96b/Q2ijELunnTkkgiMGGi3JwOPFo8V+emOyh5BdwH1ta1JJIH/+GnJnVyiIY/0x YSedUXkqIAvzyyR8k4RVJrVVHgoIz5FAE7V6vLw15tNAyyeNuo5BmmVZqPzZnJoC29AU DyBalJe2Q/VO+/sCuuqvOEDXNQ/Pvp8Sma5WOAGpbrB+VCKpjO7vjRm0PX/bioEHrF43 Q/L7U+e0JPDyBzV7dXbwtx+p3UV35pC0VKJR28gzURDbBQoHBrcfDQJD0pesyNQut7Wi HHoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=Xa3doeBq; 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 hs6-20020a1709073e8600b006fe8e64d480si7209636ejc.701.2022.06.09.11.33.21; Thu, 09 Jun 2022 11:33:48 -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=Xa3doeBq; 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 S1345334AbiFISS7 (ORCPT + 99 others); Thu, 9 Jun 2022 14:18:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233182AbiFISSz (ORCPT ); Thu, 9 Jun 2022 14:18:55 -0400 Received: from out2.migadu.com (out2.migadu.com [188.165.223.204]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DF143AE822 for ; Thu, 9 Jun 2022 11:18:52 -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=1654798731; 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=fO4jbpVApVQcfTPwx9gBa9O1ee1UTzsQG3M5HGLfNnA=; b=Xa3doeBqLfHwMDbSeTb4ZiFXvBmIjIofPaa33n/qvrG/uWiPfuEdLm4uM0UENmXHeStFzI 05B2JyJIU0BKhPX6l1OEPU9ljfiSO4uJc8a8Ta+g8lK5davYDlg+I/F1PNsr9pOnGgg1I3 Or3TzC6G5wLjJyGaTo+AhgrnmvED5fw= From: andrey.konovalov@linux.dev To: Andrew Morton Cc: Andrey Konovalov , Marco Elver , Alexander Potapenko , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH v2 2/3] mm: introduce clear_highpage_kasan_tagged Date: Thu, 9 Jun 2022 20:18:46 +0200 Message-Id: <4471979b46b2c487787ddcd08b9dc5fedd1b6ffd.1654798516.git.andreyknvl@google.com> In-Reply-To: <1ecaffc0a9c1404d4d7cf52efe0b2dc8a0c681d8.1654798516.git.andreyknvl@google.com> References: <1ecaffc0a9c1404d4d7cf52efe0b2dc8a0c681d8.1654798516.git.andreyknvl@google.com> 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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Add a clear_highpage_kasan_tagged() helper that does clear_highpage() on a page potentially tagged by KASAN. This helper is used by the following patch. Signed-off-by: Andrey Konovalov --- Changes v1->v2: - Renamed clear_highpage_tagged() to clear_highpage_kasan_tagged(). - Removed extra empty line in clear_highpage_kasan_tagged(). --- include/linux/highmem.h | 10 ++++++++++ mm/page_alloc.c | 8 ++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/include/linux/highmem.h b/include/linux/highmem.h index 3af34de54330..70b496bbd2d9 100644 --- a/include/linux/highmem.h +++ b/include/linux/highmem.h @@ -243,6 +243,16 @@ static inline void clear_highpage(struct page *page) kunmap_local(kaddr); } +static inline void clear_highpage_kasan_tagged(struct page *page) +{ + u8 tag; + + tag = page_kasan_tag(page); + page_kasan_tag_reset(page); + clear_highpage(page); + page_kasan_tag_set(page, tag); +} + #ifndef __HAVE_ARCH_TAG_CLEAR_HIGHPAGE static inline void tag_clear_highpage(struct page *page) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 66ef8c310dce..76a02255f57c 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1302,12 +1302,8 @@ static void kernel_init_pages(struct page *page, int numpages) /* s390's use of memset() could override KASAN redzones. */ kasan_disable_current(); - for (i = 0; i < numpages; i++) { - u8 tag = page_kasan_tag(page + i); - page_kasan_tag_reset(page + i); - clear_highpage(page + i); - page_kasan_tag_set(page + i, tag); - } + for (i = 0; i < numpages; i++) + clear_highpage_kasan_tagged(page + i); kasan_enable_current(); } -- 2.25.1