Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp5816611ioo; Wed, 1 Jun 2022 13:12:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxM+TdH2UA281SjIW542XRYr1/cAkq0RVtaqqKpzF7dA3afyrdvG35I/C3CwsXk4f4twNPB X-Received: by 2002:a17:902:eb86:b0:162:1654:4a08 with SMTP id q6-20020a170902eb8600b0016216544a08mr1109713plg.72.1654114330867; Wed, 01 Jun 2022 13:12:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654114330; cv=none; d=google.com; s=arc-20160816; b=GFlLSefDp89BGqRlZb7r7Kp9a8AscpSgCq4eirMikMnuUEZ6F/j9QTDw/Y/7QrsaDH r4XvbI0AMgX4RZRQ9C2xA9FkCHd5uyqz+Wt0/1bDx3Lzd301gQ8MX77uDsSpxmvWlZ4W Y8rF2d0D8ZJFmLM9dXLnIvshOs9v22Q5VEso2QcpniRtSj8hG0yc8iztU8Lj+tC77SAu rwcHg2yFcPMJ8eH+Pq2nBPhUEGMXVL1Ul0YwNWFLtX6N+z7QWzYeb+hsWDvcHv2a2rsx wtjQPGHB2DrX3s+/gduIdyvdXa6NodPuYNmvUm++gXB1a7pWFJa2NtuzCUIg5pUrNYp0 icBg== 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=tEpZdGz90JlT1Su1SZxeM3e97n4OjIjhauOVgJs/x+Q=; b=hHPkLFQoHZtb5zfHzg51ElWXi1GTCeDpNTaHBgML0FMXLMw7Tx0T0dJiiVh+MAn8iE JobHGa3luctiuY4hQCHU2aZEnAN9cdy29o4bmbhrX3W/KwKEAzhjm6Pqx1GmI3gZnKNH an+YgaMTnXyJ/cB3oCz+JZ9jWSvVdLLJD1vJbZljqo7dJ2y2z8O3ED8ZqY/GPej9Et6S srO91bRepIbjuhbsJeS7I0NMoa3JpqqTZauPBtXKtrwtmJvhvjEwUoNaFXBB+nuOVXy3 vqQ1F6ZuSs3QNDpN+BFYtTPu+i6/lAEwCApDP/7GGcCBbaFt+DDbUuuw/fTXqGZorEfn 5kWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=ce+LyTos; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id 19-20020a631853000000b003ab01be4e34si2951182pgy.678.2022.06.01.13.12.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 13:12:10 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=ce+LyTos; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2100BC8BDA; Wed, 1 Jun 2022 12:25:35 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345832AbiEaPoC (ORCPT + 99 others); Tue, 31 May 2022 11:44:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242996AbiEaPn7 (ORCPT ); Tue, 31 May 2022 11:43:59 -0400 Received: from out2.migadu.com (out2.migadu.com [IPv6:2001:41d0:2:aacc::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D9738CB10 for ; Tue, 31 May 2022 08:43:55 -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=1654011834; 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=tEpZdGz90JlT1Su1SZxeM3e97n4OjIjhauOVgJs/x+Q=; b=ce+LyTosve/iVH9saoGKtCpSbSXfRease5nqKzuWRouhIjfI3dDzxtv5+qtA5s+Y92VtF2 wmJc5Qx8+aVF8+Uy8hMCmvAxR0hDqKOY8q+ijFj7KZt2K+NkCDldH2Z2GMZLcCO9Z4X82d Ki5a5OuzdcgrA4nhqYI0GSIKITJBrVM= From: andrey.konovalov@linux.dev To: Marco Elver , Alexander Potapenko Cc: Andrey Konovalov , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH 2/3] mm: introduce clear_highpage_tagged Date: Tue, 31 May 2022 17:43:49 +0200 Message-Id: In-Reply-To: <4c76a95aff79723de76df146a10888a5a9196faf.1654011120.git.andreyknvl@google.com> References: <4c76a95aff79723de76df146a10888a5a9196faf.1654011120.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.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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_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 --- include/linux/highmem.h | 11 +++++++++++ mm/page_alloc.c | 8 ++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/include/linux/highmem.h b/include/linux/highmem.h index 3af34de54330..df76a0db7cec 100644 --- a/include/linux/highmem.h +++ b/include/linux/highmem.h @@ -243,6 +243,17 @@ static inline void clear_highpage(struct page *page) kunmap_local(kaddr); } +static inline void clear_highpage_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..d82ea983a7a3 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_tagged(page + i); kasan_enable_current(); } -- 2.25.1