From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754085AbbKLKWd (ORCPT ); Thu, 12 Nov 2015 05:22:33 -0500 Received: from mx2.suse.de ([195.135.220.15]:46862 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752601AbbKLKWc (ORCPT ); Thu, 12 Nov 2015 05:22:32 -0500 Date: Thu, 12 Nov 2015 11:22:31 +0100 (CET) From: Miroslav Benes To: Chris J Arges cc: live-patching@vger.kernel.org, jeyu@redhat.com, Josh Poimboeuf , Seth Jennings , Jiri Kosina , Vojtech Pavlik , linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/3 v4] livepatch: add old_sympos as disambiguator field to klp_func In-Reply-To: <1447259366-7055-2-git-send-email-chris.j.arges@canonical.com> Message-ID: References: <20151103200608.GQ27488@treble.redhat.com> <1447259366-7055-1-git-send-email-chris.j.arges@canonical.com> <1447259366-7055-2-git-send-email-chris.j.arges@canonical.com> User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Next to Josh's remarks I have some more (mainly nitpicks, so it is often up to you). On Wed, 11 Nov 2015, Chris J Arges wrote: > In cases of duplicate symbols, old_sympos will be used to disambiguate > instead of old_addr. By default old_sympos will be 0, and patching will > only succeed if the symbol is unique. Specifying a positive value will > ensure that occurrence of the symbol will be used for patching if it is "...occurrence of the symbol in kallsyms for the patched object will be used..." Just to have it even in the changelog for clarity. > valid. Finally, old_addr is now an internal structure element and not to > be specified by the user. > @@ -159,36 +160,45 @@ static int klp_find_callback(void *data, const char *name, > return 0; > > /* > - * args->addr might be overwritten if another match is found > - * but klp_find_object_symbol() handles this and only returns the > - * addr if count == 1. > + * increment and assign address, return only if checking pos and > + * it matches count. > */ > - args->addr = addr; > args->count++; > + args->addr = addr; I guess that this row swap is remnant of a rebase. Anyway it is superfluous. > + if ((args->pos > 0) && (args->count == args->pos)) > + return 1; We could add an optimization here. If args->pos == 0 and args->count > 1 we can return 1, because the symbol is not unique. The case is then correctly handled in klp_find_object_symbol. There is no need to walk through the rest of kallsyms. Thanks, Miroslav