kern/128304: vn_pollrecord() derefs NULL if v_addpollinfo() fails

Doug White dwhite at FreeBSD.org
Wed Oct 22 22:50:01 UTC 2008


>Number:         128304
>Category:       kern
>Synopsis:       vn_pollrecord() derefs NULL if v_addpollinfo() fails
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Oct 22 22:50:00 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     Doug White
>Release:        FreeBSD 7.0-RELEASE
>Organization:
Personal
>Environment:
FreeBSD mail1.sjc1.bitgravity.com 7.0-RELEASE-p4 FreeBSD 7.0-RELEASE-p4 #1: Mon Sep 29 18:30:06 PDT 2008     dwhite at mail1.sjc1.bitgravity.com:/usr/obj/usr/src/sys/BITGRAVITY  amd64

>Description:
The first few lines of vn_pollrecord() are:

	if (vp->v_pollinfo == NULL)
		v_addpollinfo(vp);
	mtx_lock(&vp->v_pollinfo->vpi_lock);

v_addpollinfo() leaves vp->v_pollinfo NULL if the malloc attempt fails. vfs_kqfilter() checks for failure, but this function does not.  If allocation were to fail then the mtx_lock() call would result in a null pointer dereference panic. 
>How-To-Repeat:
Problem was found by code inspection.
>Fix:
vn_pollrecord() should ensure v_addpollinfo() succeeds in allocating the pollinfo lists. However vn_pollrecord() uses its return value to convey the original event mask so there does not appear to be a method to return an error value (ENOMEM, etc.) in the current implementation.

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


More information about the freebsd-bugs mailing list