Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 24 Jun 2004 10:10:54 -0400 (EDT)
From:      Robert Watson <rwatson@FreeBSD.org>
To:        Jun Kuriyama <kuriyama@imgsrc.co.jp>
Cc:        Current <freebsd-current@FreeBSD.org>
Subject:   Re: malloc(M_WAITOK) of "32", forcing M_NOWAIT
Message-ID:  <Pine.NEB.3.96L.1040624100938.9644B-100000@fledge.watson.org>
In-Reply-To: <7m3c4lle3k.wl@black3.imgsrc.co.jp>

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

On Thu, 24 Jun 2004, Jun Kuriyama wrote:

> I don't know how to fix correctly.  But it has disappeared with
> following patch.  Grrr. 

I think this is not quite correct; you will need to unlock the nfsd_mtx
regardless of the state of RC_LOCKED, as that's a structure sleep lock and
nfsd_mtx should be locked at that point regardless of RC_LOCKED.  Assuming
this code was safe on 4.x and performed a blocking socket addr copy here,
it should also be safe on 5.x to drop nfsd_mtx here.

Robert N M Watson             FreeBSD Core Team, TrustedBSD Projects
robert@fledge.watson.org      Senior Research Scientist, McAfee Research


> 
> Index: nfs_srvcache.c
> ===================================================================
> RCS file: /home/ncvs/src/sys/nfsserver/nfs_srvcache.c,v
> retrieving revision 1.38
> diff -u -r1.38 nfs_srvcache.c
> --- nfs_srvcache.c	24 May 2004 04:06:14 -0000	1.38
> +++ nfs_srvcache.c	22 Jun 2004 06:28:12 -0000
> @@ -247,10 +247,19 @@
>  		break;
>  /*	case AF_INET6:	*/
>  /*	case AF_ISO:	*/
> -	default:
> +	default: {
> +		struct sockaddr *sa2;
>  		rp->rc_flag |= RC_NAM;
> -		rp->rc_nam = sodupsockaddr(nd->nd_nam, M_WAITOK);
> +		if (rp->rc_flag | RC_LOCKED) {
> +			NFSD_UNLOCK();
> +		}
> +		sa2 = sodupsockaddr(nd->nd_nam, M_WAITOK);
> +		if (rp->rc_flag | RC_LOCKED) {
> +			NFSD_LOCK();
> +		}
> +		rp->rc_nam = sa2;
>  		break;
> +	}
>  	};
>  	rp->rc_proc = nd->nd_procnum;
>  	LIST_INSERT_HEAD(NFSRCHASH(nd->nd_retxid), rp, rc_hash);
> 
> 
> -- 
> Jun Kuriyama <kuriyama@imgsrc.co.jp> // IMG SRC, Inc.
>              <kuriyama@FreeBSD.org> // FreeBSD Project
> _______________________________________________
> freebsd-current@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-current
> To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"
> 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.NEB.3.96L.1040624100938.9644B-100000>