linux-api.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chris J Arges <chris.j.arges-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
To: live-patching-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: jeyu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
	Chris J Arges
	<chris.j.arges-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>,
	Josh Poimboeuf <jpoimboe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	Seth Jennings <sjenning-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	Jiri Kosina <jikos-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Vojtech Pavlik <vojtech-IBi9RG/b67k@public.gmane.org>,
	linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH] livepatch: old_name.number scheme in livepatch sysfs directory
Date: Mon,  2 Nov 2015 11:58:47 -0600	[thread overview]
Message-ID: <1446487137-8469-1-git-send-email-chris.j.arges@canonical.com> (raw)

The following directory structure will allow for cases when the same
function name exists in a single object.
	/sys/kernel/livepatch/<patch>/<object>/<function.number>

The number is incremented on each known initialized func kobj thus creating
unique names in this case.

An example of this issue is documented here:
	https://github.com/dynup/kpatch/issues/493

Signed-off-by: Chris J Arges <chris.j.arges-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
---
 Documentation/ABI/testing/sysfs-kernel-livepatch |  2 +-
 kernel/livepatch/core.c                          | 20 ++++++++++++++++++--
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/Documentation/ABI/testing/sysfs-kernel-livepatch b/Documentation/ABI/testing/sysfs-kernel-livepatch
index 5bf42a8..dcd36db 100644
--- a/Documentation/ABI/testing/sysfs-kernel-livepatch
+++ b/Documentation/ABI/testing/sysfs-kernel-livepatch
@@ -33,7 +33,7 @@ Description:
 		The object directory contains subdirectories for each function
 		that is patched within the object.
 
-What:		/sys/kernel/livepatch/<patch>/<object>/<function>
+What:		/sys/kernel/livepatch/<patch>/<object>/<function.number>
 Date:		Nov 2014
 KernelVersion:	3.19.0
 Contact:	live-patching-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c
index 6e53441..ecacf65 100644
--- a/kernel/livepatch/core.c
+++ b/kernel/livepatch/core.c
@@ -587,7 +587,7 @@ EXPORT_SYMBOL_GPL(klp_enable_patch);
  * /sys/kernel/livepatch/<patch>
  * /sys/kernel/livepatch/<patch>/enabled
  * /sys/kernel/livepatch/<patch>/<object>
- * /sys/kernel/livepatch/<patch>/<object>/<func>
+ * /sys/kernel/livepatch/<patch>/<object>/<func.number>
  */
 
 static ssize_t enabled_store(struct kobject *kobj, struct kobj_attribute *attr,
@@ -727,13 +727,29 @@ static void klp_free_patch(struct klp_patch *patch)
 	kobject_put(&patch->kobj);
 }
 
+static int klp_count_sysfs_funcs(struct klp_object *obj, const char *name)
+{
+	struct klp_func *func;
+	int n = 0;
+
+	/* count the times a function name occurs and is initialized */
+	klp_for_each_func(obj, func) {
+		if ((!strcmp(func->old_name, name) &&
+		    func->kobj.state_initialized))
+			n++;
+	}
+
+	return n;
+}
+
 static int klp_init_func(struct klp_object *obj, struct klp_func *func)
 {
 	INIT_LIST_HEAD(&func->stack_node);
 	func->state = KLP_DISABLED;
 
 	return kobject_init_and_add(&func->kobj, &klp_ktype_func,
-				    &obj->kobj, "%s", func->old_name);
+				    &obj->kobj, "%s.%d", func->old_name,
+				    klp_count_sysfs_funcs(obj, func->old_name));
 }
 
 /* parts of the initialization that is done only when the object is loaded */
-- 
1.9.1

             reply	other threads:[~2015-11-02 17:58 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-02 17:58 Chris J Arges [this message]
2015-11-02 19:15 ` livepatch: old_name.number scheme in livepatch sysfs directory Jessica Yu
     [not found] ` <1446487137-8469-1-git-send-email-chris.j.arges-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
2015-11-02 19:52   ` [PATCH] " Josh Poimboeuf
2015-11-02 20:16     ` Chris J Arges
2015-11-02 20:32       ` Josh Poimboeuf
     [not found]         ` <20151102203241.GF27488-8wJ5/zUtDR0XGNroddHbYwC/G2K4zDHf@public.gmane.org>
2015-11-02 22:59           ` [PATCH v2] " Chris J Arges
2015-11-03  9:50             ` Miroslav Benes
2015-11-03 15:03               ` Josh Poimboeuf
     [not found]             ` <1446505187-28970-1-git-send-email-chris.j.arges-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
2015-11-03 10:52               ` Miroslav Benes
     [not found]                 ` <alpine.LNX.2.00.1511031146070.6257-ztGlSCb7Y1iN3ZZ/Hiejyg@public.gmane.org>
2015-11-03 12:44                   ` Petr Mladek
     [not found]                     ` <20151103124440.GK2599-KsEp0d+Q8qECVLCxKZUutA@public.gmane.org>
2015-11-03 15:03                       ` Josh Poimboeuf
2015-11-03 19:57                       ` Jiri Kosina
     [not found]                         ` <alpine.LNX.2.00.1511032055570.22567-ztGlSCb7Y1iN3ZZ/Hiejyg@public.gmane.org>
2015-11-03 20:06                           ` Josh Poimboeuf
     [not found]                             ` <1447259366-7055-1-git-send-email-chris.j.arges@canonical.com>
2015-11-11 16:29                               ` [PATCH 3/3 v4] livepatch: old_name,number " Chris J Arges
     [not found]                                 ` <1447259366-7055-4-git-send-email-chris.j.arges-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
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 4/4 v5] livepatch: function,sympos " Chris J Arges
     [not found]                                 ` <1447431804-18786-1-git-send-email-chris.j.arges@canonical.com>
2015-11-13 16:23                                   ` [PATCH 3/3 v6] " Chris J Arges
     [not found]                                   ` <1447693391-10065-1-git-send-email-chris.j.arges@canonical.com>
2015-11-16 17:03                                     ` [PATCH 3/3 v7] " Chris J Arges
     [not found]                                     ` <1448040325-32498-1-git-send-email-chris.j.arges@canonical.com>
2015-11-20 17:25                                       ` [PATCH 3/3 v8] " Chris J Arges
2015-11-23  9:47                                         ` Miroslav Benes
     [not found]                                       ` <1449024076-16034-1-git-send-email-chris.j.arges@canonical.com>
2015-12-02  2:40                                         ` [PATCH 3/3 v9] " Chris J Arges
2015-11-03 14:58                 ` [PATCH v2] livepatch: old_name.number " Josh Poimboeuf
2015-11-03 16:09                   ` Miroslav Benes
2015-11-03 16:50                     ` Josh Poimboeuf
     [not found]                       ` <20151103165058.GM27488-8wJ5/zUtDR0XGNroddHbYwC/G2K4zDHf@public.gmane.org>
2015-11-03 20:42                         ` Chris J Arges
2015-11-04  9:52                         ` Miroslav Benes
2015-11-04 16:03                           ` Josh Poimboeuf
     [not found]                             ` <20151104160354.GA29899-8wJ5/zUtDR0XGNroddHbYwC/G2K4zDHf@public.gmane.org>
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
     [not found]                                 ` <20151105155656.GD28254-8wJ5/zUtDR0XGNroddHbYwC/G2K4zDHf@public.gmane.org>
2015-11-09 16:16                                   ` [PATCH v3] livepatch: old_name,number " Chris J Arges
2015-11-09 20:56                                     ` Josh Poimboeuf
     [not found]                                       ` <20151109205608.GC3914-8wJ5/zUtDR0XGNroddHbYwC/G2K4zDHf@public.gmane.org>
2015-11-09 23:01                                         ` Chris J Arges
2015-11-10  4:54                                           ` Josh Poimboeuf
2015-11-10  8:49                                             ` Miroslav Benes
     [not found]                                               ` <alpine.LNX.2.00.1511100944120.16914-ztGlSCb7Y1iN3ZZ/Hiejyg@public.gmane.org>
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=1446487137-8469-1-git-send-email-chris.j.arges@canonical.com \
    --to=chris.j.arges-z7wlfzj8ewms+fvcfc7uqw@public.gmane.org \
    --cc=jeyu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=jikos-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=jpoimboe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=live-patching-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=sjenning-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=vojtech-IBi9RG/b67k@public.gmane.org \
    /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;
as well as URLs for NNTP newsgroup(s).