From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756743AbcKKOtA (ORCPT ); Fri, 11 Nov 2016 09:49:00 -0500 Received: from merlin.infradead.org ([205.233.59.134]:57300 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756108AbcKKOs7 (ORCPT ); Fri, 11 Nov 2016 09:48:59 -0500 Date: Fri, 11 Nov 2016 15:48:52 +0100 From: Peter Zijlstra To: Thomas Gleixner Cc: Mark Rutland , kernel-hardening@lists.openwall.com, Kees Cook , Greg KH , Will Deacon , Elena Reshetova , Arnd Bergmann , Ingo Molnar , "H. Peter Anvin" , LKML Subject: Re: [kernel-hardening] Re: [RFC v4 PATCH 00/13] HARDENED_ATOMIC Message-ID: <20161111144852.GL3117@twins.programming.kicks-ass.net> References: <20161110204838.GE17134@arm.com> <20161110211310.GX3117@twins.programming.kicks-ass.net> <20161110222744.GD8086@kroah.com> <20161110235714.GR3568@worktop.programming.kicks-ass.net> <1478824161.7326.5.camel@cvidal.org> <20161111124126.GG11945@leverpostej> <20161111124755.GI3117@twins.programming.kicks-ass.net> <20161111130034.GO3157@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 11, 2016 at 03:39:05PM +0100, Thomas Gleixner wrote: > On Fri, 11 Nov 2016, Peter Zijlstra wrote: > > A wee bit like so... > > + > > +static inline bool refcount_sub_and_test(int i, refcount_t *r) > > Why would we want to expose that at all? refcount_inc() and > refcount_dec_and_test() is what is required for refcounting. > > I know there are a few users of kref_sub() in tree, but that's all > undocumented voodoo, which should not be proliferated. I tend to agree. There are a few other sites that do multiple get/put as well using atomic_t. So supporting them using refcount_t is trivial -- simply match the atomic*() functions in semantics with added wrappery tests, but you're right in that having these encourages 'creative' use which we would be better off without. Ideally the audit would include sanitizing this. Moreover, there really is only a handfull of these creative user, so maybe we could just leave them be.