Bug 795 - sysctl lets ordinary users lock up system
Summary: sysctl lets ordinary users lock up system
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: Unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 1995-10-28 01:50 UTC by gordon
Modified: 1995-10-28 08:53 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description gordon 1995-10-28 01:50:00 UTC
	Attempting to retrieve the sysctl() information from 
	kern.vnode locks up the system some of the time.
	The lock is probably on the vnode table (ps won't run), and 
	you cannot log in on another terminal/virtual console, 
	execute ps on any terminal/virtual console already logged 
	in, ^C or ^Z out of the program, or much of anything else.  
	Some UUCP conversations continue, but they may not last past 
	the point of needing to switch files.

Fix: 

This code section was derived from a piece of code intended
	to treewalk the MIB, uh, "filesystem", and find all the stuff
	sysctl -A misses, so I set it up to avoid this particular combination, 
	but I don't have a fix.  I also find it interesting that both EISDIR 
	and ENOTDIR indicate that the name I have chosen is not terminal and 
	I should lengthen it.

					Gordon L. Burditt
					sneaky.lerctr.org!gordon
How-To-Repeat: 
	
	Run the following program several times as an unprivileged user.  
	I always had it lock up the system within 3 tries, usually 1 or 2.  
	If it makes a difference, I always ran it from a syscons virtual
	console.  When it's locked up, you cannot interrupt the program 
	with ^C or ^Z, you cannot log in on another virtual terminal or 
	serial port (You never get the password: prompt), ps never 
	finishes, and to get anything useful done, you have to reboot.
	Don't run this program unless you are prepared to reboot.

/* sysctlcrash.c */
# include <stdio.h>
# include <errno.h>
# include <sys/param.h>
# include <sys/sysctl.h>

int main(int argc, char **argv)
{
	int	ret;
	int	mib[6];
	int	len;
	char	buffer[8192];

	mib[0] = CTL_KERN;
	mib[1] = KERN_VNODE;
	len = 8192;
	ret = sysctl(mib, 2, buffer, &len, NULL, 0);
	exit(0);
}
Comment 1 Bruce Evans freebsd_committer freebsd_triage 1995-10-28 08:50:25 UTC
State Changed
From-To: open->closed

Fixed in revision 1.36 of vfs_subr.c by cleaning up properly 
before the error returns.