From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754445AbdC1JfH convert rfc822-to-8bit (ORCPT ); Tue, 28 Mar 2017 05:35:07 -0400 Received: from smtp-out6.electric.net ([192.162.217.190]:60342 "EHLO smtp-out6.electric.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751785AbdC1JfF (ORCPT ); Tue, 28 Mar 2017 05:35:05 -0400 From: David Laight To: "'Elena Reshetova'" , "netdev@vger.kernel.org" CC: "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-rdma@vger.kernel.org" , "linux-hams@vger.kernel.org" , "linux-ppp@vger.kernel.org" , "linux-wireless@vger.kernel.org" , "ganeshgr@chelsio.com" , "nbd@openwrt.org" , "blogic@openwrt.org" , "matthias.bgg@gmail.com" , "yishaih@mellanox.com" , "saeedm@mellanox.com" , "matanb@mellanox.com" , "leonro@mellanox.com" , "ajk@comnets.uni-bremen.de" , "paulus@samba.org" , "j@w1.fi" , "kvalo@codeaurora.org" , "peterz@infradead.org" , "keescook@chromium.org" , "gregkh@linuxfoundation.org" , Hans Liljestrand , "David Windsor" Subject: RE: [PATCH 06/16] drivers, net, mlx5: convert mlx5_cq.refcount from atomic_t to refcount_t Thread-Topic: [PATCH 06/16] drivers, net, mlx5: convert mlx5_cq.refcount from atomic_t to refcount_t Thread-Index: AQHSp6HnwY9uaOSTG0SY6iim/wdmRqGp/ADQ Date: Tue, 28 Mar 2017 09:33:21 +0000 Message-ID: <063D6719AE5E284EB5DD2968C1650D6DCFFBE8AF@AcuExch.aculab.com> References: <1490691403-4016-1-git-send-email-elena.reshetova@intel.com> <1490691403-4016-7-git-send-email-elena.reshetova@intel.com> In-Reply-To: <1490691403-4016-7-git-send-email-elena.reshetova@intel.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.202.99.200] Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-Outbound-IP: 213.249.233.130 X-Env-From: David.Laight@ACULAB.COM X-Proto: esmtps X-Revdns: X-HELO: AcuExch.aculab.com X-TLS: TLSv1:AES128-SHA:128 X-Authenticated_ID: X-PolicySMART: 3396946, 3397078 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Elena Reshetova > Sent: 28 March 2017 09:57 > > refcount_t type and corresponding API should be > used instead of atomic_t when the variable is used as > a reference counter. This allows to avoid accidental > refcounter overflows that might lead to use-after-free > situations. I can't help feeling that you ought to find a scheme that will detect extra decrements and extra increments before the counter wraps 32 bits. If an extra reference is requested every 100us it takes 4.8 days for the counter to increment back to zero. Simple tests aren't doing to find that - but it can easily happen on a system that is running for several years. David