From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932124AbdJWGpS (ORCPT ); Mon, 23 Oct 2017 02:45:18 -0400 Received: from mga05.intel.com ([192.55.52.43]:39757 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751152AbdJWGpQ (ORCPT ); Mon, 23 Oct 2017 02:45:16 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.43,421,1503385200"; d="scan'208";a="1233995233" From: "Reshetova, Elena" To: Michael Lyle , "dm-devel@redhat.com" CC: "linux-bcache@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-raid@vger.kernel.org" , "kent.overstreet@gmail.com" , "koverstreet@google.com" , "ejt@redhat.comg" , "snitzer@redhat.com" , "shli@kernel.org" , "agk@redhat.com" , "peterz@infradead.org" , "keescook@chromium.org" Subject: RE: [PATCH 1/4] bcache: convert cached_dev.count from atomic_t to refcount_t Thread-Topic: [PATCH 1/4] bcache: convert cached_dev.count from atomic_t to refcount_t Thread-Index: AQHTSXZ4aLRhmogCr0SiaXcg4YgT9KLtAeUAgAP/8QA= Date: Mon, 23 Oct 2017 06:45:09 +0000 Message-ID: <2236FBA76BA1254E88B949DDB74E612B802B41FC@IRSMSX102.ger.corp.intel.com> References: <1508485059-21881-1-git-send-email-elena.reshetova@intel.com> <1508485059-21881-2-git-send-email-elena.reshetova@intel.com> <8bd05fae-d41f-24e7-4e58-bf07d9a09a99@lyle.org> In-Reply-To: <8bd05fae-d41f-24e7-4e58-bf07d9a09a99@lyle.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-ctpclassification: CTP_IC x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYmQ2Mjk0NzEtNTAwZS00MWM4LTk2YjgtMGMwYTIyZDJmYjQxIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJWMkJJWis4OUd0eWk2Yk5jenJndVwvVWRWUHRtc0NwVU5JbU16RDhTNVwvR083MUFmWXkzdkRxNlpIZTUyblVQangifQ== x-originating-ip: [163.33.239.180] Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by nfs id v9N6jMwx011041 > On 10/20/2017 12:37 AM, Elena Reshetova wrote: > > atomic_t variables are currently used to implement reference > > counters with the following properties: > > - counter is initialized to 1 using atomic_set() > > - a resource is freed upon counter reaching zero > > - once counter reaches zero, its further > > increments aren't allowed > > - counter schema uses basic atomic operations > > (set, inc, inc_not_zero, dec_and_test, etc.) > > > > Such atomic variables should be converted to a newly provided > > refcount_t type and API that prevents accidental counter overflows > > and underflows. This is important since overflows and underflows > > can lead to use-after-free situation and be exploitable. > > > > The variable cached_dev.count is used as pure reference counter. > > Convert it to refcount_t and fix up the operations. > > > > Suggested-by: Kees Cook > > Reviewed-by: David Windsor > > Reviewed-by: Hans Liljestrand > > Signed-off-by: Elena Reshetova > > Reviewed-by: Michael Lyle > > Thanks for this-- I'm including it in my tree for possible inclusion in > 4.15 (I've already sent my main chunk of changes upwards). Thank you Mike! I am dropping then this patch from my list of maintained conversions. Best Regards, Elena. > > Mike