Re: malloc(M_WAITOK) of "32", forcing M_NOWAIT

From: Robert Watson <rwatson_at_FreeBSD.org>
Date: Thu, 24 Jun 2004 10:10:54 -0400 (EDT)
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_at_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
> _at__at_ -247,10 +247,19 _at__at_
>  		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_at_imgsrc.co.jp> // IMG SRC, Inc.
>              <kuriyama_at_FreeBSD.org> // FreeBSD Project
> _______________________________________________
> freebsd-current_at_freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-current
> To unsubscribe, send any mail to "freebsd-current-unsubscribe_at_freebsd.org"
> 
Received on Thu Jun 24 2004 - 12:11:46 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:58 UTC