Skip to contentSkip to conversation

large stack variables (>=1K) in 2.4.4 and 2.4.4-ac8

CHECKER Mikael Pettersson 3 participants 4 messages May 24, 2001 – May 25, 2001

lore
Share & tools
lore
#0 lore raw
Quoted 10 lines · Dawson Engler

[BUG]
/u2/engler/mc/oses/linux/2.4.4-ac8/arch/i386/kernel/nmi.c:47:check_nmi_watchdog: ERROR:VAR:47:47: suspicious var 'tmp' = 1024 bytes:47 [nbytes=1024]
#define P6_EVENT_CPU_CLOCKS_NOT_HALTED 0x79
#define P6_NMI_EVENT P6_EVENT_CPU_CLOCKS_NOT_HALTED

int __init check_nmi_watchdog (void)
{

Error --->

	irq_cpustat_t tmp[NR_CPUS];

Nice work, but I think this is a false positive.

check_nmi_watchdog() is __init and we know exactly when it's called. The interesting cases (SMP kernel, since for UP NR_CPUS==1) are:

start_kernel -> smp_init -> smp_boot_cpus -> APIC_init_uniprocessor -> check_nmi_watchdog

and

start_kernel -> smp_init -> smp_boot_cpus -> setup_IO_APIC -> check_timer -> check_nmi_watchdog

In neither case is the stack large enough that the 1KB blob in check_nmi_watchdog should pose a problem, I think. (Don't we have something like 8KB-sizeof(struct task_struct) stack to play with?)

IMHO the checker tool should take call paths into consideration when trying to detect stack overflow problems. Does it do that? (I.e. is it polyvariant or monovariant?)

I could write a patch to make 'tmp' __initdata instead, which would silence the checker tool, but I don't really want to do that unless someone can convince me that there is a real problem here.

/Mikael

#1 lore raw
Quoted 2 lines

check_nmi_watchdog() is __init and we know exactly when it's called. The interesting cases (SMP kernel, since for UP NR_CPUS==1) are:

Ah, nice --- I keep meaning to tell the checker to demote its warning about NULL bugs or large stack vars in __init routines and/or routines that have the substring "init" in them ;-)

Quoted 3 lines

IMHO the checker tool should take call paths into consideration when trying to detect stack overflow problems. Does it do that? (I.e. is it polyvariant or monovariant?)

The var checker is more "really stupid". It just does a flow insensitive pass looking for big variables. I could make it follow call chains without too much work (other checkers do do this.)

Quoted 3 lines

I could write a patch to make 'tmp' __initdata instead, which would silence the checker tool, but I don't really want to do that unless someone can convince me that there is a real problem here.

No need. Once it's marked as an FP the checker won't warn about it anymore.

Thanks for post-mortem.

#2 lore raw
Quoted 6 lines · Dawson Engler
Quoted 2 lines

check_nmi_watchdog() is __init and we know exactly when it's called. The interesting cases (SMP kernel, since for UP NR_CPUS==1) are:

Ah, nice --- I keep meaning to tell the checker to demote its warning about NULL bugs or large stack vars in __init routines and/or routines that have the substring "init" in them ;-)

Please, don't. These functions are often used from/as init_module(), so they must handle the case when allocation fails. They can be called long after the boot.

#3 lore raw
Quoted 7 lines
Quoted 3 lines

Ah, nice --- I keep meaning to tell the checker to demote its warning about NULL bugs or large stack vars in __init routines and/or routines that have the substring "init" in them ;-)

Please, don't. These functions are often used from/as init_module(), so they must handle the case when allocation fails. They can be called long after the boot.

I meant "demote" to mean "reducing the ranking of these errors during sorting" rather than "eliminate from the error logs".