From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by kanga.kvack.org (Postfix) with ESMTP id 707016B000C for ; Mon, 6 Aug 2018 16:20:23 -0400 (EDT) Received: by mail-ed1-f70.google.com with SMTP id d18-v6so4603728edp.0 for ; Mon, 06 Aug 2018 13:20:23 -0700 (PDT) Received: from mx1.suse.de (mx2.suse.de. [195.135.220.15]) by mx.google.com with ESMTPS id j44-v6si7685846eda.76.2018.08.06.13.20.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Aug 2018 13:20:22 -0700 (PDT) Date: Mon, 6 Aug 2018 22:20:17 +0200 From: Jan Kara Subject: Re: SLAB_TYPESAFE_BY_RCU without constructors (was Re: [PATCH v4 13/17] khwasan: add hooks implementation) Message-ID: <20180806202017.lrzihv42b4mtcgrn@quack2.suse.cz> References: <01000164f169bc6b-c73a8353-d7d9-47ec-a782-90aadcb86bfb-000000@email.amazonses.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: owner-linux-mm@kvack.org List-ID: To: Dmitry Vyukov Cc: Linus Torvalds , Christoph Lameter , Andrey Ryabinin , Theodore Ts'o , Jan Kara , linux-ext4@vger.kernel.org, Greg Kroah-Hartman , Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , David Miller , NetFilter , coreteam@netfilter.org, Network Development , Gerrit Renker , dccp@vger.kernel.org, Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Dave Airlie , intel-gfx , DRI , Eric Dumazet , Alexey Kuznetsov , Hideaki YOSHIFUJI , Ursula Braun , linux-s390 , Linux Kernel Mailing List , Andrew Morton , linux-mm , Andrey Konovalov On Wed 01-08-18 10:46:35, Dmitry Vyukov wrote: > I guess it would be useful to have such extensive comment for each > SLAB_TYPESAFE_BY_RCU use explaining why it is needed and how all the > tricky aspects are handled. > > For example, the one in jbd2 is interesting because it memsets the > whole object before freeing it into SLAB_TYPESAFE_BY_RCU slab: > > memset(jh, JBD2_POISON_FREE, sizeof(*jh)); > kmem_cache_free(jbd2_journal_head_cache, jh); > > I guess there are also tricky ways how it can all work in the end > (type-stable state is only a byte, or we check for all possible > combinations of being overwritten with JBD2_POISON_FREE). But at first > sight it does look fishy. The RCU access is used from a single place: fs/jbd2/transaction.c: jbd2_write_access_granted() There are also quite some comments explaining why what it does is safe. The overwrite by JBD2_POISON_FREE is much older than this RCU stuff (honestly I didn't know about it until this moment) and has nothing to do with the safety of RCU access. Honza -- Jan Kara SUSE Labs, CR