lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ZlBK_PZ2ZivCFXCv@kernel.org>
Date: Fri, 24 May 2024 11:08:28 +0300
From: Mike Rapoport <rppt@...nel.org>
To: Wei Yang <richard.weiyang@...il.com>
Cc: mpe@...erman.id.au, npiggin@...il.com, christophe.leroy@...roup.eu,
	aneesh.kumar@...nel.org, naveen.n.rao@...ux.ibm.com, arnd@...db.de,
	anshuman.khandual@....com, linuxppc-dev@...ts.ozlabs.org,
	linux-kernel@...r.kernel.org, linux-arch@...r.kernel.org,
	linux-mm@...ck.org
Subject: Re: [Patch v2] mm/memblock: discard .text/.data if
 CONFIG_ARCH_KEEP_MEMBLOCK not set

On Fri, May 24, 2024 at 01:46:56AM +0000, Wei Yang wrote:
> On Tue, May 21, 2024 at 10:21:52AM +0300, Mike Rapoport wrote:
> >Hi,
> >
> >On Fri, May 10, 2024 at 02:04:22AM +0000, Wei Yang wrote:
> >> When CONFIG_ARCH_KEEP_MEMBLOCK not set, we expect to discard related
> >> code and data. But it doesn't until CONFIG_MEMORY_HOTPLUG not set
> >> neither.
> >> 
> >> This patch puts memblock's .text/.data into its own section, so that it
> >> only depends on CONFIG_ARCH_KEEP_MEMBLOCK to discard related code and
> >> data.
> >> 
> >> After this, from the log message in mem_init_print_info(), init size
> >> increase from 2420K to 2432K on arch x86.
> >> 
> >> Signed-off-by: Wei Yang <richard.weiyang@...il.com>
> >> 
> >> ---
> >> v2: fix orphan section for powerpc
> >> ---
> >>  arch/powerpc/kernel/vmlinux.lds.S |  1 +
> >>  include/asm-generic/vmlinux.lds.h | 14 +++++++++++++-
> >>  include/linux/memblock.h          |  8 ++++----
> >>  3 files changed, 18 insertions(+), 5 deletions(-)
> >>  
> >> +#define __init_memblock        __section(".mbinit.text") __cold notrace \
> >> +						  __latent_entropy
> >> +#define __initdata_memblock    __section(".mbinit.data")
> >> +
> >
> >The new .mbinit.* sections should be added to scripts/mod/modpost.c
> >alongside .meminit.* sections and then I expect modpost to report a bunch
> >of section mismatches because many memblock functions are called on memory
> >hotplug even on architectures that don't select ARCH_KEEP_MEMBLOCK.
> >
> 
> I tried to add some code in modpost.c, "make all" looks good.
> 
> May I ask how can I trigger the "mismatch" warning?
> 
> BTW, if ARCH_KEEP_MEMBLOCK unset, we would discard memblock meta-data. If
> hotplug would call memblock function, it would be dangerous?
> 
> The additional code I used is like below.
> 
> ---
>  scripts/mod/modpost.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
> index 937294ff164f..c837e2882904 100644
> --- a/scripts/mod/modpost.c
> +++ b/scripts/mod/modpost.c
> @@ -777,14 +777,14 @@ static void check_section(const char *modname, struct elf_info *elf,
>  
>  #define ALL_INIT_DATA_SECTIONS \
>  	".init.setup", ".init.rodata", ".meminit.rodata", \
> -	".init.data", ".meminit.data"
> +	".init.data", ".meminit.data", "mbinit.data"

should be ".mbinit.data"
>  
>  #define ALL_PCI_INIT_SECTIONS	\
>  	".pci_fixup_early", ".pci_fixup_header", ".pci_fixup_final", \
>  	".pci_fixup_enable", ".pci_fixup_resume", \
>  	".pci_fixup_resume_early", ".pci_fixup_suspend"
>  
> -#define ALL_XXXINIT_SECTIONS ".meminit.*"
> +#define ALL_XXXINIT_SECTIONS ".meminit.*", "mbinit.*"

and ".mbinit.*"

But regardless of typos, when ARCH_KEEP_MEMBLOCK=n the .mbinit is equivalent
to .init and it should not be referenced from .meminit, so I don't think
adding it here is correct.

If I simply alias __init_memblock to __init then with
CONFIG_MEMORY_HOTPLUG=y I get

WARNING: modpost: vmlinux: section mismatch in reference: early_pfn_to_nid+0x42 (section: .meminit.text) -> memblock_search_pfn_nid (section: .init.text)
WARNING: modpost: vmlinux: section mismatch in reference: memmap_init_range+0x142 (section: .meminit.text) -> mirrored_kernelcore (section: .init.data)
WARNING: modpost: vmlinux: section mismatch in reference: memmap_init_range+0x1e1 (section: .meminit.text) -> memblock (section: .init.data)
WARNING: modpost: vmlinux: section mismatch in reference: memmap_init_range+0x1e8 (section: .meminit.text) -> memblock (section: .init.data)
WARNING: modpost: vmlinux: section mismatch in reference: sparse_buffer_alloc+0x3b (section: .meminit.text) -> memblock_free (section: .init.text)

>  #define ALL_INIT_SECTIONS INIT_SECTIONS, ALL_XXXINIT_SECTIONS
>  #define ALL_EXIT_SECTIONS ".exit.*"
> @@ -799,7 +799,7 @@ static void check_section(const char *modname, struct elf_info *elf,
>  
>  #define INIT_SECTIONS      ".init.*"
>  
> -#define ALL_TEXT_SECTIONS  ".init.text", ".meminit.text", ".exit.text", \
> +#define ALL_TEXT_SECTIONS  ".init.text", ".meminit.text", ".mbinit.text", ".exit.text", \
>  		TEXT_SECTIONS, OTHER_TEXT_SECTIONS
>  
>  enum mismatch {
> 
> -- 
> Wei Yang
> Help you, Help me
> 

-- 
Sincerely yours,
Mike.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ