Re: Bug Report: Dereferencing a bad pointer

From: Richard B. Johnson (root@chaos.analogic.com)
Date: Fri Nov 09 2001 - 08:33:14 EST


On Thu, 8 Nov 2001, David Chandler wrote:

> I get a seg fault on both 2.2 and 2.4 kernels by running the following
> one-line C program:
> int main() { int k = (int *)0x0; }
>
> Debugging the offender,
> int main() { int k = (int *)0xc0000000; }
> is not very informative: single-stepping over the sole command just
> hangs, and you have to press Control-C to interrupt gdb, at which point
> you can single-step right into the same problem again.
>
> When the program hangs, 'top' says that the CPU is fully utilized and
> the system is spending 80% of its time in the kernel and 20% in the
> offending process.
>
> Have you not been able to duplicate it on a 2.4 kernel on x86? If not,
> please tell me which 2.4 kernel correctly seg faults.
>
>
> David Chandler
>

Linux 2.4.1 seg-faults fine. Here is a test program that does not
use 'C' or the C runtime library. An assembly language program
is generated by this script. The first run just exits to the
Operating System using the Linux system call via interrupt 0x80.
The second run reads whatever is at virtual offset address 0xc000000
then attempts to exit to the OS. It checks to see if a core file
was generated (to see if it seg-faulted).

Try this out. If it properly seg-faults, you may have a 'C' compiler
that has optimized your offending line right out of existence!

If it doesn't work, you have truly discovered some problem with the
kernel version that doesn't work.

Cheers,
Dick Johnson

Penguin : Linux version 2.4.1 on an i686 machine (799.53 BogoMips).

    I was going to compile a list of innovations that could be
    attributed to Microsoft. Once I realized that Ctrl-Alt-Del
    was handled in the BIOS, I found that there aren't any.

FILE=/tmp/grok

cat <<EOF >${FILE}.s
.section .text
.global _start
.type _start,@function

_start:
        movl \$0xc0000000, %ebx
# movl (%ebx), %eax
        movl \$1, %eax
        xorl %ebx,%ebx
        int \$0x80
EOF
as -o ${FILE}.o ${FILE}.s
ld -o ${FILE} ${FILE}.o
chmod +x ${FILE}
echo "This should execute fine"
rm -f core
${FILE}
if [ -f core ] ; then
   echo "Failed"
else
   echo "Okay"
fi
cat <<EOF >${FILE}.s
.section .text
.global _start
.type _start,@function

_start:
        movl \$0xc0000000, %ebx
        movl (%ebx), %eax
        movl \$1, %eax
        xorl %ebx,%ebx
        int \$0x80
EOF
as -o ${FILE}.o ${FILE}.s
ld -o ${FILE} ${FILE}.o
chmod +x ${FILE}
echo "This should seg-fault"
${FILE}
if [ -f core ] ; then
   echo "Okay"
else
   echo "Failed"
fi
rm -f core

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



This archive was generated by hypermail 2b29 : Thu Nov 15 2001 - 21:00:22 EST