From owner-freebsd-questions@FreeBSD.ORG Sat Jul 27 19:38:22 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 4E19E24C for ; Sat, 27 Jul 2013 19:38:22 +0000 (UTC) (envelope-from david.i.noel@gmail.com) Received: from mail-wi0-x230.google.com (mail-wi0-x230.google.com [IPv6:2a00:1450:400c:c05::230]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id D69052226 for ; Sat, 27 Jul 2013 19:38:21 +0000 (UTC) Received: by mail-wi0-f176.google.com with SMTP id hn3so1193261wib.9 for ; Sat, 27 Jul 2013 12:38:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=+kuE9z869EE7wneq4wZ354LXgeOFkxzWPFt1EPvA18k=; b=uNOH3CD3VGtVKAJL7t0OLbqwe40apeBNPYk5hXek536hcXYOjD0gf+pdS5RdCzo2qG 7KYR3jlsxhuYX3UWnLiM7vyKTwfIzDWwrvg6CmzH7U1Zei8JyExgm6l5t143i6H4lk/T 5AkdfxG4P9d5PNU3NHYOKxxYqgZ5UzZMzkuavjWIfelhEcADql0A5/9t+gCRJ32eVFVL XQCXuXuP3b4wqWgw9Pq3cdrfqrEpFxsg60H6kPL7MkpE7VQFMb1mWMvx80nrJu6JiJSb LsRibWzROGrn38E7L7G8W0ptTE2+OvxZ1uKVVZImzCYj4JkgmRaUeLOsW8rNf+/m0wJi MI/g== MIME-Version: 1.0 X-Received: by 10.180.77.164 with SMTP id t4mr185261wiw.58.1374953900152; Sat, 27 Jul 2013 12:38:20 -0700 (PDT) Received: by 10.216.180.138 with HTTP; Sat, 27 Jul 2013 12:38:20 -0700 (PDT) In-Reply-To: <51F420ED.1050402@fjl.co.uk> References: <51F3F290.9020004@cordula.ws> <51F420ED.1050402@fjl.co.uk> Date: Sat, 27 Jul 2013 14:38:20 -0500 Message-ID: Subject: Re: Delete a directory, crash the system From: David Noel To: Frank Leonhardt Content-Type: text/plain; charset=ISO-8859-1 Cc: freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: David.I.Noel@gmail.com List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 27 Jul 2013 19:38:22 -0000 > 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!