Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site sri-iu.UUCP Path: utzoo!linus!decvax!genrad!mit-eddie!godot!harvard!seismo!sri-iu!kashtan From: kashtan@sri-iu.UUCP (David L. Kashtan) Newsgroups: net.eunice Subject: RE: Reading the IP/TCP routing tables from memory Message-ID: <14@sri-iu.UUCP> Date: Wed, 21-Nov-84 03:20:30 EST Article-I.D.: sri-iu.14 Posted: Wed Nov 21 03:20:30 1984 Date-Received: Fri, 23-Nov-84 03:02:33 EST Organization: S.R.I. International, Menlo Park, CA Lines: 90 Under EUNICE, nlist() will indeed read the ETC:INET.STB symbol table. Since the network data structures in the kernel may contain sensitive information, they are specifically kept KERNEL-MODE access only. The following routines implement klseek()/klread() which act like lseek/read on /dev/kmem. David /* * /dev/kmem seek/read */ static char *current_addr = 0; /* Our current Seek address */ klseek(dummy,addr,whence) char *addr; { current_addr = addr; /* Just stash the desired address */ } static char *klread_buffer; /* User buffer to read into */ static int klread_size; /* User buffer size */ klread(dummy,buffer,size) char *buffer; { extern klread_krnl(); /* * Fill in arguments to the kernel mode code */ klread_buffer = buffer; klread_size = size; /* * Fetch the kernel data in kernel mode */ sys$cmkrnl(klread_krnl,0); /* * Return the given size (just to be consistent with read) */ return(size); } /* * This is executed in kernel mode * (since network data structures are protected from casual user access) */ static klread_krnl() { register char *cp,*cp1; register int i; cp1 = klread_buffer; cp = current_addr; i = klread_size; while(i > 0) { if (kl_prober(cp)) *cp1++ = *cp++; current_addr++; i--; } return; } static kl_prober(cp) { /* * Change our previous mode to KERNEL so that the probe * will check for kernel read access -- construct a new * PSL/PC on the stack and REI to it */ asm(" clrl -(sp)"); asm(" movab 1f,-(sp)"); asm(" rei"); /* * Now check for read access */ asm("1: prober $0,$4,*4(ap)"); asm(" bneq 2f"); asm(" clrl r0"); asm(" ret"); asm("2: movl $1,r0"); asm(" ret"); } -- David Kashtan, Artificial Intelligence Center, SRI International ARPA: Kashtan@SRI-IU or Kashtan@SRI-AI UUCP: {lbl-csam, sri-unix, cmcl2} !sri-iu!kashtan