Date: Sat, 29 Dec 2007 13:44:50 -1000 (HST) From: Jeff Roberson <jroberson@chesapeake.net> To: arch@freebsd.org Subject: kvm_getfiles is badly broken Message-ID: <20071229133256.D957@desktop>
next in thread | raw e-mail | index | archive | help
>From kvm_getfiles(3): The number of files found is returned in the reference parameter cnt. The files are returned as a contiguous array of file structures, preceded by the address of the first file entry in the kernel. sysctl kern.file is used if the kernel is live. This code assumes the kernel copies out a struct filelist before any files. It does not. I can not find any consumers of this interface however. I also don't understand why it supplies the address of the first file and what this would be used for. There are other users of sysctl kern.file which assume it does not prepend this address so it would be wrong to change that. Would it also be wrong to change kvm to supply null as the first address? Other inconsistencies include live kernels returning strcut xfile and dead kernels returning struct file. The interface in kvm_getfiles() claims to return struct files. I can't imagine any code actually relies on this routine. Any opinions on what we should do with this? It has been broken since 2002 at least. I'm committing changes for my lockless struct file work. As part of that I'll commit a broken but compiling implementation that matches current bugs but causes the code to fail whenever it is called. Cheers, Jeff
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20071229133256.D957>