Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 25 Mar 2008 17:17:29 GMT
From:      Jari Kirma <kirma@cs.hut.fi>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   kern/122082: NULL pointer dereference in in_pcbdrop
Message-ID:  <200803251717.m2PHHT3E033225@www.freebsd.org>
Resent-Message-ID: <200803251720.m2PHK43D073119@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         122082
>Category:       kern
>Synopsis:       NULL pointer dereference in in_pcbdrop
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Mar 25 17:20:03 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     Jari Kirma
>Release:        7.0-STABLE
>Organization:
Helsinki University of Technology
>Environment:
FreeBSD kirma.fi 7.0-STABLE FreeBSD 7.0-STABLE #3: Fri Mar 14 12:01:00 EET 2008     root@example.com:/usr/obj/usr/src/sys/VULCAN  i386

>Description:
According to two kernel crash dumps, it dies on NULL pointer dereference on in_pcbdrop. Specifically this occurs on LIST_REMOVE below:

		if (LIST_FIRST(&phd->phd_pcblist) == NULL) {
			LIST_REMOVE(phd, phd_hash);
			free(phd, M_PCB);
		}

Even more specifically, this occurs on "(elm)->field.le_prev = LIST_NEXT((elm), field);" below:

#define LIST_REMOVE(elm, field) do {                                    \
        QMD_LIST_CHECK_NEXT(elm, field);                                \
        QMD_LIST_CHECK_PREV(elm, field);                                \
        if (LIST_NEXT((elm), field) != NULL)                            \
                LIST_NEXT((elm), field)->field.le_prev =                \
                    (elm)->field.le_prev;                               \
        *(elm)->field.le_prev = LIST_NEXT((elm), field);                \
        TRASHIT((elm)->field.le_next);                                  \
        TRASHIT((elm)->field.le_prev);                                  \
} while (0)

Obviously this occurs when phd->phd_hash->le_prev is NULL:

(kgdb) p *phd
$8 = {phd_hash = {le_next = 0x0, le_prev = 0x0}, phd_pcblist = {
    lh_first = 0x0}, phd_port = 0}

The backtrace is essentially the same for both "clean" crashes I've seen:

(kgdb) bt
#0  doadump () at pcpu.h:195
#1  0xc05536e1 in boot (howto=260) at /usr/src/sys/kern/kern_shutdown.c:409
#2  0xc05539b4 in panic (fmt=Variable "fmt" is not available.
) at /usr/src/sys/kern/kern_shutdown.c:563
#3  0xc0767cf4 in trap_fatal (frame=0xe7135ba4, eva=0)
    at /usr/src/sys/i386/i386/trap.c:899
#4  0xc0767f44 in trap_pfault (frame=0xe7135ba4, usermode=0, eva=0)
    at /usr/src/sys/i386/i386/trap.c:812
#5  0xc07688aa in trap (frame=0xe7135ba4) at /usr/src/sys/i386/i386/trap.c:490
#6  0xc075025b in calltrap () at /usr/src/sys/i386/i386/exception.s:139
#7  0xc0600027 in in_pcbdrop (inp=0xcd4db0b4)
    at /usr/src/sys/netinet/in_pcb.c:758
#8  0xc066b53e in tcp_twclose (tw=0xcd1c8514, reuse=0)
    at /usr/src/sys/netinet/tcp_timewait.c:477
#9  0xc066b74e in tcp_tw_2msl_scan (reuse=0)
    at /usr/src/sys/netinet/tcp_timewait.c:644
#10 0xc066a31c in tcp_slowtimo () at /usr/src/sys/netinet/tcp_timer.c:129
#11 0xc059c19b in pfslowtimo (arg=0x0) at /usr/src/sys/kern/uipc_domain.c:459
#12 0xc05650b1 in softclock (dummy=0x0) at /usr/src/sys/kern/kern_timeout.c:274
#13 0xc0537b22 in ithread_loop (arg=0xc6bae6a0)
    at /usr/src/sys/kern/kern_intr.c:1036
#14 0xc05349e1 in fork_exit (callout=0xc0537981 <ithread_loop>, 
    arg=0xc6bae6a0, frame=0xe7135d38) at /usr/src/sys/kern/kern_fork.c:781
#15 0xc07502d0 in fork_trampoline () at /usr/src/sys/i386/i386/exception.s:205

The system experiencing this problem is a quad-core Intel system with nvidia display adapter (and associated drivers).
>How-To-Repeat:
Seems to occur from time to time when using a web browser, probably when HTTP server closes a socket from the other end, since the crash seems to occur a moment after successfully loading a web page.
>Fix:


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200803251717.m2PHHT3E033225>