From owner-svn-src-head@FreeBSD.ORG Fri May 15 19:23:06 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1D1FD1065673; Fri, 15 May 2009 19:23:06 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0C8308FC19; Fri, 15 May 2009 19:23:06 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4FJN5Vl032202; Fri, 15 May 2009 19:23:05 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4FJN50N032201; Fri, 15 May 2009 19:23:05 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <200905151923.n4FJN50N032201@svn.freebsd.org> From: Konstantin Belousov Date: Fri, 15 May 2009 19:23:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192151 - head/sys/fs/devfs X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 May 2009 19:23:06 -0000 Author: kib Date: Fri May 15 19:23:05 2009 New Revision: 192151 URL: http://svn.freebsd.org/changeset/base/192151 Log: Devfs replaces file ops vector with devfs-specific one in devfs_open(), before the struct file is fully initialized in vn_open(), in particular, fp->f_vnode is NULL. Other thread calling file operation before f_vnode is set results in NULL pointer dereference in devvn_refthread(). Initialize f_vnode before calling d_fdopen() cdevsw method, that might set file ops too. Reported and tested by: Chris Timmons (RELENG_7 version) MFC after: 3 days Modified: head/sys/fs/devfs/devfs_vnops.c Modified: head/sys/fs/devfs/devfs_vnops.c ============================================================================== --- head/sys/fs/devfs/devfs_vnops.c Fri May 15 19:19:27 2009 (r192150) +++ head/sys/fs/devfs/devfs_vnops.c Fri May 15 19:23:05 2009 (r192151) @@ -942,8 +942,10 @@ devfs_open(struct vop_open_args *ap) fpop = td->td_fpop; td->td_fpop = fp; - if (fp != NULL) + if (fp != NULL) { fp->f_data = dev; + fp->f_vnode = vp; + } if (dsw->d_fdopen != NULL) error = dsw->d_fdopen(dev, ap->a_mode, td, fp); else