Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5389804imm; Tue, 18 Sep 2018 08:48:04 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZ5ltmwCRQebfjvulY5JQFH4FlhVMbc09RqaGisaoc/wIPoUP/UAvLBAjxzrLT4kcfbJI9T X-Received: by 2002:a62:9e08:: with SMTP id s8-v6mr31781600pfd.23.1537285684176; Tue, 18 Sep 2018 08:48:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537285684; cv=none; d=google.com; s=arc-20160816; b=dgq8rIy7g6T/aTDNrHkeQ7V2gZUE6CYj7ioTrn+xqIkY2Q3EqTTup9aydVRGgkNzqV aa/OWS6FJulTPPRgvMjfF+yhT63sRQfcsBLqvwZ/x9Ci2NQQTAvsTt2KnGbP92FnLJOa lTKrnatXUxaGFnbsK5K+2mYi/6Coyuke+VpTl7MsZ1LbWvAqkF2qnrzRYd65CVIKAZTY 5u5N3CWY8Y2dfPEDPk1OVdIvWsf5KBaKD04Lmyq/QPWkI7DNGJ7IzpUIR6eKuZUTvxGY 2yju7Yb+RB9LjjAePKIYYTVxBhgGXHcv5H2pktmHiBoA0m4nV11Aecf8l783uIjUiH6V Uagg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature; bh=G39LeE3j89pOeDp3MlZsLrw2HaAfCPU7/f1VOjS6b4I=; b=qyAByDCNYu4vLg8GVfnFY850gFDs42wfsPQqSjwW3jHK3/pz1qQyS5BnsEC6DpLiJx /S5Ng1z0w/Um/EUmuOmmVu1UbWX1r5wl8yTulb++nc8UV2CeQI7lLhcPAqQEvepBvkbB rgkDIxOGoWQit/Bg3g9Wglrvol9Id2sYjcloNIUvDYnNqcj1dQklTQU8lsthIABval1z VgrAs9eLzFiKTb8xrBtS6mMkyNybZvXin7lABRUiP7u7nNp30c+UIGSm7kdzHo+9v1K5 CfFs3dn7Jd8lMlL4nYjlIyJcgqHveLxo0I1pwCc3IVTewq7ipsyEaUxe2NJYYijlnqAi n+TQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Ck5hVqgq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 43-v6si19140183plc.496.2018.09.18.08.47.42; Tue, 18 Sep 2018 08:48:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Ck5hVqgq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729900AbeIRVSm (ORCPT + 99 others); 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-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().