From 6f9fb3945a17afac34f7d29ccadd96b595b91ab8 Mon Sep 17 00:00:00 2001 From: rwatson Date: Sun, 11 Jan 2004 01:29:03 +0000 Subject: Problem: When an NFS server is port-scanned nfsd sometimes exits. This has happened 3 times the last few weeks. Nfsd has been written to exit when accept(2) fails. Unfortunately accept can sometimes make a "normal" return with errno ECONNABORTED and in this case nfsd exits prematurely. Solution: Check for ECONNABORTED (and also EINTR, since nfsd uses signals) and continue. Submitted by: Bjoern Groenvall PR: 61084 --- usr.sbin/nfsd/nfsd.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'usr.sbin/nfsd/nfsd.c') diff --git a/usr.sbin/nfsd/nfsd.c b/usr.sbin/nfsd/nfsd.c index fcf53db..c8f3a42 100644 --- a/usr.sbin/nfsd/nfsd.c +++ b/usr.sbin/nfsd/nfsd.c @@ -658,6 +658,8 @@ main(argc, argv, envp) if (select(maxsock + 1, &ready, NULL, NULL, NULL) < 1) { syslog(LOG_ERR, "select failed: %m"); + if (errno == EINTR) + continue; nfsd_exit(1); } } @@ -668,6 +670,9 @@ main(argc, argv, envp) if ((msgsock = accept(tcpsock, (struct sockaddr *)&inetpeer, &len)) < 0) { syslog(LOG_ERR, "accept failed: %m"); + if (errno == ECONNABORTED || + errno == EINTR) + continue; nfsd_exit(1); } memset(inetpeer.sin_zero, 0, @@ -688,6 +693,9 @@ main(argc, argv, envp) &len)) < 0) { syslog(LOG_ERR, "accept failed: %m"); + if (errno == ECONNABORTED || + errno == EINTR) + continue; nfsd_exit(1); } if (setsockopt(msgsock, SOL_SOCKET, -- cgit v1.1