From: Josh Poimboeuf <jpoimboe@redhat.com>
To: Chris J Arges <chris.j.arges@canonical.com>
Cc: live-patching@vger.kernel.org, jeyu@redhat.com,
Seth Jennings <sjenning@redhat.com>,
Jiri Kosina <jikos@kernel.org>, Vojtech Pavlik <vojtech@suse.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/4 v5] livepatch: add old_sympos as disambiguator field to klp_func
Date: Thu, 12 Nov 2015 13:45:49 -0600 [thread overview]
Message-ID: <20151112194549.GK4038@treble.hsd1.ky.comcast.net> (raw)
In-Reply-To: <1447347595-30728-2-git-send-email-chris.j.arges@canonical.com>
On Thu, Nov 12, 2015 at 10:59:50AM -0600, 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 in kallsyms for the patched object
> will be used for patching if it is valid.
>
> In addition, make old_addr an internal structure field not to be specified
> by the user. Finally, remove klp_find_verify_func_addr as it can be
> replaced by klp_find_object_symbol directly.
>
> Signed-off-by: Chris J Arges <chris.j.arges@canonical.com>
> ---
> include/linux/livepatch.h | 20 ++++++++-------
> kernel/livepatch/core.c | 65 ++++++++++++++++++++---------------------------
> 2 files changed, 38 insertions(+), 47 deletions(-)
>
> diff --git a/include/linux/livepatch.h b/include/linux/livepatch.h
> index 31db7a0..3d18dff 100644
> --- a/include/linux/livepatch.h
> +++ b/include/linux/livepatch.h
> @@ -37,8 +37,9 @@ enum klp_state {
> * struct klp_func - function structure for live patching
> * @old_name: name of the function to be patched
> * @new_func: pointer to the patched function code
> - * @old_addr: a hint conveying at what address the old function
> - * can be found (optional, vmlinux patches only)
> + * @old_sympos: a hint indicating which symbol position the old function
> + * can be found (optional)
> + * @old_addr: the address of the function being patched
> * @kobj: kobject for sysfs resources
> * @state: tracks function-level patch application state
> * @stack_node: list node for klp_ops func_stack list
> @@ -47,17 +48,18 @@ struct klp_func {
> /* external */
> const char *old_name;
> void *new_func;
> +
> /*
> - * The old_addr field is optional and can be used to resolve
> - * duplicate symbol names in the vmlinux object. If this
> - * information is not present, the symbol is located by name
> - * with kallsyms. If the name is not unique and old_addr is
> - * not provided, the patch application fails as there is no
> - * way to resolve the ambiguity.
> + * The old_sympos field is optional and can be used to resolve
> + * duplicate symbol names in livepatch objects. If this field is zero,
> + * it is expected the symbol is unique, otherwise patching fails. If
> + * this value is greater than zero then that occurrence of the symbol
> + * in kallsyms for the given object is used.
> */
> - unsigned long old_addr;
> + unsigned long old_sympos;
>
> /* internal */
> + unsigned long old_addr;
> struct kobject kobj;
> enum klp_state state;
> struct list_head stack_node;
> diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c
> index 6e53441..479d75e 100644
> --- a/kernel/livepatch/core.c
> +++ b/kernel/livepatch/core.c
> @@ -135,13 +135,8 @@ struct klp_find_arg {
> const char *objname;
> const char *name;
> unsigned long addr;
> - /*
> - * If count == 0, the symbol was not found. If count == 1, a unique
> - * match was found and addr is set. If count > 1, there is
> - * unresolvable ambiguity among "count" number of symbols with the same
> - * name in the same object.
> - */
> unsigned long count;
> + unsigned long pos;
> };
>
> static int klp_find_callback(void *data, const char *name,
> @@ -159,36 +154,46 @@ 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 the address. Return 1 when the desired symbol
> + * position is found or the search for a unique symbol fails.
> */
> args->addr = addr;
> args->count++;
> + if (((args->pos > 0) && (args->count == args->pos)) ||
> + ((args->pos == 0) && (args->count > 1)))
> + return 1;
>
> return 0;
> }
>
> static int klp_find_object_symbol(const char *objname, const char *name,
> - unsigned long *addr)
> + unsigned long *addr, unsigned long sympos)
One nit about this interface. I think it would be clearer if the sympos
argument came before the addr argument:
static int klp_find_object_symbol(const char *objname, const char *name,
unsigned long sympos, unsigned long addr)
Because:
1. it puts all input arguments before the output argument; and
2. it puts the sympos in its logical place immediately after the
function name.
--
Josh
next prev parent reply other threads:[~2015-11-12 19:45 UTC|newest]
Thread overview: 89+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-02 17:58 [PATCH] livepatch: old_name.number scheme in livepatch sysfs directory Chris J Arges
2015-11-02 19:15 ` Jessica Yu
2015-11-02 19:52 ` [PATCH] " Josh Poimboeuf
2015-11-02 20:16 ` Chris J Arges
2015-11-02 20:32 ` Josh Poimboeuf
2015-11-02 22:59 ` [PATCH v2] " Chris J Arges
2015-11-03 9:50 ` Miroslav Benes
2015-11-03 15:03 ` Josh Poimboeuf
2015-11-03 10:52 ` Miroslav Benes
2015-11-03 12:44 ` Petr Mladek
2015-11-03 15:03 ` Josh Poimboeuf
2015-11-03 19:57 ` Jiri Kosina
2015-11-03 20:06 ` Josh Poimboeuf
[not found] ` <1447259366-7055-1-git-send-email-chris.j.arges@canonical.com>
2015-11-11 16:28 ` [PATCH 1/3 v4] livepatch: add old_sympos as disambiguator field to klp_func Chris J Arges
2015-11-11 17:43 ` Josh Poimboeuf
2015-11-12 10:22 ` Miroslav Benes
2015-11-11 16:29 ` [PATCH 2/3 v4] livepatch: add old_sympos as disambiguator field to klp_reloc Chris J Arges
2015-11-11 16:39 ` Chris J Arges
2015-11-11 17:57 ` Josh Poimboeuf
2015-11-12 14:31 ` Petr Mladek
2015-11-12 19:19 ` Josh Poimboeuf
2015-11-13 13:54 ` Petr Mladek
2015-11-13 16:59 ` Josh Poimboeuf
2015-11-16 12:11 ` Petr Mladek
2015-11-12 10:23 ` Miroslav Benes
2015-11-11 16:29 ` [PATCH 3/3 v4] livepatch: old_name,number scheme in livepatch sysfs directory Chris J Arges
2015-11-11 18:01 ` Josh Poimboeuf
[not found] ` <1447347595-30728-1-git-send-email-chris.j.arges@canonical.com>
2015-11-12 16:59 ` [PATCH 1/4 v5] livepatch: add old_sympos as disambiguator field to klp_func Chris J Arges
2015-11-12 19:45 ` Josh Poimboeuf [this message]
2015-11-13 9:56 ` Jiri Kosina
2015-11-13 10:14 ` Miroslav Benes
2015-11-13 16:27 ` Petr Mladek
2015-11-12 16:59 ` [PATCH 2/4 v5] livepatch: Simplify code for relocated external symbols Chris J Arges
2015-11-13 10:24 ` Miroslav Benes
2015-11-13 13:55 ` Petr Mladek
2015-11-12 16:59 ` [PATCH 3/4 v5] livepatch: add sympos as disambiguator field to klp_reloc Chris J Arges
2015-11-12 19:50 ` Josh Poimboeuf
2015-11-13 16:42 ` Petr Mladek
2015-11-12 16:59 ` [PATCH 4/4 v5] livepatch: function,sympos scheme in livepatch sysfs directory Chris J Arges
[not found] ` <1447431804-18786-1-git-send-email-chris.j.arges@canonical.com>
2015-11-13 16:23 ` [PATCH 1/3 v6] livepatch: add old_sympos as disambiguator field to klp_func Chris J Arges
2015-11-13 16:23 ` [PATCH 2/3 v6] livepatch: add sympos as disambiguator field to klp_reloc Chris J Arges
2015-11-13 16:23 ` [PATCH 3/3 v6] livepatch: function,sympos scheme in livepatch sysfs directory Chris J Arges
[not found] ` <1447693391-10065-1-git-send-email-chris.j.arges@canonical.com>
2015-11-16 17:03 ` [PATCH 1/3 v7] livepatch: add old_sympos as disambiguator field to klp_func Chris J Arges
2015-11-16 21:59 ` Jiri Kosina
2015-11-17 14:29 ` Chris J Arges
2015-11-19 10:02 ` Jiri Kosina
2015-11-16 17:03 ` [PATCH 2/3 v7] livepatch: add sympos as disambiguator field to klp_reloc Chris J Arges
2015-11-18 9:56 ` Miroslav Benes
2015-11-18 14:01 ` Josh Poimboeuf
2015-11-18 16:47 ` Petr Mladek
2015-11-18 16:37 ` Petr Mladek
2015-11-18 16:39 ` Chris J Arges
2015-11-18 16:55 ` Petr Mladek
2015-11-18 20:34 ` Jiri Kosina
2015-11-16 17:03 ` [PATCH 3/3 v7] livepatch: function,sympos scheme in livepatch sysfs directory Chris J Arges
2015-11-20 17:25 ` [PATCH 0/3 v8] livepatch: disambiguate symbols with the same name Chris J Arges
2015-11-20 17:25 ` [PATCH 1/3 v8] livepatch: add old_sympos as disambiguator field to klp_func Chris J Arges
2015-11-23 9:47 ` Miroslav Benes
2015-11-20 17:25 ` [PATCH 2/3 v8] livepatch: add sympos as disambiguator field to klp_reloc Chris J Arges
2015-11-23 9:52 ` Miroslav Benes
2015-11-30 20:46 ` Chris J Arges
2015-12-01 1:17 ` Josh Poimboeuf
2015-11-20 17:25 ` [PATCH 3/3 v8] livepatch: function,sympos scheme in livepatch sysfs directory Chris J Arges
2015-11-23 9:47 ` Miroslav Benes
2015-12-02 2:40 ` [PATCH 0/3 v9] livepatch: disambiguate symbols with the same name Chris J Arges
2015-12-02 2:40 ` [PATCH 1/3 v9] livepatch: add old_sympos as disambiguator field to klp_func Chris J Arges
2015-12-02 2:40 ` [PATCH 2/3 v9] livepatch: add sympos as disambiguator field to klp_reloc Chris J Arges
2015-12-14 12:45 ` Miroslav Benes
2015-12-02 2:40 ` [PATCH 3/3 v9] livepatch: function,sympos scheme in livepatch sysfs directory Chris J Arges
2015-12-02 15:28 ` [PATCH 0/3 v9] livepatch: disambiguate symbols with the same name Petr Mladek
2015-12-03 17:59 ` Josh Poimboeuf
2015-12-03 22:04 ` Jiri Kosina
2015-11-03 14:58 ` [PATCH v2] livepatch: old_name.number scheme in livepatch sysfs directory Josh Poimboeuf
2015-11-03 16:09 ` Miroslav Benes
2015-11-03 16:50 ` Josh Poimboeuf
2015-11-03 20:42 ` Chris J Arges
2015-11-04 9:52 ` Miroslav Benes
2015-11-04 16:03 ` Josh Poimboeuf
2015-11-04 16:17 ` Chris J Arges
2015-11-05 15:18 ` Miroslav Benes
2015-11-05 15:56 ` Josh Poimboeuf
2015-11-05 16:07 ` Chris J Arges
2015-11-09 16:16 ` [PATCH v3] livepatch: old_name,number " Chris J Arges
2015-11-09 20:56 ` Josh Poimboeuf
2015-11-09 23:01 ` Chris J Arges
2015-11-10 4:54 ` Josh Poimboeuf
2015-11-10 8:49 ` Miroslav Benes
2015-11-10 13:40 ` Josh Poimboeuf
2015-11-10 9:02 ` Miroslav Benes
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151112194549.GK4038@treble.hsd1.ky.comcast.net \
--to=jpoimboe@redhat.com \
--cc=chris.j.arges@canonical.com \
--cc=jeyu@redhat.com \
--cc=jikos@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=live-patching@vger.kernel.org \
--cc=sjenning@redhat.com \
--cc=vojtech@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®