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  PHC 
Open Source and information security mailing list archives
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Sun, 12 Oct 2014 12:00:03 -0500
From:	Jeff Epler <>
To:	Chuck Ebbert <>
Cc:	"H. Peter Anvin" <>, Ingo Molnar <>,
	Thomas Gleixner <>,,
Subject: Re: [PATCH] x86: Clean up stack access code in irq_32.c

It looks like the proposed variant still miscompiles in clang 3.4 and 3.5, the
two versions I had handy to test.

I extracted your code to a simple standalone C translation unit and
inspected various compilers' results via objdump.

// cut here for cso.c
struct thread_info { long l[32]; }; // who knows

#define STACK_WARN (1024)
#define PAGE_SIZE (4096)

#define THREAD_SIZE_ORDER      2
#define THREAD_SIZE_MASK       (THREAD_SIZE - 1)
#define CURRENT_MASK           (~THREAD_SIZE_MASK)

/* how to get the current stack pointer from C */
#define current_stack_pointer ({               \
       register unsigned long sp asm("esp");   \
       sp;                                     \

int check_stack_overflow0(void)
       long sp;

       __asm__ __volatile__("andl %%esp,%0" :
                            "=r" (sp) : "0" (THREAD_SIZE - 1));

       return sp < (sizeof(struct thread_info) + STACK_WARN);

int check_stack_overflow1(void)
       return (current_stack_pointer & THREAD_SIZE_MASK)
              < sizeof(struct thread_info) + STACK_WARN;
// end cso.c

Typical compiler invocation:
        clang-3.5 -m32 -Os -c cso.c

Both clang-3.4 and clang-3.5 as packaged for debian jessie seem to get
check_stack_overflow1 wrong, yielding a function which always returns true:

    00000000 <check_stack_overflow1>:
       0:   b8 01 00 00 00          mov    $0x1,%eax
       5:   c3                      ret    

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

Powered by blists - more mailing lists