From owner-freebsd-hackers@FreeBSD.ORG Wed Jan 19 04:25:22 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 22BAB106566C for ; Wed, 19 Jan 2011 04:25:22 +0000 (UTC) (envelope-from dillon@apollo.backplane.com) Received: from apollo.backplane.com (apollo.backplane.com [216.240.41.2]) by mx1.freebsd.org (Postfix) with ESMTP id E7A618FC1C for ; Wed, 19 Jan 2011 04:25:21 +0000 (UTC) Received: from apollo.backplane.com (localhost [127.0.0.1]) by apollo.backplane.com (8.14.4/8.14.1) with ESMTP id p0J4OmWX006801; Tue, 18 Jan 2011 20:24:48 -0800 (PST) Received: (from dillon@localhost) by apollo.backplane.com (8.14.4/8.13.4/Submit) id p0J4OkgW006798; Tue, 18 Jan 2011 20:24:46 -0800 (PST) Date: Tue, 18 Jan 2011 20:24:46 -0800 (PST) From: Matthew Dillon Message-Id: <201101190424.p0J4OkgW006798@apollo.backplane.com> To: Rick Macklem References: <334773590.270506.1295050163687.JavaMail.root@erie.cs.uoguelph.ca> Cc: freebsd-hackers@freebsd.org Subject: Re: NFS: file too large X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Jan 2011 04:25:22 -0000 :Well, since a server specifies the maximum file size it can :handle, it seems good form to check for that in the client. :(Although I'd agree that a server shouldn't crash if a read/write : that goes beyond that limit.) : :Also, as Matt notes, off_t is signed. As such, it looks to me like :the check could mess up if uio_offset it right near 0x7fffffffffffffff, :so that uio->ui_offset + uio->uio_resid ends up negative. I think the :check a little above that for uio_offset < 0 should also check :uio_offset + uio_resid < 0 to avoid this. : :rick Yes, though doing an overflow check in C, at least with newer versions of GCC, requires a separate comparison. The language has been mangled pretty badly over the years. if (a + b < a) -> can be optimized-out by the compiler if (a + b < 0) -> also can be optimized-out by the compiler x = a + b; if (x < a) -> this is ok (best method) x = a + b; if (x < 0) -> this is ok This sort of check may already be made in various places (e.g. by UFS and/or uio), since negative offsets are used to identify meta-data in UFS. -Matt Matthew Dillon