Re: [PATCH 1/3 v4] livepatch: add old_sympos as disambiguator field to klp_func

From: Miroslav Benes
Date: Thu Nov 12 2015 - 05:22:36 EST

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

> + 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.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at