Re: [PATCH][2.6] WARN_ON_STACK_VAR aka fighting variable lifetime bugs

From: David Mosberger
Date: Mon Aug 11 2003 - 13:54:08 EST


>>>>> On Sat, 9 Aug 2003 15:29:41 -0400 (EDT), Zwane Mwaikambo <zwane@xxxxxxxxxxxxxxxx> said:

Zwane> --- linux-2.6.0-test2-irq/include/asm-ia64/bug.h 30 Jul 2003 00:06:30 -0000 1.1.1.1
Zwane> +++ linux-2.6.0-test2-irq/include/asm-ia64/bug.h 9 Aug 2003 19:14:09 -0000
Zwane> +#define WARN_ON_STACK_VAR(ptr) do { \
Zwane> + unsigned long __ti = (unsigned long)current_thread_info(); \
Zwane> + WARN_ON((__ti & (unsigned long)(ptr)) == __ti); \
Zwane> +} while (0)

Note that on ia64 we don't use bit-masking to calculate the
task-pointer. Instead, thread-info follows the task structure. This
is done such that the task-structure, thread-info, and kernel stack
can be mapped by a single (pinned) TLB entry.

The correct check for a variable being on the stack of the current
task would be something like this:

((unsigned long)(ptr) - (unsigned long) current) < IA64_STK_OFFSET

(IA64_STK_OFFSET is declared by <asm/ptrace.h>).

Thanks,

--david
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/