Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp852416ybi; Fri, 31 May 2019 09:47:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqxdj8Qq8YalxO95Z+MCHgbk63M4kt+mmX+/toLkqYbOukGi3B3gRuXRcEFjZT531CQ+Xdg5 X-Received: by 2002:a63:6848:: with SMTP id d69mr10604852pgc.0.1559321264082; Fri, 31 May 2019 09:47:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559321264; cv=none; d=google.com; s=arc-20160816; b=gw8lPwODqHr7fuNCrl0JQVGIqWveBoT2RMp8bOipZVDjfPV5HLupDud588bsFAR8Ca mCm4zrmCaVD5ErR6Hg+y29wxxnnQBvEybgvwM/EX4f2pW8Yx6KB7EGg0RZ0DwpTuDaP/ 6s8HSgV0n5PlEabEAu4yRhlUlqKr2Ajc6enoOOvPiJouHc1HvIJLGDFTkfya30Q1lVJx 9AIjrMeDPMXa/rG5mUnKqrtYsd/A9pNBU9PsQU1fn2eibZodL4+72xcGYOpXZGjXdjhZ 2JvZfxPebtxZTLWPYLSEQHDTgX7gR3Eenc+Pj0oKD3hRbF2SC2HErUp5Y+sXkSd+Rhdo IB/w== 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:dkim-signature; bh=kWlXD8DiGcPRvC35zTm87cBBCSSsFkc29ZuXEbkqGVk=; b=yVHNKy2tJhTOS1Mwjz8JhzpWckxhoPdrUDIpL8XlPZPyLOXnSDYmgMe0dqedRHUY4Q Izuy2OR20Cu1Yu73HFfFLFodfnpkot0O4k/+5ySmZPM+8m1NRw3xdrRuJB9pNRdf7NIK FVOJ+XYc1ZcqfP+1g6Krw5QJw2o4luT4UxNnxXXx/pRnnVY4bSKZ42YclvgS3QotBmoq HDvxcNDD0YuUDHADMsjQkVFcqwKd1EeVwTvJ69Zd7mR59ke1P6UyRV/tnAITODfY8cjE ghIdbwjrXQeIr/DmYftQbXfPaXkZA2n1iQwx0XhYDRwdn84jX4lKz1CWIsgoeLoCepvI B8Gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=E7kQkfZH; 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 18si8052026pfy.280.2019.05.31.09.47.28; Fri, 31 May 2019 09:47:44 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=E7kQkfZH; 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 S1727034AbfEaQpH (ORCPT + 99 others); Fri, 31 May 2019 12:45:07 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:41948 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726037AbfEaQpH (ORCPT ); Fri, 31 May 2019 12:45:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=kWlXD8DiGcPRvC35zTm87cBBCSSsFkc29ZuXEbkqGVk=; b=E7kQkfZHgd8Xhu0FahwHyMpg5 V3rEtjoLJ3K9R4uoncA6Hex5gD8HOVuW7fVxbtdnIqyfv8W/h+05KnWJBg4vEKPRe2ymP3ySMITTe ixeyxsQmEDk7ZL4SYsPhLh0YihzKKEhtCm/WT5wgoDmN0fh1RghSDBWMAye5x0mUZAwBsAoTYuGAY Z9VFIGkIDNokycSy82VgJisRCfDA50kqxwNtaNZLL5GhRla8oD9tR3ZSVr+ETnDPQj7Z4gDMat87o PPgb+VPA/Vnh79iL++6flNyNB0V08ayFnXyxdC5HHjU1AWvBHkzDjczpYsUEZb6q0WmsvsoqSEH2I nHFV3dpDw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1hWke6-00080M-73; Fri, 31 May 2019 16:44:46 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 2CB6B201CF1CB; Fri, 31 May 2019 18:44:44 +0200 (CEST) Date: Fri, 31 May 2019 18:44:44 +0200 From: Peter Zijlstra To: David Howells Cc: Jann Horn , Greg KH , Al Viro , raven@themaw.net, linux-fsdevel , Linux API , linux-block@vger.kernel.org, keyrings@vger.kernel.org, linux-security-module , kernel list , Kees Cook , Kernel Hardening Subject: Re: [PATCH 1/7] General notification queue with user mmap()'able ring buffer Message-ID: <20190531164444.GD2606@hirez.programming.kicks-ass.net> References: <20190528162603.GA24097@kroah.com> <155905930702.7587.7100265859075976147.stgit@warthog.procyon.org.uk> <155905931502.7587.11705449537368497489.stgit@warthog.procyon.org.uk> <4031.1559064620@warthog.procyon.org.uk> <20190528231218.GA28384@kroah.com> <31936.1559146000@warthog.procyon.org.uk> <16193.1559163763@warthog.procyon.org.uk> <21942.1559304135@warthog.procyon.org.uk> <606.1559312412@warthog.procyon.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <606.1559312412@warthog.procyon.org.uk> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 31, 2019 at 03:20:12PM +0100, David Howells wrote: > Peter Zijlstra wrote: > > (and it has already been established that refcount_t doesn't work for > > usage count scenarios) > > ? > > Does that mean struct kref doesn't either? Indeed, since kref is just a pointless wrapper around refcount_t it does not either. The main distinction between a reference count and a usage count is that 0 means different things. For a refcount 0 means dead. For a usage count 0 is merely unused but valid. Incrementing a 0 refcount is a serious bug -- use-after-free (and hence refcount_t will refuse this and splat), for a usage count this is no problem. Now, it is sort-of possible to merge the two, by basically stating something like: usage = refcount - 1. But that can get tricky and people have not really liked the result much for the few times I tried.