Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3957443imm; Mon, 6 Aug 2018 13:48:25 -0700 (PDT) X-Google-Smtp-Source: AAOMgpejeYbaoLQ+yR91AlDNR6tfnbtFwTyBcsCptyOjZzakaV3/4s+Q81BQ268XC6CKr8PHX7am X-Received: by 2002:a63:4a61:: with SMTP id j33-v6mr15935690pgl.436.1533588505627; Mon, 06 Aug 2018 13:48:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533588505; cv=none; d=google.com; s=arc-20160816; b=xkRRSenRe0npqZ+EFf44ZlVvnlGFCynRBUsKQ4wLQ20+e70RoloFMJwyZ5WxgsmsU0 U5DFLLuixPCJLXxfT5dC6IwgOAgOn9rFVbmB4SVGdOYaO/qwStWmRw+bqc4tpPzNNGLP ujD0siaX4VPDTltPPCik/rgOe7vyuBtqz618RF01ejPPRDV3B3O0dpudDzNxWt309GS7 3Eobka9ea3iotAXFsWg84BU5utRifu0sMJfSSIUAA+wmuTepbABFZrquJVo9bBdnGzOP HmO1Pq7+zeW89wf8ze6CHtuKDMYLGIN23gWMM5gLD5U1sR+xnaqmDgqytdTDT5tgOG73 Z7TQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=u05IdLOqIGFa8G2KbwvG3gUyxTA/8iLm7h+zo1Yfehc=; b=JsT24ujewO5aRW/GpGedUxNZn++6DvJj9I8pqLT487GexRylSdG5fOXQfXIVeTrSJy gdpdpkGqmt8giRayX4WBxjO93SIsXSKXoKXhX9XLVGnQlH4QyzeGxsKlPDrgXexE3cOA +3Vq8D0CrBN8QTUOP8G4Sn9jIESRurM7F0VzyiIe/kJT9A4t60+Kc2mIGPJ3I0Qr1AKA TZ+mI/5fd3DRQ/DHOXzUf+B0YWpvCjqZAKe80n1aSt1FiYyynqKt7jf1RtQIkX8RkFO+ F7x2OfFjkf53Tw5Ddp++Rr/03PHZ+oWTg0ZdooeSP+XtsvcaEjbBOlv8qW+bpaJdsAcW qKVg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h90-v6si10699194plb.484.2018.08.06.13.48.10; Mon, 06 Aug 2018 13:48:25 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387740AbeHFWbH (ORCPT + 99 others); Mon, 6 Aug 2018 18:31:07 -0400 Received: from mx2.suse.de ([195.135.220.15]:38124 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732733AbeHFWbH (ORCPT ); Mon, 6 Aug 2018 18:31:07 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 3D2CEAE9D; Mon, 6 Aug 2018 20:20:21 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 6A0AB1E0A3B; Mon, 6 Aug 2018 22:20:17 +0200 (CEST) Date: Mon, 6 Aug 2018 22:20:17 +0200 From: Jan Kara 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 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: User-Agent: NeoMutt/20170912 (1.9.0) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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