stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Michael Ellerman <mpe@ellerman.id.au>,
	"Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH 4.19 46/49] kexec_file: drop weak attribute from arch_kexec_apply_relocations[_add]
Date: Thu, 30 Jun 2022 15:46:59 +0200	[thread overview]
Message-ID: <20220630133235.230013083@linuxfoundation.org> (raw)
In-Reply-To: <20220630133233.910803744@linuxfoundation.org>

From: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>

commit 3e35142ef99fe6b4fe5d834ad43ee13cca10a2dc upstream.

Since commit d1bcae833b32f1 ("ELF: Don't generate unused section
symbols") [1], binutils (v2.36+) started dropping section symbols that
it thought were unused.  This isn't an issue in general, but with
kexec_file.c, gcc is placing kexec_arch_apply_relocations[_add] into a
separate .text.unlikely section and the section symbol ".text.unlikely"
is being dropped. Due to this, recordmcount is unable to find a non-weak
symbol in .text.unlikely to generate a relocation record against.

Address this by dropping the weak attribute from these functions.
Instead, follow the existing pattern of having architectures #define the
name of the function they want to override in their headers.

[1] https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=d1bcae833b32f1

[akpm@linux-foundation.org: arch/s390/include/asm/kexec.h needs linux/module.h]
Link: https://lkml.kernel.org/r/20220519091237.676736-1-naveen.n.rao@linux.vnet.ibm.com
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 arch/s390/include/asm/kexec.h |   10 +++++++++
 arch/x86/include/asm/kexec.h  |    9 ++++++++
 include/linux/kexec.h         |   46 ++++++++++++++++++++++++++++++++++--------
 kernel/kexec_file.c           |   34 -------------------------------
 4 files changed, 57 insertions(+), 42 deletions(-)

--- a/arch/s390/include/asm/kexec.h
+++ b/arch/s390/include/asm/kexec.h
@@ -9,6 +9,8 @@
 #ifndef _S390_KEXEC_H
 #define _S390_KEXEC_H
 
+#include <linux/module.h>
+
 #include <asm/processor.h>
 #include <asm/page.h>
 /*
@@ -69,4 +71,12 @@ int *kexec_file_update_kernel(struct kim
 extern const struct kexec_file_ops s390_kexec_image_ops;
 extern const struct kexec_file_ops s390_kexec_elf_ops;
 
+#ifdef CONFIG_KEXEC_FILE
+struct purgatory_info;
+int arch_kexec_apply_relocations_add(struct purgatory_info *pi,
+				     Elf_Shdr *section,
+				     const Elf_Shdr *relsec,
+				     const Elf_Shdr *symtab);
+#define arch_kexec_apply_relocations_add arch_kexec_apply_relocations_add
+#endif
 #endif /*_S390_KEXEC_H */
--- a/arch/x86/include/asm/kexec.h
+++ b/arch/x86/include/asm/kexec.h
@@ -21,6 +21,7 @@
 #ifndef __ASSEMBLY__
 
 #include <linux/string.h>
+#include <linux/module.h>
 
 #include <asm/page.h>
 #include <asm/ptrace.h>
@@ -217,6 +218,14 @@ extern int arch_kexec_post_alloc_pages(v
 extern void arch_kexec_pre_free_pages(void *vaddr, unsigned int pages);
 #define arch_kexec_pre_free_pages arch_kexec_pre_free_pages
 
+#ifdef CONFIG_KEXEC_FILE
+struct purgatory_info;
+int arch_kexec_apply_relocations_add(struct purgatory_info *pi,
+				     Elf_Shdr *section,
+				     const Elf_Shdr *relsec,
+				     const Elf_Shdr *symtab);
+#define arch_kexec_apply_relocations_add arch_kexec_apply_relocations_add
+#endif
 #endif
 
 typedef void crash_vmclear_fn(void);
--- a/include/linux/kexec.h
+++ b/include/linux/kexec.h
@@ -174,14 +174,6 @@ int kexec_purgatory_get_set_symbol(struc
 				   bool get_value);
 void *kexec_purgatory_get_symbol_addr(struct kimage *image, const char *name);
 
-int __weak arch_kexec_apply_relocations_add(struct purgatory_info *pi,
-					    Elf_Shdr *section,
-					    const Elf_Shdr *relsec,
-					    const Elf_Shdr *symtab);
-int __weak arch_kexec_apply_relocations(struct purgatory_info *pi,
-					Elf_Shdr *section,
-					const Elf_Shdr *relsec,
-					const Elf_Shdr *symtab);
 
 int __weak arch_kexec_walk_mem(struct kexec_buf *kbuf,
 			       int (*func)(struct resource *, void *));
@@ -206,6 +198,44 @@ extern int crash_exclude_mem_range(struc
 				   unsigned long long mend);
 extern int crash_prepare_elf64_headers(struct crash_mem *mem, int kernel_map,
 				       void **addr, unsigned long *sz);
+
+#ifndef arch_kexec_apply_relocations_add
+/*
+ * arch_kexec_apply_relocations_add - apply relocations of type RELA
+ * @pi:		Purgatory to be relocated.
+ * @section:	Section relocations applying to.
+ * @relsec:	Section containing RELAs.
+ * @symtab:	Corresponding symtab.
+ *
+ * Return: 0 on success, negative errno on error.
+ */
+static inline int
+arch_kexec_apply_relocations_add(struct purgatory_info *pi, Elf_Shdr *section,
+				 const Elf_Shdr *relsec, const Elf_Shdr *symtab)
+{
+	pr_err("RELA relocation unsupported.\n");
+	return -ENOEXEC;
+}
+#endif
+
+#ifndef arch_kexec_apply_relocations
+/*
+ * arch_kexec_apply_relocations - apply relocations of type REL
+ * @pi:		Purgatory to be relocated.
+ * @section:	Section relocations applying to.
+ * @relsec:	Section containing RELs.
+ * @symtab:	Corresponding symtab.
+ *
+ * Return: 0 on success, negative errno on error.
+ */
+static inline int
+arch_kexec_apply_relocations(struct purgatory_info *pi, Elf_Shdr *section,
+			     const Elf_Shdr *relsec, const Elf_Shdr *symtab)
+{
+	pr_err("REL relocation unsupported.\n");
+	return -ENOEXEC;
+}
+#endif
 #endif /* CONFIG_KEXEC_FILE */
 
 struct kimage {
--- a/kernel/kexec_file.c
+++ b/kernel/kexec_file.c
@@ -111,40 +111,6 @@ int __weak arch_kexec_kernel_verify_sig(
 #endif
 
 /*
- * arch_kexec_apply_relocations_add - apply relocations of type RELA
- * @pi:		Purgatory to be relocated.
- * @section:	Section relocations applying to.
- * @relsec:	Section containing RELAs.
- * @symtab:	Corresponding symtab.
- *
- * Return: 0 on success, negative errno on error.
- */
-int __weak
-arch_kexec_apply_relocations_add(struct purgatory_info *pi, Elf_Shdr *section,
-				 const Elf_Shdr *relsec, const Elf_Shdr *symtab)
-{
-	pr_err("RELA relocation unsupported.\n");
-	return -ENOEXEC;
-}
-
-/*
- * arch_kexec_apply_relocations - apply relocations of type REL
- * @pi:		Purgatory to be relocated.
- * @section:	Section relocations applying to.
- * @relsec:	Section containing RELs.
- * @symtab:	Corresponding symtab.
- *
- * Return: 0 on success, negative errno on error.
- */
-int __weak
-arch_kexec_apply_relocations(struct purgatory_info *pi, Elf_Shdr *section,
-			     const Elf_Shdr *relsec, const Elf_Shdr *symtab)
-{
-	pr_err("REL relocation unsupported.\n");
-	return -ENOEXEC;
-}
-
-/*
  * Free up memory used by kernel, initrd, and command line. This is temporary
  * memory allocation which is not needed any more after these buffers have
  * been loaded into separate segments and have been copied elsewhere.



  parent reply	other threads:[~2022-06-30 14:03 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-30 13:46 [PATCH 4.19 00/49] 4.19.250-rc1 review Greg Kroah-Hartman
2022-06-30 13:46 ` [PATCH 4.19 01/49] vt: drop old FONT ioctls Greg Kroah-Hartman
2022-06-30 13:46 ` [PATCH 4.19 02/49] random: schedule mix_interrupt_randomness() less often Greg Kroah-Hartman
2022-06-30 13:46 ` [PATCH 4.19 03/49] ALSA: hda/via: Fix missing beep setup Greg Kroah-Hartman
2022-06-30 13:46 ` [PATCH 4.19 04/49] ALSA: hda/conexant: " Greg Kroah-Hartman
2022-06-30 13:46 ` [PATCH 4.19 05/49] ALSA: hda/realtek: Add quirk for Clevo PD70PNT Greg Kroah-Hartman
2022-06-30 13:46 ` [PATCH 4.19 06/49] ata: libata: add qc->flags in ata_qc_complete_template tracepoint Greg Kroah-Hartman
2022-06-30 13:46 ` [PATCH 4.19 07/49] dm era: commit metadata in postsuspend after worker stops Greg Kroah-Hartman
2022-06-30 13:46 ` [PATCH 4.19 08/49] random: quiet urandom warning ratelimit suppression message Greg Kroah-Hartman
2022-06-30 13:46 ` [PATCH 4.19 09/49] USB: serial: option: add Telit LE910Cx 0x1250 composition Greg Kroah-Hartman
2022-06-30 13:46 ` [PATCH 4.19 10/49] USB: serial: option: add Quectel EM05-G modem Greg Kroah-Hartman
2022-06-30 13:46 ` [PATCH 4.19 11/49] USB: serial: option: add Quectel RM500K module support Greg Kroah-Hartman
2022-06-30 13:46 ` [PATCH 4.19 12/49] bonding: ARP monitor spams NETDEV_NOTIFY_PEERS notifiers Greg Kroah-Hartman
2022-06-30 13:46 ` [PATCH 4.19 13/49] net/sched: sch_netem: Fix arithmetic in netem_dump() for 32-bit platforms Greg Kroah-Hartman
2022-06-30 13:46 ` [PATCH 4.19 14/49] erspan: do not assume transport header is always set Greg Kroah-Hartman
2022-06-30 13:46 ` [PATCH 4.19 15/49] x86/xen: Remove undefined behavior in setup_features() Greg Kroah-Hartman
2022-06-30 13:46 ` [PATCH 4.19 16/49] MIPS: Remove repetitive increase irq_err_count Greg Kroah-Hartman
2022-06-30 13:46 ` [PATCH 4.19 17/49] afs: Fix dynamic root getattr Greg Kroah-Hartman
2022-06-30 13:46 ` [PATCH 4.19 18/49] igb: Make DMA faster when CPU is active on the PCIe link Greg Kroah-Hartman
2022-06-30 13:46 ` [PATCH 4.19 19/49] virtio_net: fix xdp_rxq_info bug after suspend/resume Greg Kroah-Hartman
2022-06-30 13:46 ` [PATCH 4.19 20/49] gpio: winbond: Fix error code in winbond_gpio_get() Greg Kroah-Hartman
2022-06-30 13:46 ` [PATCH 4.19 21/49] iio: adc: vf610: fix conversion mode sysfs node name Greg Kroah-Hartman
2022-06-30 13:46 ` [PATCH 4.19 22/49] xhci: turn off port power in shutdown Greg Kroah-Hartman
2022-06-30 13:46 ` [PATCH 4.19 23/49] usb: chipidea: udc: check request status before setting device address Greg Kroah-Hartman
2022-06-30 13:46 ` [PATCH 4.19 24/49] iio:chemical:ccs811: rearrange iio trigger get and register Greg Kroah-Hartman
2022-06-30 13:46 ` [PATCH 4.19 25/49] iio:accel:bma180: " Greg Kroah-Hartman
2022-06-30 13:46 ` [PATCH 4.19 26/49] iio: accel: mma8452: ignore the return value of reset operation Greg Kroah-Hartman
2022-06-30 13:46 ` [PATCH 4.19 27/49] iio: gyro: mpu3050: Fix the error handling in mpu3050_power_up() Greg Kroah-Hartman
2022-06-30 13:46 ` [PATCH 4.19 28/49] iio: trigger: sysfs: fix use-after-free on remove Greg Kroah-Hartman
2022-06-30 13:46 ` [PATCH 4.19 29/49] iio: adc: axp288: Override TS pin bias current for some models Greg Kroah-Hartman
2022-06-30 13:46 ` [PATCH 4.19 30/49] xtensa: xtfpga: Fix refcount leak bug in setup Greg Kroah-Hartman
2022-06-30 13:46 ` [PATCH 4.19 31/49] xtensa: Fix refcount leak bug in time.c Greg Kroah-Hartman
2022-06-30 13:46 ` [PATCH 4.19 32/49] powerpc: Enable execve syscall exit tracepoint Greg Kroah-Hartman
2022-06-30 13:46 ` [PATCH 4.19 33/49] powerpc/rtas: Allow ibm,platform-dump RTAS call with null buffer address Greg Kroah-Hartman
2022-06-30 13:46 ` [PATCH 4.19 34/49] powerpc/powernv: wire up rng during setup_arch Greg Kroah-Hartman
2022-06-30 13:46 ` [PATCH 4.19 35/49] ARM: dts: imx6qdl: correct PU regulator ramp delay Greg Kroah-Hartman
2022-06-30 13:46 ` [PATCH 4.19 36/49] ARM: exynos: Fix refcount leak in exynos_map_pmu Greg Kroah-Hartman
2022-06-30 13:46 ` [PATCH 4.19 37/49] soc: bcm: brcmstb: pm: pm-arm: Fix refcount leak in brcmstb_pm_probe Greg Kroah-Hartman
2022-06-30 13:46 ` [PATCH 4.19 38/49] ARM: Fix refcount leak in axxia_boot_secondary Greg Kroah-Hartman
2022-06-30 13:46 ` [PATCH 4.19 39/49] ARM: cns3xxx: Fix refcount leak in cns3xxx_init Greg Kroah-Hartman
2022-06-30 13:46 ` [PATCH 4.19 40/49] modpost: fix section mismatch check for exported init/exit sections Greg Kroah-Hartman
2022-06-30 13:46 ` [PATCH 4.19 41/49] kbuild: link vmlinux only once for CONFIG_TRIM_UNUSED_KSYMS (2nd attempt) Greg Kroah-Hartman
2022-06-30 13:46 ` [PATCH 4.19 42/49] powerpc/pseries: wire up rng during setup_arch() Greg Kroah-Hartman
2022-06-30 13:46 ` [PATCH 4.19 43/49] drm: remove drm_fb_helper_modinit Greg Kroah-Hartman
2022-06-30 13:46 ` [PATCH 4.19 44/49] xen: unexport __init-annotated xen_xlate_map_ballooned_pages() Greg Kroah-Hartman
2022-06-30 13:46 ` [PATCH 4.19 45/49] fdt: Update CRC check for rng-seed Greg Kroah-Hartman
2022-06-30 13:46 ` Greg Kroah-Hartman [this message]
2022-06-30 13:47 ` [PATCH 4.19 47/49] net: mscc: ocelot: allow unregistered IP multicast flooding Greg Kroah-Hartman
2022-06-30 13:47 ` [PATCH 4.19 48/49] net/sched: move NULL ptr check to qdisc_put() too Greg Kroah-Hartman
2022-06-30 13:47 ` [PATCH 4.19 49/49] swiotlb: skip swiotlb_bounce when orig_addr is zero Greg Kroah-Hartman
2022-06-30 17:09 ` [PATCH 4.19 00/49] 4.19.250-rc1 review Jon Hunter
2022-06-30 23:08 ` Shuah Khan
2022-07-01  0:56 ` Guenter Roeck
2022-07-01  7:42 ` Naresh Kamboju
2022-07-01 10:38 ` Sudip Mukherjee
2022-07-01 18:46 ` Pavel Machek

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=20220630133235.230013083@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=ebiederm@xmission.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpe@ellerman.id.au \
    --cc=naveen.n.rao@linux.vnet.ibm.com \
    --cc=stable@vger.kernel.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).