Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752088AbdFNO0M (ORCPT ); Wed, 14 Jun 2017 10:26:12 -0400 Received: from mx2.suse.de ([195.135.220.15]:46501 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751868AbdFNO0L (ORCPT ); Wed, 14 Jun 2017 10:26:11 -0400 Date: Wed, 14 Jun 2017 16:26:09 +0200 From: Petr Mladek To: Josh Poimboeuf Cc: Joe Lawrence , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, Jessica Yu , Jiri Kosina , Miroslav Benes Subject: Re: [PATCH 1/3] livepatch: introduce shadow variable API Message-ID: <20170614142608.GB2583@pathway.suse.cz> References: <1496341526-19061-1-git-send-email-joe.lawrence@redhat.com> <1496341526-19061-2-git-send-email-joe.lawrence@redhat.com> <20170614125913.GC15013@pathway.suse.cz> <20170614131744.43izgxdl4qvwmgbj@treble> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170614131744.43izgxdl4qvwmgbj@treble> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 994 Lines: 31 On Wed 2017-06-14 08:17:44, Josh Poimboeuf wrote: > On Wed, Jun 14, 2017 at 02:59:13PM +0200, Petr Mladek wrote: > > > +} > > > + > > > +void klp_shadow_detach(void *obj, char *var) > > > +{ > > > + unsigned long flags; > > > + struct klp_shadow *shadow; > > > + > > > + spin_lock_irqsave(&klp_shadow_lock, flags); > > > + > > > + hash_for_each_possible(klp_shadow_hash, shadow, node, > > > + (unsigned long)obj) { > > > + if (shadow->obj == obj && !strcmp(shadow->var, var)) { > > > > Do we need to test "shadow->obj == obj" here? If it is not true, > > there would be a bug in the hashtable implementation or in > > klp_shadow_attach(). > > > > Well, it might make sense to add a consistency check: > > > > WARN_ON(shadow->obj != obj); > > > > It would make sense if hash_for_each_possible() worked that way, but for > some reason it doesn't. :-/ It gives you all the hash collisions. I see. Shame on me. The original code makes perfect sense then. Best Regards, Petr