NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/38790: accept(2) with incorrect descriptor leaves unkillable processes

>Number:         38790
>Category:       kern
>Synopsis:       accept(2) with incorrect descriptor leaves unkillable processes
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu May 29 17:15:00 +0000 2008
>Originator:     Nicolas Joly
>Release:        NetBSD 4.99.63
Biological Software and Databanks.
Institut Pasteur, Paris.
System: NetBSD 4.99.63 NetBSD 4.99.63 (LANFEUST_DEVEL) 
#1: Thu May 29 16:56:54 CEST 2008
Architecture: x86_64
Machine: amd64
I just noticed that programs that use accept(2) with an incorrect descriptor
will never return ... and can't be killed too. Here follow a small testcase,
which exhibit the problem.

njoly@lanfeust [emul/netbsd]> cat accept.c 
#include <sys/socket.h>

#include <err.h>
#include <fcntl.h>
#include <unistd.h>

int main() {
  int fd, res;

  fd = open("/dev/null", O_RDWR);
  if (fd == -1)
    err(1, "open failed");

  res = accept(fd, NULL, NULL);
  if (res == -1)
    err(1, "accept failed");

  res = close(fd);
  if (res == -1)
    err(1, "close failed");

  return 0; }
njoly@lanfeust [emul/netbsd]> make accept
cc -O2   -o accept accept.c 
njoly@lanfeust [emul/netbsd]> ./accept 
accept: accept failed: Socket operation on non-socket

njoly@lanfeust [emul/netbsd]> ps
22706 ttyp3- DWE  0:00.00 (accept)

compile and run the small testcase.

Home | Main Index | Thread Index | Old Index