Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965899AbdCVTId (ORCPT ); Wed, 22 Mar 2017 15:08:33 -0400 Received: from mail-it0-f47.google.com ([209.85.214.47]:36219 "EHLO mail-it0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935973AbdCVTIQ (ORCPT ); Wed, 22 Mar 2017 15:08:16 -0400 MIME-Version: 1.0 In-Reply-To: <1490148199.16816.126.camel@edumazet-glaptop3.roam.corp.google.com> References: <1489767196.28631.305.camel@edumazet-glaptop3.roam.corp.google.com> <20170318164759.GA23837@gondor.apana.org.au> <20170318.182121.439615057765380575.davem@davemloft.net> <20170320103937.lq7nfnutupr3gkn7@hirez.programming.kicks-ass.net> <20170320131629.GA26405@gondor.apana.org.au> <20170320132357.acygo3umw6fiwb4p@hirez.programming.kicks-ass.net> <20170320132713.GA26954@gondor.apana.org.au> <20170320134017.h3c2jrsnd4guuyu7@hirez.programming.kicks-ass.net> <1490131389.16816.123.camel@edumazet-glaptop3.roam.corp.google.com> <1490148199.16816.126.camel@edumazet-glaptop3.roam.corp.google.com> From: Kees Cook Date: Wed, 22 Mar 2017 12:08:03 -0700 X-Google-Sender-Auth: wPYol7MKluiGWqvB7UXbeBrRizc Message-ID: Subject: Re: [PATCH 07/17] net: convert sock.sk_refcnt from atomic_t to refcount_t To: Eric Dumazet Cc: Peter Zijlstra , Herbert Xu , David Miller , "Reshetova, Elena" , Network Development , bridge@lists.linux-foundation.org, LKML , Alexey Kuznetsov , James Morris , Patrick McHardy , Stephen Hemminger , Hans Liljestrand , David Windsor , Andrew Morton Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1119 Lines: 40 On Tue, Mar 21, 2017 at 7:03 PM, Eric Dumazet wrote: > On Tue, 2017-03-21 at 16:51 -0700, Kees Cook wrote: > >> Am I understanding you correctly that you'd want something like: >> >> refcount.h: >> #ifdef UNPROTECTED_REFCOUNT >> #define refcount_inc(x) atomic_inc(x) >> ... >> #else >> void refcount_inc(... >> ... >> #endif >> >> some/net.c: >> #define UNPROTECTED_REFCOUNT >> #include >> >> or similar? > > At first, it could be something simple like that yes. > > Note that we might define two refcount_inc() : One that does whole > tests, and refcount_inc_relaxed() that might translate to atomic_inc() > on non debug kernels. > > Then later, maybe provide a dynamic infrastructure so that we can > dynamically force the full checks even for refcount_inc_relaxed() on say > 1% of the hosts, to get better debug coverage ? Well, this isn't about finding bugs in normal workflows. This is about catching bugs that attackers have found and start exploiting to gain a use-after-free primitive. The intention is for it to be always enabled. -Kees -- Kees Cook Pixel Security