From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on archive.lwn.net X-Spam-Level: X-Spam-Status: No, score=-13.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by archive.lwn.net (Postfix) with ESMTP id 0E5007D57F for ; Tue, 18 Sep 2018 15:45:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728912AbeIRVSm (ORCPT ); Tue, 18 Sep 2018 17:18:42 -0400 Received: from mail-it0-f66.google.com ([209.85.214.66]:34877 "EHLO mail-it0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729753AbeIRVSl (ORCPT ); Tue, 18 Sep 2018 17:18:41 -0400 Received: by mail-it0-f66.google.com with SMTP id 139-v6so3647743itf.0 for ; Tue, 18 Sep 2018 08:45:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=G39LeE3j89pOeDp3MlZsLrw2HaAfCPU7/f1VOjS6b4I=; b=Ck5hVqgqbrrpb+24RXExvL0YlH+GoMxdJ17SyWcTIYCPfU4F0vfX+ox/33kzkiROfF +ADvndyKfq+DMzjD4aVCmZDUNHaAJ8bJD/xN43sMCxSfFAIJJQZeELDTM2QhMnwFvxvD l3AfCWGLMRJc+QtuVne9O6spJJbiF1OOUUuOSzL6cHPb8kXLxn9g9bDKf5RurG6y3oXD HHj6ct35HM59mjgYXMxyW+xvy6TpMArp9OvY61klIvaOVc+coYUD6gPMzsnYHK0xAgNP YYLwXQaDTxP+aVmBRrs5/7j3/xaa54yshIorHpbDGPmZedrNqGqvNpgAS5FvjGUwpJKg AxQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=G39LeE3j89pOeDp3MlZsLrw2HaAfCPU7/f1VOjS6b4I=; b=FC6SYB+b7ZOPke1VQNYNLrkivmpj9WPOvwQxIOmMSOzLZVHcdZEYlILbr+mEJGP2i6 fzxTcajDKyBTokxoaA9T7IZ1TKzRUXFzTX1HsTtYX8EDJzb6FobT074hTD4dQRKOirqJ QwuYFhl4vm2/gXmhAGiXf0Gr26tE5GIQe8fVnilP/UP8eqqUBm9C1yxrODTV2eGSj+eC Nwg4c+KNEt9mFD7/wKpCqjjla773HiF4nuM02v3M6ZtppZ8HKz6xMN3SSnWUpUrqVBhV XZVkqBy4Kv9u1xCKlrnuLzPVjt6U3iMuhEfTpy0iqLseK+Gg0kpvwF6yL+bf+Xqbflls 5oYw== X-Gm-Message-State: APzg51AEy24hb/IgTfxO65vrQ6Zte0ORQ3ac7VhsXFBloE4MGldfbWcC FIkHeL8kdLa5LZM1CjGZbirA2vC4erKO7Qxhon98sA== X-Google-Smtp-Source: ANB0VdaHaepZAaqjLoWrQ8SoCHpVOxP8PA/aubJWtZA7UY6iOrQCoVT2MZXTHCI0Xn7uVldkY9bAR0C41LfkiBOOZds= X-Received: by 2002:a24:d286:: with SMTP id z128-v6mr16414275itf.14.1537285532139; Tue, 18 Sep 2018 08:45:32 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a02:5942:0:0:0:0:0 with HTTP; Tue, 18 Sep 2018 08:45:11 -0700 (PDT) In-Reply-To: References: <6cd298a90d02068969713f2fd440eae21227467b.1535462971.git.andreyknvl@google.com> From: Dmitry Vyukov Date: Tue, 18 Sep 2018 17:45:11 +0200 Message-ID: Subject: Re: [PATCH v6 07/18] khwasan: add tag related helper functions To: Andrey Konovalov Cc: Andrey Ryabinin , Alexander Potapenko , 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 , "open list:DOCUMENTATION" , LKML , Linux ARM , linux-sparse@vger.kernel.org, Linux-MM , "open list:KERNEL BUILD + fi..." , Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan , Jann Horn , Mark Brand , Chintan Pandya , Vishwath Mohan Content-Type: text/plain; charset="UTF-8" Sender: linux-doc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-doc@vger.kernel.org On Mon, Sep 17, 2018 at 8:59 PM, Andrey Konovalov wrote: > On Wed, Sep 12, 2018 at 6:21 PM, Dmitry Vyukov wrote: >> On Wed, Aug 29, 2018 at 1:35 PM, Andrey Konovalov wrote: > >>> +void *khwasan_preset_slub_tag(struct kmem_cache *cache, const void *addr) >> >> Can't we do this in the existing kasan_init_slab_obj() hook? It looks >> like it should do exactly this -- allow any one-time initialization >> for objects. We could extend it to accept index and return a new >> pointer. >> If that does not work for some reason, I would try to at least unify >> the hook for slab/slub, e.g. pass idx=-1 from slub and then use >> random_tag(). >> It also seems that we do preset tag for slab multiple times (from >> slab_get_obj()). Using kasan_init_slab_obj() should resolve this too >> (hopefully we don't call it multiple times). > > The issue is that SLAB stores freelist as an array of indexes instead > of using an actual linked list like SLUB. So you can't store the tag > in the pointer while the object is in the freelist, since there's no > pointer. And, technically, we don't preset tags for SLAB, we just use > the id as the tag every time a pointer is used, so perhaps we should > rename the callback. As to unifying the callbacks, sure, we can do > that. As per offline discussion: potentially we can use kasan_init_slab_obj() if we add tag in kmalloc hook by using obj_to_idx().