From nobody Mon Feb 9 16:50:58 2026 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C973E2777EA for ; Fri, 23 Jan 2026 10:28:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769164127; cv=none; b=RWn3k+G6oNJ+pHVPmKtMKGcfPV8pqmHC3IWZv2oP812yfANHB59jqQs1GacC3JKypsrptW4ru5vcyNcwI94u6PYnDMGGMGfyfcWHVUlQfhRIImAbU82vpf1+5kO5EYJ+DYOmpc735rxUi5V0ytm209iFJCsu3SQ4LwC3vlcaY9g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769164127; c=relaxed/simple; bh=DtOADswTq9t7oM1NSkiyrF+jafF+Tp/877w6zEpUQhU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pdue8VDzeDylkOT9NsGT0JMjVTyAMqim1nGGgPEDfiHtMNC+c3XEgEki0dFzYS4R9CzaolH7cPlJjqVUhoRnKhjILUSZapvB9id5fl5xk0RXEefrQml2XcUn5Vgmz41ZqfjpgZ1ZrF1Hkbatk9TdbviVyINHthNaUxDmi0F6e5k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=fFcxQwta; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="fFcxQwta" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-47ee3a63300so23430635e9.2 for ; Fri, 23 Jan 2026 02:28:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1769164124; x=1769768924; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZxfRVP7W+3lq5s1e+n6bpoYt/Dv/ToAFRdoKHsTj1cI=; b=fFcxQwtaDCazpAceKn6XtsiQQztngTZvmNRaK0nF+1JeAPAatfdkhiNkOYR1RaE7M1 IlmkgeaXWIGP5X2YAyca3HUIiwVqwox7mnkNfJrH7sHAOlHsbMeP8EyJcGE3t8YgWjpQ R3WjtlkNCDpxhvMDZucoIP1hzikr/5KyjvfkfmJDUQW0Sky3LsFYq3Oq32qFLvPZrlLi iEpNA6YKjgt/RGMjPTMdvuSi2jEhHF34tpSHy/32LlgeijvjzgiqlIDLsvKrBGODY5j8 JPOjf9/qiV5Avbtx7snuiw9y3ayVG7ZBxzKRx4zcQIaN/pMaHOqucc5zBHRyxe85z0kJ QDzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769164124; x=1769768924; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=ZxfRVP7W+3lq5s1e+n6bpoYt/Dv/ToAFRdoKHsTj1cI=; b=pxZ/9OftLXMBzCsYD3MpXtGLe0RsSeZkhwf+YO54MNykRGhZP6rEYu3FNjXXii3C9O BvF7xqSbwhLS8loLTWE8zhtKUgrn+dT6hGL/Bjs7nu1AXn3MR83WpP94AnO/pV+rM0FJ 3MGmhvabNtXHwrrJlSZKe3wKuhB9zElphtXHMGOPujaamiQEblTji3BBeUbKPblmot2Z odpLsbP/VLq0Lwt38b0rGREOr9FgcgFcF/bGwICN6idNh4QPYCujVOY9WREG+PKn6JbS prRq33Q5PZVkfLmLEWPDm6qa6WyjzgqNevvTKUssM5bUWT80y30Y1MHHUDvAJLEZtLnz h2SQ== X-Forwarded-Encrypted: i=1; AJvYcCVYg9TXK0kvcgwdiRC8lFzhtxjR9gfGvjNWKF8bK74W7vuKbl+J3r+MTeynd6l+XNNqCCo+vQljAj9/apw=@vger.kernel.org X-Gm-Message-State: AOJu0YwGAyAnZkX1JAmc1Jv0JR9wBXHz1dy4J8pcE96jSiIxQ6MPY6mt FJbAjXqZ7EBcv31MVCTf6LRZTK+lEdEkZRc2RKw24l6zGu9LQFejAh+6jQYQkz/E2No= X-Gm-Gg: AZuq6aI6qbnXWTyJM/7Gum/XQdanz1ZUNrEagXdHew2MWTQOngIT0IBYnddRRu9uG/l xO7VlbqLIz/F8MJdcugoGLNkn2gp3DYPKhpww6ahCbsCxwc1QvoM6jW/5J6tpkPmOJKjEup356w IOTz9T5trL895G+l3ACISyjRAT69TUSqM5dS/i8asKPzYI6NCLPBo4tpfgrp1spTJFEGzz10rUx 497Kju8TtSMIOlmyZyqOxkaR/j+hLcz4YiP97MVIyjtHXlEGK52MQN7ruHh8s13Ryjx2jc9SwTX EPzKLV5ygBb1PLGmkpYEH+PlgiCd82ccqFc+/ZkHTpQiuTgAgBrIESdBndBCRLmSKuvEf/gSAHj aVV+8QQWjLUtplrX1z3FazBYjM4mcF5+A0lLJe6bFN2VhNOudqsW9TArvWfG5fgjP0lj2DFF60C 6ZIkXZih8rgVmSyVkNrXChRxB//5CzkOQ= X-Received: by 2002:a05:600c:6814:b0:477:54cd:200e with SMTP id 5b1f17b1804b1-4804c947d18mr42348725e9.1.1769164124202; Fri, 23 Jan 2026 02:28:44 -0800 (PST) Received: from zovi.suse.cz (109-81-1-107.rct.o2.cz. [109.81.1.107]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-480470474cbsm128920065e9.8.2026.01.23.02.28.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Jan 2026 02:28:43 -0800 (PST) From: Petr Pavlu To: Josh Poimboeuf , Jiri Kosina , Miroslav Benes , Petr Mladek , Joe Lawrence Cc: Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Peter Zijlstra , live-patching@vger.kernel.org, linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 2/2] livepatch: Free klp_{object,func}_ext data after initialization Date: Fri, 23 Jan 2026 11:26:57 +0100 Message-ID: <20260123102825.3521961-3-petr.pavlu@suse.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260123102825.3521961-1-petr.pavlu@suse.com> References: <20260123102825.3521961-1-petr.pavlu@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The klp_object_ext and klp_func_ext data, which are stored in the __klp_objects and __klp_funcs sections, respectively, are not needed after they are used to create the actual klp_object and klp_func instances. This operation is implemented by the init function in scripts/livepatch/init.c. Prefix the two sections with ".init" so they are freed after the module is initializated. Signed-off-by: Petr Pavlu Acked-by: Joe Lawrence --- scripts/livepatch/init.c | 2 +- scripts/module.lds.S | 4 ++-- tools/objtool/check.c | 2 +- tools/objtool/include/objtool/klp.h | 10 +++++----- tools/objtool/klp-diff.c | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/scripts/livepatch/init.c b/scripts/livepatch/init.c index 9e315fc857bd..638c95cffe76 100644 --- a/scripts/livepatch/init.c +++ b/scripts/livepatch/init.c @@ -19,7 +19,7 @@ static int __init livepatch_mod_init(void) unsigned int nr_objs; int ret; =20 - obj_exts =3D klp_find_section_by_name(THIS_MODULE, "__klp_objects", + obj_exts =3D klp_find_section_by_name(THIS_MODULE, ".init.klp_objects", &obj_exts_sec_size); nr_objs =3D obj_exts_sec_size / sizeof(*obj_exts); if (!nr_objs) { diff --git a/scripts/module.lds.S b/scripts/module.lds.S index 383d19beffb4..054ef99e8288 100644 --- a/scripts/module.lds.S +++ b/scripts/module.lds.S @@ -34,8 +34,8 @@ SECTIONS { =20 __patchable_function_entries : { *(__patchable_function_entries) } =20 - __klp_funcs 0: ALIGN(8) { KEEP(*(__klp_funcs)) } - __klp_objects 0: ALIGN(8) { KEEP(*(__klp_objects)) } + .init.klp_funcs 0 : ALIGN(8) { KEEP(*(.init.klp_funcs)) } + .init.klp_objects 0 : ALIGN(8) { KEEP(*(.init.klp_objects)) } =20 #ifdef CONFIG_ARCH_USES_CFI_TRAPS __kcfi_traps : { KEEP(*(.kcfi_traps)) } diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 3f7999317f4d..933868ee3beb 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -4761,7 +4761,7 @@ static int validate_ibt(struct objtool_file *file) !strcmp(sec->name, "__bug_table") || !strcmp(sec->name, "__ex_table") || !strcmp(sec->name, "__jump_table") || - !strcmp(sec->name, "__klp_funcs") || + !strcmp(sec->name, ".init.klp_funcs") || !strcmp(sec->name, "__mcount_loc") || !strcmp(sec->name, ".llvm.call-graph-profile") || !strcmp(sec->name, ".llvm_bb_addr_map") || diff --git a/tools/objtool/include/objtool/klp.h b/tools/objtool/include/ob= jtool/klp.h index ad830a7ce55b..e32e5e8bc631 100644 --- a/tools/objtool/include/objtool/klp.h +++ b/tools/objtool/include/objtool/klp.h @@ -6,12 +6,12 @@ #define SHN_LIVEPATCH 0xff20 =20 /* - * __klp_objects and __klp_funcs are created by klp diff and used by the p= atch - * module init code to build the klp_patch, klp_object and klp_func structs - * needed by the livepatch API. + * .init.klp_objects and .init.klp_funcs are created by klp diff and used = by the + * patch module init code to build the klp_patch, klp_object and klp_func + * structs needed by the livepatch API. */ -#define KLP_OBJECTS_SEC "__klp_objects" -#define KLP_FUNCS_SEC "__klp_funcs" +#define KLP_OBJECTS_SEC ".init.klp_objects" +#define KLP_FUNCS_SEC ".init.klp_funcs" =20 /* * __klp_relocs is an intermediate section which are created by klp diff a= nd diff --git a/tools/objtool/klp-diff.c b/tools/objtool/klp-diff.c index 4d1f9e9977eb..fd64d5e3c3b6 100644 --- a/tools/objtool/klp-diff.c +++ b/tools/objtool/klp-diff.c @@ -1439,7 +1439,7 @@ static int clone_special_sections(struct elfs *e) } =20 /* - * Create __klp_objects and __klp_funcs sections which are intermediate + * Create .init.klp_objects and .init.klp_funcs sections which are interme= diate * sections provided as input to the patch module's init code for building= the * klp_patch, klp_object and klp_func structs for the livepatch API. */ --=20 2.52.0