kern/51583: [PATCH] allow to work with devices and sockets over nullfs

Dmitry Sivachenko mitya at demos.su
Tue Apr 29 06:30:05 PDT 2003


>Number:         51583
>Category:       kern
>Synopsis:       [PATCH] allow to work with devices and sockets over nullfs
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Apr 29 06:30:03 PDT 2003
>Closed-Date:
>Last-Modified:
>Originator:     Dmitry Sivachenko
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
>Environment:
System: FreeBSD tear.demos.su 5.0-CURRENT FreeBSD 5.0-CURRENT #0: Tue Apr 29 10:41:13 MSD 2003 mitya at tear.demos.su:/usr/src/sys/i386/compile/TEAR i386


This problem exists on both -STABLE and -CURRENT.

>Description:
1) The system may panic when accessing devices over nullfs:
mount_null(fs) /dev /mnt
dd if=/mnt/zero of=/tmp/t.dat

The system will panic.

2) It is impossible to work with unix sockets (PF_LOCAL) over nullfs:
To reproduce: start mysqld.  It creates socket /tmp/mysql.sock to 
communicate with local mysql client.
mount_null(fs) /tmp /mnt
Try to use this socket:
mysql -S /mnt/mysql.sock mysql

Connection to mysqld will fail.

>How-To-Repeat:
	
>Fix:
I am attaching patches for both -current and -stable.
I am not sure how correct they are, but they do work.

-STABLE:

--- null_subr.c.orig	Tue Apr 29 17:20:44 2003
+++ null_subr.c	Tue Apr 29 16:23:19 2003
@@ -177,6 +177,10 @@ null_node_alloc(mp, lowervp, vpp)
 	vp = *vpp;
 
 	vp->v_type = lowervp->v_type;
+	if (vp->v_type == VCHR || vp->v_type == VBLK)
+		addalias(vp, lowervp->v_un.vu_spec.vu_specinfo);
+	else
+		vp->v_un = lowervp->v_un;
 	lockinit(&xp->null_lock, PINOD, "nullnode", 0, LK_CANRECURSE);
 	xp->null_vnode = vp;
 	vp->v_data = xp;


-CURRENT:

--- null_subr.c	Tue Apr 29 17:18:30 2003
+++ null_subr.c.new	Tue Apr 29 17:11:37 2003
@@ -73,6 +73,7 @@ MALLOC_DEFINE(M_NULLFSNODE, "NULLFS node
 
 static struct vnode * null_hashget(struct vnode *);
 static struct vnode * null_hashins(struct null_node *);
+extern void	addalias(struct vnode *vp, dev_t nvp_rdev);
 
 /*
  * Initialise cache headers
@@ -224,6 +225,10 @@ null_nodeget(mp, lowervp, vpp)
 	xp->null_lowervp = lowervp;
 
 	vp->v_type = lowervp->v_type;
+	if (vp->v_type == VCHR || vp->v_type == VBLK)
+		addalias(vp, lowervp->v_un.vu_spec.vu_cdev);
+	else
+		vp->v_un = lowervp->v_un;
 	vp->v_data = xp;
 
 	/*
>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list