Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933222AbcLNRNA (ORCPT ); Wed, 14 Dec 2016 12:13:00 -0500 Received: from mx2.suse.de ([195.135.220.15]:42290 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932835AbcLNRM5 (ORCPT ); Wed, 14 Dec 2016 12:12:57 -0500 Date: Wed, 14 Dec 2016 18:12:52 +0100 From: "Luis R. Rodriguez" To: Petr Mladek Cc: "Luis R. Rodriguez" , shuah@kernel.org, jeyu@redhat.com, rusty@rustcorp.com.au, ebiederm@xmission.com, dmitry.torokhov@gmail.com, acme@redhat.com, corbet@lwn.net, martin.wilck@suse.com, mmarek@suse.com, hare@suse.com, rwright@hpe.com, jeffm@suse.com, DSterba@suse.com, fdmanana@suse.com, neilb@suse.com, linux@roeck-us.net, rgoldwyn@suse.com, subashab@codeaurora.org, xypron.glpk@gmx.de, keescook@chromium.org, atomlin@redhat.com, mbenes@suse.cz, paulmck@linux.vnet.ibm.com, dan.j.williams@intel.com, jpoimboe@redhat.com, davem@davemloft.net, mingo@redhat.com, akpm@linux-foundation.org, torvalds@linux-foundation.org, linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC 06/10] kmod: provide sanity check on kmod_concurrent access Message-ID: <20161214171252.GP1402@wotan.suse.de> References: <20161208184801.1689-1-mcgrof@kernel.org> <20161208194850.2627-1-mcgrof@kernel.org> <20161214160858.GI16064@pathway.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161214160858.GI16064@pathway.suse.cz> User-Agent: Mutt/1.6.0 (2016-04-01) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1421 Lines: 33 On Wed, Dec 14, 2016 at 05:08:58PM +0100, Petr Mladek wrote: > On Thu 2016-12-08 11:48:50, Luis R. Rodriguez wrote: > > Only decrement *iff* we're possitive. Warn if we've hit > > a situation where the counter is already 0 after we're done > > with a modprobe call, this would tell us we have an unaccounted > > counter access -- this in theory should not be possible as > > only one routine controls the counter, however preemption is > > one case that could trigger this situation. Avoid that situation > > by disabling preemptiong while we access the counter. > > I am curious about it. How could enabled preemption cause that > the counter will get negative? As the commit log describes today in theory this is not possible was we have only have one routine controlling the counter. If we were to expand this then such possibilities become more real. > Unaccounted access would be possible if put() is called > without get() or if put() is called before get(). Exactly, so buggy users of the get/put calls in future calls. I can just drop the preemption disable / enable for now as it should not be an issue now. > I do not see a way how the value might get negative when > the calls are paired and ordered. Right, this just matches parity with module_put(), its perhaps *preemptively* too cautious though so I could just drop the preemption enable/disable for now as that would slow down things a bit. Luis