[236] in The Cryptographic File System users list

home help back first fref pref prev next nref lref last post

Serious bug in cfs (1.4.1 and earlier)

daemon@ATHENA.MIT.EDU (Martin Forssen)
Sat Aug 11 16:45:13 2001

From owner-cfs-users@crypto.com Sat Aug 11 20:45:13 2001
Return-Path: <owner-cfs-users@crypto.com>
Delivered-To: cfs-mtg@CHARON.mit.edu
Received: (qmail 24388 invoked from network); 11 Aug 2001 20:45:12 -0000
Received: from mx.crypto.com (207.140.168.138)
  by charon.mit.edu with SMTP; 11 Aug 2001 20:45:12 -0000
Received: (from majordomo@localhost)
	by MultiHostMXServer (8.9.3/8.9.x4) id QAA02103
	for cfs-users-list; Sat, 11 Aug 2001 16:29:55 -0400 (EDT)
X-Authentication-Warning: mx.crypto.com: majordomo set sender to owner-cfs-users@crypto.com using -f
Received: from nsa.research.att.com (H-135-207-24-155.research.att.com [135.207.24.155])
	by MultiHostMXServer (8.9.3/8.9.x4) with ESMTP id QAA04095
	for <cfs-users@crypto.com>; Sat, 11 Aug 2001 16:29:53 -0400 (EDT)
Received: from mail-blue.research.att.com (mail-blue.research.att.com [135.207.30.102]) by nsa.research.att.com (8.7.3/8.7.3) with ESMTP id QAA27056 for <cfs-users@nsa.research.att.com>; Sat, 11 Aug 2001 16:29:52 -0400 (EDT)
Received: by mail-blue.research.att.com (Postfix)
	id 99C2B4CE1F; Sat, 11 Aug 2001 16:29:52 -0400 (EDT)
Delivered-To: cfs-users@research.att.com
Received: from tkrat.org (tkrat.math.chalmers.se [129.16.168.189])
	by mail-blue.research.att.com (Postfix) with ESMTP id 5AEAE4CE09
	for <cfs-users@research.att.com>; Sat, 11 Aug 2001 16:29:52 -0400 (EDT)
Received: from tkrat.org (localhost [127.0.0.1])
	by tkrat.org (Postfix) with ESMTP id 500213F5B6
	for <cfs-users@research.att.com>; Sat, 11 Aug 2001 22:30:28 +0200 (MEST)
Date: Sat, 11 Aug 2001 22:29:46 +0200 (MEST)
From: Martin Forssen <maf@tkrat.org>
Subject: Serious bug in cfs (1.4.1 and earlier)
To: cfs-users@research.att.com
MIME-Version: 1.0
Content-Type: MULTIPART/mixed; BOUNDARY="397199618-1804289383-997561792=:32655"
Content-Transfer-Encoding: BINARY
Message-Id: <20010811203028.500213F5B6@tkrat.org>
Sender: owner-cfs-users@crypto.com
Precedence: bulk

--397199618-1804289383-997561792=:32655
Content-Type: TEXT/plain; charset=us-ascii

Hello,

I have found what I consider a relatively serious bug in cfs. This
applies to version 1.4.1 (the latest I could find) as well as earlier
versions (at least 1.3.3).

The bug is that under some circumstances cfsd looses small appends (<8
bytes) to files (should happen 12% of the times). This results in
corrupted files.

The problem is that the way files are padded may actually require that
the file is truncated when new data is written to it. And currently
there is no code for doing that. The attached patch fixes this.

	/MaF

--397199618-1804289383-997561792=:32655
Content-Type: TEXT/plain; name="cfs_fh.c-patch"
Content-Disposition: attachment; filename="cfs_fh.c-patch"

--- cfs_fh.c.old	Sat Aug 11 20:03:26 2001
+++ cfs_fh.c	Sat Aug 11 20:03:06 2001
@@ -180,6 +180,13 @@
 		perror("write");
 		return -1;
 	}
+	/* due to the way the file is padded we may actually have to
+	   truncate it here. This happens when the write is at the end of
+	   the file, is shorter than CFSBLOCK and brings the file to a length
+	   which is evenly dividable by CFSBLOCK */
+	if (offset+len > dtov(sb.st_size) && vtod(offset+len) < sb.st_size) {
+	    ftruncate(fd, vtod(offset+len));
+	}
 	/* iolen may contain CFSBLOCK extra chars */
 	return(dtov(iolen)-fronterr);
 }

--397199618-1804289383-997561792=:32655--

home help back first fref pref prev next nref lref last post