From patchwork Tue Nov 6 17:30:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10670891 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 152D713BF for ; Tue, 6 Nov 2018 17:30:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F36952AB9D for ; Tue, 6 Nov 2018 17:30:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F0E7E2ABB7; Tue, 6 Nov 2018 17:30:49 +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=ham 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 911FD2ABB2 for ; Tue, 6 Nov 2018 17:30:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389672AbeKGC5C (ORCPT ); Tue, 6 Nov 2018 21:57:02 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:40526 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730448AbeKGC5B (ORCPT ); Tue, 6 Nov 2018 21:57:01 -0500 Received: by mail-wm1-f68.google.com with SMTP id b203-v6so12991845wme.5 for ; Tue, 06 Nov 2018 09:30:44 -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=bOEKal8RBRTtWSpTxNA94ZGJWCyGRWdgsr1BoKcGe9Y=; b=Y+JaKNNgXBgr6Jwh77JFn54Ud9LeC25orGV/QEwMUJVZJOpZMlBYwv++U+CYCLelPU vj0qUgYsRe3ImvGiWtzR0lfkqoNrpLrIeBHcuByNoVKslQJ9vxAUJSnYAr0poPt78I7D mWqMTMtiao+3C5hZyPLfjow9DWPjGjEwY2dy7x8MPT46QXCjUDa+fOuywqKiokAeQM1j qgoRzxOd08r7H/xMb2tEYutlTFK3SS/4M8LhMUTq2wa29hMVBvGFDu5SYN5Z0r+gF0mW rRw9MzJ+cNMEN8kqmxC1y7d0T7MalzIruz+SoiVY1SLeX4wVbktJFPzOHahQPV5d7jBd pxBQ== 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=bOEKal8RBRTtWSpTxNA94ZGJWCyGRWdgsr1BoKcGe9Y=; b=ikh1dxmpb2IXqq8l7B1bQvrVFLo1s3v/wRL5lNffh05IGuKWoN8M498Vv9O/qpfQi4 hmVDpwhmkWdZmF1o6fkAICxtrgBL5Kq/oXny0tH7nyLQuLIrwQ6Ucyb2yfoCMAKJhKIT eUyWOUgR2uQm5wCoEHa60kcpH0OXNA2S9buqwADS1ZsJKtlI2MXEOnR13jaErCWefq9A vRSZ3mVjXKOV6dx+xMs16IOhh6ijv+9BecFR3Th6crmqHTuTcM3An1x05IUEuWAFlGZL 1TrNSBVD/JDcQSOqxN8RWXZw+xzbb1b2BbflH4lxE7Qfnpalg0b1B7Q/EYeaWRhIFQmE mVHg== X-Gm-Message-State: AGRZ1gI5cRfEHT1m6JJc2JWE9UOWSOSR1hChTgt/x9XHfL5/6rnaBgPB 2S0n8aUfm1TnPhgeXR41UMhRTQ== X-Google-Smtp-Source: AJdET5dBD0E5xJ40vEso8U5nzyUsyOPliGVN3y8L7pt7/Ig65473+BQawanYnU0kxpouZIDmv1Cubw== X-Received: by 2002:a1c:2dd0:: with SMTP id t199-v6mr2801475wmt.50.1541525444008; Tue, 06 Nov 2018 09:30:44 -0800 (PST) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id z17-v6sm16328416wrm.65.2018.11.06.09.30.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Nov 2018 09:30:43 -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 v10 02/22] kasan, slub: handle pointer tags in early_kmem_cache_node_alloc Date: Tue, 6 Nov 2018 18:30:17 +0100 Message-Id: <76e40ec9137224352051f1e3ebcd8e8ee95044e1.1541525354.git.andreyknvl@google.com> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-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);