From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C0FBECE564 for ; Tue, 18 Sep 2018 15:45:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EF72C214C2 for ; Tue, 18 Sep 2018 15:45:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Ck5hVqgq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EF72C214C2 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729911AbeIRVSm (ORCPT ); Tue, 18 Sep 2018 17:18:42 -0400 Received: from mail-it0-f66.google.com ([209.85.214.66]:50729 "EHLO mail-it0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729447AbeIRVSm (ORCPT ); Tue, 18 Sep 2018 17:18:42 -0400 Received: by mail-it0-f66.google.com with SMTP id j81-v6so3913373ite.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=WLFU+JNZEd4CBoJNFdW9aoKRIWs40yLBDJ8uae2sHw4SEcig2P3Guf+gTy6ALWJ9ly RoxVVr5ynx6rNJbrOH3Lrtu4118UZnYFUwgewGn6/ViLo90tZkcMGpt6829cFqTqqM6z Yg1zLVpV79dcK8w4jgUS6Jd4IQHKq1xvOcj5wwGWBOjEoQ1sw4dWnz2NcjWXEM3NFaq7 aRhJeb4v4r7tjFyEUUnsj0E+Hai4X+wUFndJtY7KZnGq5DfYacooDnwjkhxZZT5aIm7N rnhMQJpZjfUUDfryoqb8ZWs3GbcXFbI+SStvBh5Ocvgaqpi9Gh4RUEZKbEaatCc58B4m 2wcg== X-Gm-Message-State: APzg51DisqlL9Gr3EQgb5/TUWUSY/6VDDw0+Bv5fME76irja9IB0TCCV bTMKkgbJ6j5UhmYMLCemNE4/ISMGlo3iIn400t8AWg== 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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().