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

Doug White dwhite at
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
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Oct 22 22:50:00 UTC 2008
>Originator:     Doug White
>Release:        FreeBSD 7.0-RELEASE
FreeBSD 7.0-RELEASE-p4 FreeBSD 7.0-RELEASE-p4 #1: Mon Sep 29 18:30:06 PDT 2008     dwhite at  amd64

The first few lines of vn_pollrecord() are:

	if (vp->v_pollinfo == NULL)

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. 
Problem was found by code inspection.
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.


More information about the freebsd-bugs mailing list