From patchwork Mon Nov 19 17:26:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10689163 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E022517FE for ; Mon, 19 Nov 2018 17:30:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C64122A0B0 for ; Mon, 19 Nov 2018 17:30:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BA0022A002; Mon, 19 Nov 2018 17:30:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 73B572A0B0 for ; Mon, 19 Nov 2018 17:30:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404419AbeKTDyq (ORCPT ); Mon, 19 Nov 2018 22:54:46 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:33312 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404385AbeKTDvS (ORCPT ); Mon, 19 Nov 2018 22:51:18 -0500 Received: by mail-wr1-f65.google.com with SMTP id u9-v6so32944007wrr.0 for ; Mon, 19 Nov 2018 09:26:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jyRw+rMzdi1alRfDuiZVB0ZJPKSze4LAdpqwyD2ClBE=; b=mix8fNuo76mUcOPQpFGJWa+t7fphMwTFH0Yv/elxeFlZH0rFcGIhZSYZDdFmCW/Yc2 gdVTJ1G8VrAf3ZTQFOBWXHTHQML1qLB4+ArqqGrvFMpu/52VezVzttvjQGeCn/ppJiAz 2M36LqSQ0j3VewPVv18rf6O38zK9OStZG8MZbQrOrkxapZyL8dadP1feNdsZh9E4ibWH 89x1sGZMqHA0DyrvQ1nSWJHqp+wx8b0Yhaml0yUS5oH0Mo3uo7NPWGOy5iePmASMlyX4 Cx1OsEIjkZD2mMsnpK0cA4AcUmPsh33slFpcSzjdJFEbCyh8yVbEh6cMGs7uDR1BzfR+ XpMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jyRw+rMzdi1alRfDuiZVB0ZJPKSze4LAdpqwyD2ClBE=; b=kbOzzFn5J35iIyDicwl5phY43PA6q6K5urrNk4/FwGqq5Jb3MDxB4AYJ/skdeD2oUV /T9o39vo/sPDv9+5dZB+spPAZgRbs3hMgVukQbxBxndpiGvAYoz9LoivS0gXEsmSip/b +BMsLAWo/IypwCXKL4JK127lwpWzuSQEnb64yLXNQP0CJgYQssCee38UQi2ZfeDZeLl2 H19awluewxzQqSE0AA2WA4dsLQhRe2e7eavOODHOZfcVPzdL0Bzdg20ifb6PIJZJJi25 +0ifjiUk+luWg28ynRwzQKlAbTJlBY1tlVYi5411bLqdVtydA83XhQ+Sw1jzlJNwJG8e +0NQ== X-Gm-Message-State: AGRZ1gIncTJACwz1ICL65eiH2pdkIsFoKhzk/p8GYv40+i5WHpLNuUJF vlaTD+NIwbrlOBbPZrYBldveBQ== X-Google-Smtp-Source: AJdET5ePNjMSgad+LbaZrgUmfsb6OSab/vVHZ5XlZ7W2Ovv+StAw8FD1z8DRCPskgWhsuE36zAqtCg== X-Received: by 2002:adf:a409:: with SMTP id d9-v6mr19710119wra.190.1542648412325; Mon, 19 Nov 2018 09:26:52 -0800 (PST) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:3180:41f8:3010:ff61]) by smtp.gmail.com with ESMTPSA id l143-v6sm23685190wmb.23.2018.11.19.09.26.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Nov 2018 09:26:51 -0800 (PST) From: Andrey Konovalov To: Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , Catalin Marinas , Will Deacon , Christoph Lameter , Andrew Morton , Mark Rutland , Nick Desaulniers , Marc Zyngier , Dave Martin , Ard Biesheuvel , "Eric W . Biederman" , Ingo Molnar , Paul Lawrence , Geert Uytterhoeven , Arnd Bergmann , "Kirill A . Shutemov" , Greg Kroah-Hartman , Kate Stewart , Mike Rapoport , kasan-dev@googlegroups.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sparse@vger.kernel.org, linux-mm@kvack.org, linux-kbuild@vger.kernel.org Cc: Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan , Jann Horn , Mark Brand , Chintan Pandya , Vishwath Mohan , Andrey Konovalov Subject: [PATCH v11 02/24] kasan, slub: handle pointer tags in early_kmem_cache_node_alloc Date: Mon, 19 Nov 2018 18:26:18 +0100 Message-Id: <14a68774683e15692615600c47bba53506a1c8ef.1542648335.git.andreyknvl@google.com> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The previous patch updated KASAN hooks signatures and their usage in SLAB and SLUB code, except for the early_kmem_cache_node_alloc function. This patch handles that function separately, as it requires to reorder some of the initialization code to correctly propagate a tagged pointer in case a tag is assigned by kasan_kmalloc. Signed-off-by: Andrey Konovalov --- mm/slub.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index fdd4a86aa882..8561a32910dd 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -3364,16 +3364,16 @@ static void early_kmem_cache_node_alloc(int node) n = page->freelist; BUG_ON(!n); - page->freelist = get_freepointer(kmem_cache_node, n); - page->inuse = 1; - page->frozen = 0; - kmem_cache_node->node[node] = n; #ifdef CONFIG_SLUB_DEBUG init_object(kmem_cache_node, n, SLUB_RED_ACTIVE); init_tracking(kmem_cache_node, n); #endif - kasan_kmalloc(kmem_cache_node, n, sizeof(struct kmem_cache_node), + n = kasan_kmalloc(kmem_cache_node, n, sizeof(struct kmem_cache_node), GFP_KERNEL); + page->freelist = get_freepointer(kmem_cache_node, n); + page->inuse = 1; + page->frozen = 0; + kmem_cache_node->node[node] = n; init_kmem_cache_node(n); inc_slabs_node(kmem_cache_node, node, page->objects);