Commit cb902b33 authored by Antoine Tenart's avatar Antoine Tenart Committed by David S. Miller
Browse files

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: default avatarAntoine Tenart <atenart@kernel.org>
Acked-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
Acked-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e968b1b3
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -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;
}

/**