Text  |   XML   |   Visible Warnings:

pvm3.4.6 : pvm3.4.6 analysis 2 : Use After Free  at pvmd.c:2250

Categories: ALLOC.UAF CWE:416
Warning ID: 22034.28692
Procedure: netoutput
Trace: view
Modified: Thu Nov 26 11:27:24 2009   show details
 
Priority: None
State: None
Finding: None
Owner: None
  edit properties

Legend [ X ]
Warning Location
Contributes
Parse Error
Other Warning
Two or More Loop Iterations
On Execution Path
Comment
Macro
Preprocessor
Include
Keyword
Preprocessed Away

Source  |  Language: C Hide Legend     
ProblemLineSource
   /kat0/fletcher/SATE/2010/pvm3/src/pvmd.c
   Enter work
 1696 work() 
 1697 {
 1698         static int lastpinged = 0;      /* host that got last keepalive msg */ 
 1699 #ifdef FDSETNOTSTRUCT 
 1700         fd_set rfds, wfds;                      /* result of select */ 
 1701         /* fd_set efds; */ 
 1702 #else 
 1703         struct fd_set rfds, wfds;       /* result of select */ 
 1704         /* struct fd_set efds; */ 
 1705 #endif 
 1706         int nrdy;                                       /* number of fds ready after select */ 
   ...
 1718         double tbpl;                            /* time at beginning of probe loop */ 
 1719         double toutpl;                          /* timeout in the probe loop */ 
 1720         int timed_out;
 1721         extern double dclock();
 1722 #endif 
 1723 #endif 
 1724 #ifdef  SHMEM 
 1725         int someclosed; 
 1726 #endif 
 1727  
 1728         gettimeofday(&tnow, (struct timezone*)0);
 1729         if (pvmdebmask || myhostpart) {
 1730                 PVM_TIMET time_temp;
 1731                 pvmlogprintf("%s (%s) %s %s\n",
 1732                                 hosts->ht_hosts[hosts->ht_local]->hd_name,
 1733                                 inadport_decimal(&hosts->ht_hosts[hosts->ht_local]->hd_sad),   /* Buffer Overrun (ID: 22089.28936) */  /* Buffer Underrun (ID: 22088.28935) */
 1734                                 myarchname,
 1735                                 PVM_VER);
 1736                 pvmlogprintf("ready ");
 1737                 time_temp = (PVM_TIMET) tnow.tv_sec;
 1738                 pvmlogprintf(ctime(&time_temp));   /* Format String (ID: 22201.29376) */
 1739         }
 1740  
 1741         /*
 1742         * check for default plug-in modules (& start them)
 1743         * (only if pvmd, not for pvmd'...)
 1744         */ 
 1745  
 1746         if ( myhostpart ) {
 1747                 char *av[5];
 1748                 char *buf;
 1749                 char *cmd;
 1750                 int ac;
 1751                 int i;
 1752  
 1753                 for ( i=0 ; modulenames[i] ; i++ ) {
 1754                         cmd = getenv( modulenames[i] );
 1755                         if ( cmd != NULL )
 1756                         {
   ...
 1765                                 }
 1766                                 if (buf) PVM_FREE( buf );
 1767                         }
 1768                 }
 1769         }
 1770  
 1771         /*
 1772         * remind myself to start those pesky slave pvmds 
 1773         */ 
 1774  
 1775         if (addmesg) {
 1776                 struct pmsg *mp = addmesg;
 1777  
 1778                 addmesg = 0;
 1779                 sendmessage(mp);
 1780         }
 1781  
 1782         /*
 1783         * init bail (for PVMDSTARTUP) and ping times 
 1784         */ 
 1785  
 1786         pvmgetclock(&tnow);
 1787         tout.tv_sec = DDBAILTIME;
 1788         tout.tv_usec = 0;
 1789         TVXADDY(&tbail, &tnow, &tout);
 1790  
 1791         tout.tv_sec = DDPINGTIME;
 1792         tout.tv_usec = 0;
 1793         TVXADDY(&tping, &tnow, &tout);
 1794  
 1795         /* init select fd sets */ 
 1796  
 1797         wrk_fds_init();
 1798  
 1799         if (loclsock >= 0)
 1800                 wrk_fds_add(loclsock, 1);
 1801         wrk_fds_add(netsock, 1);
 1802  
 1803         for (; ; ) {
 1804  
 1805                 /*
 1806                 *       clean up after any tasks that we got SIGCHLDs for 
 1807                 */ 
 1808 #ifdef IMA_BEOSCYLD 
 1809                 reap(SIGCLD); 
 1810 #endif 
 1811                 while (rdead != wdead) {
 1812                         if (deads[rdead].dd_pid == pprime) {
 1813                                 int cc;
 1814 #ifdef SOCKLENISUINT 
 1815 #if defined(IMA_AIX4SP2) || defined(IMA_AIX5SP2) \
 1816                 || defined(IMA_AIX56K64) || defined(IMA_LINUXALPHA)
 1817                                 unsigned int oslen;
 1818 #else 
 1819                                 size_t oslen;
 1820 #endif 
 1821 #else 
 1822                                 int oslen;
 1823 #endif 
 1824                                 struct sockaddr_in osad;
 1825                                 struct timeval t;
 1826                                 char buf[DDFRAGHDR];
 1827  
 1828                                 hostfailentry(hosts->ht_hosts[0]);
true1829                                 clear_opq_of((int)(TIDPVMD | hosts->ht_hosts[0]->hd_hostpart));
 1830                                 pprime = 0;
 1831  
 1832                                 while (1) {
 1833                                         FD_ZERO(&rfds);
 1834                                         FD_SET(ppnetsock, &rfds);
 1835                                         t.tv_sec = 0;
 1836                                         t.tv_usec = 0;
 1837                                         cc = select(ppnetsock + 1,
 1838 #ifdef  FDSETISINT 
 1839                                                         (int *)&rfds, (int *)0, (int *)0, 
 1840 #else 
 1841                                                         (fd_set *)&rfds, (fd_set *)0, (fd_set *)0,
 1842 #endif 
 1843                                                         &t);
 1844                                         if (cc == 1) {
 1845                                                 oslen = sizeof(osad);
 1846                                                 recvfrom(ppnetsock, buf, sizeof(buf),
 1847                                                                 0, (struct sockaddr*)&osad, &oslen);
 1848  
 1849                                         } else if (cc != -1 || errno != EINTR)
 1850                                                 break;
 1851                                 }
 1852  
 1853                         } else {
 1854                                 if (tp = task_findpid(deads[rdead].dd_pid)) {
 1855  
 1856                 /* check for output one last time 
 1857                    XXX this could be cleaner by going through main select again 
 1858                    XXX before flushing the task */ 
 1859  
 1860                                         tp->t_status = deads[rdead].dd_es;
 1861                                         tp->t_utime = deads[rdead].dd_ut;
 1862                                         tp->t_stime = deads[rdead].dd_st;
 1863                                         while (tp->t_out >= 0) {
 1864  
 1865 #ifdef FDSETNOTSTRUCT 
 1866                                                 fd_set rfds;
 1867 #else 
 1868                                                 struct fd_set rfds; 
 1869 #endif 
 1870  
 1871                                                 FD_ZERO(&rfds);
 1872                                                 FD_SET(tp->t_out, &rfds);
 1873                                                 TVCLEAR(&tout);
 1874                                                 if (select(tp->t_out + 1,
 1875 #ifdef  FDSETISINT 
 1876                                                                 (int *)&rfds, (int *)0, (int *)0, 
 1877 #else 
 1878                                                                 (fd_set *)&rfds, (fd_set *)0, (fd_set *)0,
 1879 #endif 
 1880                                                                 &tout) == 1)
 1881                                                         loclstout(tp);
 1882  
 1883                                                 else 
 1884                                                         break;
 1885                                         }
 1886 #if defined(IMA_PGON) || defined(IMA_SP2MPI) || defined(IMA_AIX4SP2) \
 1887         || defined(IMA_AIX5SP2) || defined(IMA_BEOLIN) 
 1888                                         mpp_free(tp); 
 1889 #endif 
 1890                                         task_cleanup(tp);
 1891                                         task_free(tp);
 1892                                 }
 1893                         }
 1894                         if (++rdead >= ndead)
 1895                                 rdead = 0;
 1896                 }
 1897  
*opq->pk_tlink is freed1898                 netoutput();
     Enter work / netoutput
 2225   netoutput() 
 2226   {
 2227           struct timeval tnow, tx;
 2228           struct pkt *pp, *pp2;
 2229           struct hostd *hp;
 2230           char *cp;
 2231           int len;
 2232           int cc;
 2233           char dummy[DDFRAGHDR];
 2234    
 2235   /*
 2236           len = 0;
 2237           for (pp = opq->pk_tlink; pp != opq; pp = pp->pk_tlink)
 2238                   len++;
 2239           pvmlogprintf("netoutput() %d in opq\n", len);
 2240   */ 
 2241           if (opq->pk_tlink == opq)
 2242                   return 0;
 2243    
 2244           /*
 2245           * send any pkts whose time has come 
 2246           */ 
 2247    
 2248           pvmgetclock(&tnow);
 2249    
*opq->pk_tlink is freed2250           while ((pp = opq->pk_tlink) != opq && TVXLTY(&pp->pk_rtv, &tnow)) {     /* Use After Free */
     Exit work / netoutput
Preconditions
(*hosts->ht_hosts)->hd_txq >= 0
(*hosts->ht_hosts)->hd_vmid = 0
(*hosts->ht_hosts)->hd_arch != 0
opq->pk_tlink != opq
opq->pk_tlink->pk_link = 0
loclsock >= 0
myhostpart = 0
pvmdebmask = 0
rdead != 0
tnow.tv_usec >= 1000000
wdead = 0
Postconditions
opq->pk_tlink->pk_tlink' = 0
opq->pk_tlink->pk_trlink' = 0
*opq->pk_tlink' is freed
addmesg' = 0
strlen(&buf[0])' = 59
buf[59]' = 0
cc' = 0
errno' != 0
mp' = addmesg
pp' = opq->pk_tlink
pprime' = 0
rdead' = 0
t.tv_sec' = 0
t.tv_usec' = 0
tbail.tv_sec' = &$unknown_235786 + 301
tbail.tv_usec' = tnow.tv_usec - 1000000
tnow.tv_sec' = &$unknown_235786
tping.tv_sec' = &$unknown_235786 + 61
tping.tv_usec' = tnow.tv_usec - 1000000




Change Warning 22034.28692 : Use After Free

Priority:
State:
Finding:
Owner:
Note: