From owner-freebsd-questions@FreeBSD.ORG Sat Jul 27 19:43:26 2013 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 7409E367 for ; Sat, 27 Jul 2013 19:43:26 +0000 (UTC) (envelope-from frank2@fjl.co.uk) Received: from bs1.fjl.org.uk (bs1.fjl.org.uk [84.45.41.196]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 24B8D225D for ; Sat, 27 Jul 2013 19:43:25 +0000 (UTC) Received: from [192.168.1.35] (mux.fjl.org.uk [62.3.120.246]) (authenticated bits=0) by bs1.fjl.org.uk (8.14.4/8.14.4) with ESMTP id r6RJhNFr079620 (version=TLSv1/SSLv3 cipher=DHE-DSS-CAMELLIA256-SHA bits=256 verify=NO) for ; Sat, 27 Jul 2013 20:43:24 +0100 (BST) (envelope-from frank2@fjl.co.uk) Message-ID: <51F422DB.2000205@fjl.co.uk> Date: Sat, 27 Jul 2013 20:43:23 +0100 From: Frank Leonhardt User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 MIME-Version: 1.0 To: freebsd-questions@freebsd.org Subject: Re: Delete a directory, crash the system References: <51F3F290.9020004@cordula.ws> <51F420ED.1050402@fjl.co.uk> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.14 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 27 Jul 2013 19:43:26 -0000 On 27/07/2013 20:38, David Noel wrote: >> I was going to raise an issue when the discussion had died down to a >> concensus. I also don't think it's reasonable for the kernel to bomb >> when it encounters corruption on a disk. >> >> If you want to patch it yourself, edit sys/ufs/ufs/ufs_vnops.c at around >> line 2791 change: >> >> if (dp->i_effnlink < 3) >> panic("ufs_dirrem: Bad link count %d on parent", >> dp->i_effnlink); >> >> To >> >> if (dp->i_effnlink < 3) { >> error = EINVAL; >> goto out; >> } >> >> The ufs_link() call has a similar issue. >> >> I can't see why my mod will break anything, but there's always >> unintended consequences. By returning invalid argument, any code above >> it should already be handling that condition although the user will be >> scratching their head wondering what's wrong with it. Returning ENOENT >> or EACCES or ENOTDIR may be better ("No such directory", "Access denied" >> or "Not a valid directory"). >> >> The trouble is that it's tricky to test properly without finding a good >> way to corrupt the link count :-) >> >> Regards, Frank. > Cool. Thanks for the patch! > Sorry - forgot to mention that you use it entirely at your own risk!