Thread (5 messages) 5 messages, 2 authors, 2026-01-22

Re: [PATCH v2 1/2] livepatch: Fix having __klp_objects relics in non-livepatch modules

From: Petr Pavlu <petr.pavlu@suse.com>
Date: 2026-01-22 08:34:24
Also in: live-patching, lkml

On 1/21/26 10:04 PM, Josh Poimboeuf wrote:
On Wed, Jan 21, 2026 at 09:28:16AM +0100, Petr Pavlu wrote:
quoted
+void *klp_locate_section_objs(const struct module *mod, const char *name,
+			      size_t object_size, unsigned int *nr_objs)
+{
+	struct klp_modinfo *info = mod->klp_info;
+
+	for (int i = 1; i < info->hdr.e_shnum; i++) {
+		Elf_Shdr *shdr = &info->sechdrs[i];
+
+		if (strcmp(info->secstrings + shdr->sh_name, name))
+			continue;
+
+		*nr_objs = shdr->sh_size / object_size;
+		return (void *)shdr->sh_addr;
+	}
+
+	*nr_objs = 0;
+	return NULL;
+}
+EXPORT_SYMBOL_GPL(klp_locate_section_objs);
How about we make it even more generic with something like

void *klp_find_section_by_name(const struct module *mod, const char *name,
			       size_t *sec_size);

?

I think that would help the code read more clearly.
Ok, I'll update it.

-- 
Thanks,
Petr
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help