*BSD News Article 15178


Return to BSD News archive

Xref: sserve comp.os.386bsd.bugs:570 comp.bugs.4bsd:1946
Newsgroups: comp.os.386bsd.bugs,comp.bugs.4bsd
Path: sserve!newshost.anu.edu.au!munnari.oz.au!news.Hawaii.Edu!ames!saimiri.primate.wisc.edu!zaphod.mps.ohio-state.edu!cs.utexas.edu!uunet!emba-news.uvm.edu!sadye.emba.uvm.edu!wollman
From: wollman@sadye.emba.uvm.edu (Garrett Wollman)
Subject: socreate() will call protocol's usrreq even if it is NULL
Message-ID: <1993Apr26.165813.172@uvm.edu>
Sender: news@uvm.edu
Organization: University of Vermont, EMBA Computer Facility
Date: Mon, 26 Apr 1993 16:58:13 GMT
Lines: 48

I found this while debugging IP multicast routing...  If a protocol
has a no pr_usrreq entry point specified, such as the EON does (and my
encapsulation protocol used to), a call such as:

	s = socket(PF_INET, SOCK_RAW, IPPROTO_ENCAP);

will result in socreate() calling through the null usrreq pointer,
thus crashing the system.  Here is a patch which causes socreate to
return EINVAL instead.  (EPROTONOSUPPORT might be a better choice, but
EINVAL was what came immediately to my head.)

*** uipc_socket.c~	Wed Mar 17 19:02:33 1993
--- uipc_socket.c	Mon Apr 26 12:49:39 1993
***************
*** 80,88 ****
  	if (p->p_ucred->cr_uid == 0)
  		so->so_state = SS_PRIV;
  	so->so_proto = prp;
! 	error =
! 	    (*prp->pr_usrreq)(so, PRU_ATTACH,
! 		(struct mbuf *)0, (struct mbuf *)proto, (struct mbuf *)0);
  	if (error) {
  		so->so_state |= SS_NOFDREF;
  		sofree(so);
--- 80,94 ----
  	if (p->p_ucred->cr_uid == 0)
  		so->so_state = SS_PRIV;
  	so->so_proto = prp;
! 
! 	if(prp->pr_usrreq) {
! 	  error =
! 	    (*prp->pr_usrreq)(so, PRU_ATTACH, (struct mbuf *)0,
! 			      (struct mbuf *)proto, (struct mbuf *)0);
! 	} else {
! 	  error = EINVAL;
! 	}
! 
  	if (error) {
  		so->so_state |= SS_NOFDREF;
  		sofree(so);

-GAWollman

-- 
Garrett A. Wollman   | Shashish is simple, it's discreet, it's brief. ... 
wollman@emba.uvm.edu | Shashish is the bonding of hearts in spite of distance.
uvm-gen!wollman      | It is a bond more powerful than absence.  We like people
UVM disagrees.       | who like Shashish.  - Claude McKenzie + Florent Vollant