From owner-freebsd-bugs@FreeBSD.ORG Thu Jan 8 09:01:31 2004 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2B03F16A4CE for ; Thu, 8 Jan 2004 09:01:31 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id A7D8543D64 for ; Thu, 8 Jan 2004 09:00:32 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) i08H0WFR058658 for ; Thu, 8 Jan 2004 09:00:32 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.10/8.12.10/Submit) id i08H0WOT058657; Thu, 8 Jan 2004 09:00:32 -0800 (PST) (envelope-from gnats) Resent-Date: Thu, 8 Jan 2004 09:00:32 -0800 (PST) Resent-Message-Id: <200401081700.i08H0WOT058657@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Bjoern Groenvall Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3713016A4CE for ; Thu, 8 Jan 2004 08:57:54 -0800 (PST) Received: from manian.sics.se (manian.sics.se [193.10.66.13]) by mx1.FreeBSD.org (Postfix) with ESMTP id 18CF843D41 for ; Thu, 8 Jan 2004 08:57:51 -0800 (PST) (envelope-from bg@manian.sics.se) Received: from manian.sics.se (localhost [127.0.0.1]) by manian.sics.se (8.12.10/8.12.10) with ESMTP id i08Gvxet020047; Thu, 8 Jan 2004 17:57:59 +0100 (CET) (envelope-from bg@manian.sics.se) Received: (from bg@localhost) by manian.sics.se (8.12.10/8.12.10/Submit) id i08Gvx5t020046; Thu, 8 Jan 2004 17:57:59 +0100 (CET) (envelope-from bg) Message-Id: <200401081657.i08Gvx5t020046@manian.sics.se> Date: Thu, 8 Jan 2004 17:57:59 +0100 (CET) From: Bjoern Groenvall To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 cc: bg@sics.se Subject: bin/61084: nfsd sometimes exits prematurely during port-scan X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Bjoern Groenvall List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Jan 2004 17:01:31 -0000 >Number: 61084 >Category: bin >Synopsis: nfsd sometimes exits prematurely during port-scan >Confidential: no >Severity: critical >Priority: high >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Jan 08 09:00:32 PST 2004 >Closed-Date: >Last-Modified: >Originator: Bjoern Groenvall >Release: FreeBSD 5.2-RC i386 >Organization: SICS >Environment: System: FreeBSD dim.sics.se 5.2-RC FreeBSD 5.2-RC #1: Fri Dec 19 16:32:35 CET 2003 root@dim.sics.se:/usr/src/sys/i386/compile/DIM i386 >Description: 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 (see below). Dec 22 16:25:59 dim kernel: Limiting closed port RST response from 363 to 200 packets/sec Dec 22 16:25:59 dim nfsd[417]: accept failed: Software caused connection abort Dec 22 16:26:00 dim kernel: Limiting closed port RST response from 215 to 200 packets/sec Dec 28 08:26:43 dim kernel: Limiting closed port RST response from 325 to 200 packets/sec Dec 28 08:26:43 dim nfsd[36538]: accept failed: Software caused connection abort Dec 28 08:26:45 dim kernel: Limiting closed port RST response from 431 to 200 packets/sec Jan 7 00:37:12 dim kernel: Limiting closed port RST response from 305 to 200 packets/sec Jan 7 00:37:12 dim nfsd[89133]: accept failed: Software caused connection abort Jan 7 00:37:14 dim kernel: Limiting closed port RST response from 371 to 200 packets/sec >How-To-Repeat: Unknown. Perhaps possible using a port-scan program of some sort. >Fix: This is a sample fix that also handles rare "normal" returns with errno EINTR. --- nfsd.c.orig Thu Jul 25 08:18:22 2002 +++ nfsd.c Wed Jan 7 18:02:18 2004 @@ -658,6 +658,8 @@ 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 @@ 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 @@ &len)) < 0) { syslog(LOG_ERR, "accept failed: %m"); + if (errno == ECONNABORTED || + errno == EINTR) + continue; nfsd_exit(1); } if (setsockopt(msgsock, SOL_SOCKET, >Release-Note: >Audit-Trail: >Unformatted: