summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2026-09-07 14:48:10 +0100
committerMark Brown <broonie@kernel.org>2026-09-07 14:48:10 +0100
commite36afd8662a261db3f8b7c94ba219b82f69548b8 (patch)
tree5152c1d163a172456c904b4477c7386d230919b4
parent2f21ac3310eb7da2551a3bacd9c04f2d769b1a49 (diff)
parent5d791d3396ca4c9e5fd9d20b49386c20d8179eb8 (diff)
downloadlinux-next-e36afd8662a261db3f8b7c94ba219b82f69548b8.tar.gz
linux-next-e36afd8662a261db3f8b7c94ba219b82f69548b8.zip
Merge branch 'for-next' of https://git.kernel.org/pub/scm/linux/kernel/git/livepatching/livepatching.git
-rw-r--r--include/linux/livepatch.h4
-rw-r--r--kernel/livepatch/core.c10
-rw-r--r--tools/testing/selftests/livepatch/functions.sh12
3 files changed, 23 insertions, 3 deletions
diff --git a/include/linux/livepatch.h b/include/linux/livepatch.h
index ba9e3988c07c..5f74f79c22b4 100644
--- a/include/linux/livepatch.h
+++ b/include/linux/livepatch.h
@@ -33,6 +33,7 @@
* @kobj: kobject for sysfs resources
* @node: list node for klp_object func_list
* @stack_node: list node for klp_ops func_stack list
+ * @obj: back pointer to the owning object
* @old_size: size of the old function
* @new_size: size of the new function
* @nop: temporary patch to use the original code again; dyn. allocated
@@ -72,6 +73,7 @@ struct klp_func {
struct kobject kobj;
struct list_head node;
struct list_head stack_node;
+ struct klp_object *obj;
unsigned long old_size, new_size;
bool nop;
bool patched;
@@ -86,6 +88,7 @@ struct klp_func {
* @kobj: kobject for sysfs resources
* @func_list: dynamic list of the function entries
* @node: list node for klp_patch obj_list
+ * @patch: back pointer to the owning patch
* @mod: kernel module associated with the patched object
* (NULL for vmlinux)
* @dynamic: temporary object for nop functions; dynamically allocated
@@ -101,6 +104,7 @@ struct klp_object {
struct kobject kobj;
struct list_head func_list;
struct list_head node;
+ struct klp_patch *patch;
struct module *mod;
bool dynamic;
bool patched;
diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c
index a240d1144e89..517fe427ff92 100644
--- a/kernel/livepatch/core.c
+++ b/kernel/livepatch/core.c
@@ -646,12 +646,15 @@ static const struct kobj_type klp_ktype_patch = {
static void klp_kobj_release_object(struct kobject *kobj)
{
+ struct klp_patch *patch;
struct klp_object *obj;
obj = container_of(kobj, struct klp_object, kobj);
+ patch = obj->patch;
if (obj->dynamic)
klp_free_object_dynamic(obj);
+ kobject_put(&patch->kobj);
}
static const struct kobj_type klp_ktype_object = {
@@ -662,12 +665,15 @@ static const struct kobj_type klp_ktype_object = {
static void klp_kobj_release_func(struct kobject *kobj)
{
+ struct klp_object *obj;
struct klp_func *func;
func = container_of(kobj, struct klp_func, kobj);
+ obj = func->obj;
if (func->nop)
klp_free_func_nop(func);
+ kobject_put(&obj->kobj);
}
static const struct kobj_type klp_ktype_func = {
@@ -943,7 +949,9 @@ static void klp_init_func_early(struct klp_object *obj,
struct klp_func *func)
{
kobject_init(&func->kobj, &klp_ktype_func);
+ kobject_get(&obj->kobj);
list_add_tail(&func->node, &obj->func_list);
+ func->obj = obj;
}
static void klp_init_object_early(struct klp_patch *patch,
@@ -951,7 +959,9 @@ static void klp_init_object_early(struct klp_patch *patch,
{
INIT_LIST_HEAD(&obj->func_list);
kobject_init(&obj->kobj, &klp_ktype_object);
+ kobject_get(&patch->kobj);
list_add_tail(&obj->node, &patch->obj_list);
+ obj->patch = patch;
}
static void klp_init_patch_early(struct klp_patch *patch)
diff --git a/tools/testing/selftests/livepatch/functions.sh b/tools/testing/selftests/livepatch/functions.sh
index a65b7b1ac8ad..429fce1f3143 100644
--- a/tools/testing/selftests/livepatch/functions.sh
+++ b/tools/testing/selftests/livepatch/functions.sh
@@ -320,9 +320,9 @@ function start_test {
# find new kernel messages since the test started.
local last_dmesg_msg="livepatch kselftest timestamp: $(date --rfc-3339=ns)"
log "$last_dmesg_msg"
- loop_until 'dmesg | grep -q "$last_dmesg_msg"' ||
+ loop_until 'dmesg -r | grep -q "$last_dmesg_msg"' ||
die "buffer busy? can't find canary dmesg message: $last_dmesg_msg"
- LAST_DMESG=$(dmesg | grep "$last_dmesg_msg")
+ LAST_DMESG=$(dmesg -r | grep "$last_dmesg_msg")
echo -n "TEST: $test ... "
log "===== TEST: $test ====="
@@ -335,12 +335,18 @@ function check_result {
local result
# Test results include any new dmesg entry since LAST_DMESG, then:
+ # - exclude debug messages except with "livepatch:" prefix
# - include lines matching keywords
# - exclude lines matching keywords
# - filter out dmesg timestamp prefixes
- result=$(dmesg | awk -v last_dmesg="$LAST_DMESG" 'p; $0 == last_dmesg { p=1 }' | \
+ # - exclude the delayed kobject release messages when CONFIG_DEBUG_KOBJECT_RELEASE is on
+ result=$(dmesg -r | \
+ awk -v last_dmesg="$LAST_DMESG" \
+ 'p { if ($0 !~ /^<7>/ || $0 ~ /livepatch:/) print; next } $0 == last_dmesg { p = 1 }' | \
grep -e 'livepatch:' -e 'test_klp' | \
grep -v '\(tainting\|taints\) kernel' | \
+ grep -v 'kobject: .*parent.*(delayed' | \
+ sed 's/^<[0-9]*>//' | \
sed 's/^\[[ 0-9.]*\] //' | \
sed 's/^\[[ ]*[CT][0-9]*\] //')