

DOVES Vulnerability V-00103
DOVES Project
Computer Security Laboratory
Department of Computer Science
University of California at Davis
Brief summary: The check for the maximum number of file descriptors allocated to a process is incorrect.
Detailed description: The semantics of the UNIX operating system require that file descriptors be allocated in increasing order, beginning with 0. Some kernels use this to simplify the check for the maximum number of open file descriptors. Call this limit RLIMIT_NOFILE. When the file descriptor RLIMIT_NOFILE-1 is assigned, the kernel concludes that the maximum number of file descriptors has been opened. (Note that in general, more than RLIMIT_NOFILE can be opened. The hard limit is different. But RLIMIT_NOFILE is intended to be the limit for a single process.)
The problem is that the dup2()(2) does not restrict the naming of file descriptors to be underRLIMIT_NOFILE . So, the following sequence of code opens a file descriptor that does not count in the number of open file descriptors that the kernel uses:
/* assume fd is an open file descriptor */
if (dup2(fd, RLIMIT_NOFILE+1) < 0)
        perror("dup2");
	return;
}
close(fd);Components: kernel
Operating system(s): Linux kernels 2.2,14 and pre 2.4;The attacker can open more file descriptors than the system specifications allow.
How to detect:
if (newfd >= NR_OPEN)you are vulnerable. (NR_OPEN is the hard limit described earlier.)
How to fix:
if (newfd >= current->rlim[RLIMIT_NOFILE].rlim_cur)This checks the new file descriptor against the process resource limit, not the hard limit.
Other information:
PA Classification:
RISOS Classification:
Davis Classification:
Attacks: See Doves exploit #104.
Who reported it: Olaf Kirch in Letter titled "circumvent RLIMIT_NOFILE" on Mon, 24 Jul 2000 16:50:03 +0200: reported the problem and gave an exploit; Linus Torvalds in response to Olaf's letter on Mon, 24 Jul 2000 18:57:39 PDT: suggested the fix
Send email to doves@cs.ucdavis.edu
Department of Computer Science
University of California at Davis
One Shields Ave.
Davis, CA 95616-8562
Dove images © 1999-2000 www.barrysclipart.com