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
>Organization:
Biological Software and Databanks.
Institut Pasteur, Paris.
>Environment:
System: NetBSD lanfeust.sis.pasteur.fr 4.99.63 NetBSD 4.99.63 (LANFEUST_DEVEL) 
#1: Thu May 29 16:56:54 CEST 2008 
njoly%lanfeust.sis.pasteur.fr@localhost:/local/src/NetBSD/obj.amd64/sys/arch/amd64/compile/LANFEUST_DEVEL
 amd64
Architecture: x86_64
Machine: amd64
>Description:
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
^C^C^C^C
[NEVER RETURNS]

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

>How-To-Repeat:
compile and run the small testcase.
>Fix:
n/a



Home | Main Index | Thread Index | Old Index