Subject: Re: Walking an inpcb.inp_queue
To: None <tech-net@netbsd.org>
From: Manuel Bouyer <bouyer@antioche.lip6.fr>
List: tech-net
Date: 07/30/2001 21:35:18
On Sun, Jul 29, 2001 at 06:10:28PM -0400, Scott Barron wrote:
> Hello,
> 
> I am using kvm to access and then walk an inpcb.inp_queue (as netstat does)
> to get to various members of struct socket.  I am wondering if there is a
> danger of the kernel pulling one of the pointers out from under me (example:
> if another process got scheduled and closed down that socket while I held
> the pointer, etc).  I've minimized my accesses to inp_queue but am wondering
> if I need to be worried about this and if so, is there anyway I can prevent
> it?  (I wasn't sure wheather to post this to tech-net or tech-kern, please
> let me know if its better suited to tech-kern.)

Yes, you may have problems like this. But the kvm routines should be able to
fail gracefully this case, and if your program checks the return value this
should work well.

--
Manuel Bouyer <bouyer@antioche.eu.org>
--