summaryrefslogtreecommitdiffstats
path: root/include/asm-generic/sections.h
diff options
context:
space:
mode:
authorAntoine Tenart <atenart@kernel.org>2021-11-22 15:24:56 +0100
committerDavid S. Miller <davem@davemloft.net>2021-11-22 15:53:45 +0100
commitcb902b332f9545635911063b671927defa5866bf (patch)
tree4574da77a58f6d22e3bad4d40c6ae7bbea2c5dcb /include/asm-generic/sections.h
parentarp: Remove #ifdef CONFIG_PROC_FS (diff)
downloadlinux-cb902b332f9545635911063b671927defa5866bf.tar.xz
linux-cb902b332f9545635911063b671927defa5866bf.zip
sections: global data can be in .bss
When checking an address is located in a global data section also check for the .bss section as global variables initialized to 0 can be in there (-fzero-initialized-in-bss). This was found when looking at ensure_safe_net_sysctl which was failing to detect non-init sysctl pointing to a global data section when the data was in the .bss section. Signed-off-by: Antoine Tenart <atenart@kernel.org> Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/asm-generic/sections.h')
-rw-r--r--include/asm-generic/sections.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h
index 1dfadb2e878d..76a0f16e56cf 100644
--- a/include/asm-generic/sections.h
+++ b/include/asm-generic/sections.h
@@ -130,18 +130,24 @@ static inline bool init_section_intersects(void *virt, size_t size)
/**
* is_kernel_core_data - checks if the pointer address is located in the
- * .data section
+ * .data or .bss section
*
* @addr: address to check
*
- * Returns: true if the address is located in .data, false otherwise.
+ * Returns: true if the address is located in .data or .bss, false otherwise.
* Note: On some archs it may return true for core RODATA, and false
* for others. But will always be true for core RW data.
*/
static inline bool is_kernel_core_data(unsigned long addr)
{
- return addr >= (unsigned long)_sdata &&
- addr < (unsigned long)_edata;
+ if (addr >= (unsigned long)_sdata && addr < (unsigned long)_edata)
+ return true;
+
+ if (addr >= (unsigned long)__bss_start &&
+ addr < (unsigned long)__bss_stop)
+ return true;
+
+ return false;
}
/**