From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932944AbdBVRUY convert rfc822-to-8bit (ORCPT ); Wed, 22 Feb 2017 12:20:24 -0500 Received: from mga02.intel.com ([134.134.136.20]:49935 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932602AbdBVRUQ (ORCPT ); Wed, 22 Feb 2017 12:20:16 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,195,1484035200"; d="scan'208";a="936912186" From: "Reshetova, Elena" To: David Howells CC: "linux-kernel@vger.kernel.org" , "linux-afs@lists.infradead.org" , "peterz@infradead.org" , "gregkh@linuxfoundation.org" , Hans Liljestrand , "Kees Cook" , David Windsor Subject: RE: [PATCH 1/4] fs, afs: convert afs_cell.usage from atomic_t to refcount_t Thread-Topic: [PATCH 1/4] fs, afs: convert afs_cell.usage from atomic_t to refcount_t Thread-Index: AQHSjFlH0Aza8UMUrUiQNZ8uKmd18aF1NTYAgAAPUBA= Date: Wed, 22 Feb 2017 17:19:49 +0000 Message-ID: <2236FBA76BA1254E88B949DDB74E612B41C4EF59@IRSMSX102.ger.corp.intel.com> References: <1487691808-11289-2-git-send-email-elena.reshetova@intel.com> <1487691808-11289-1-git-send-email-elena.reshetova@intel.com> <12908.1487780160@warthog.procyon.org.uk> In-Reply-To: <12908.1487780160@warthog.procyon.org.uk> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.180] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > Elena Reshetova wrote: > > > 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. > > This causes an assertion failure because cells aren't immediately destroyed > when their refcount reaches 0, but may be resurrected provided the cache lock > is held. However, attempting to increment the 0 refcount does nothing, not > even giving a warning. This is strange, it is supposed to give a warning I think now when it is even not inlined. Peter, am I confusing smth? > > So please place a hold on this patch. I will check the other AFS patches also. > Thank you very much David for testing the patches! I guess for this one and other two patches it means that if we want to do the atomic_t --> refcount_t conversions, we need to do +1 on the whole counting scheme to avoid issues around reaching zero. Do you see this approach reasonable? I can give it a try, if it makes sense in your opinion. Best Regards, Elena.