From owner-cvs-all Sun Aug 22 9:25: 1 1999 Delivered-To: cvs-all@freebsd.org Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.26.10.9]) by hub.freebsd.org (Postfix) with ESMTP id CB4BB15518; Sun, 22 Aug 1999 09:24:00 -0700 (PDT) (envelope-from bde@godzilla.zeta.org.au) Received: (from bde@localhost) by godzilla.zeta.org.au (8.8.7/8.8.7) id CAA30375; Mon, 23 Aug 1999 02:21:56 +1000 Date: Mon, 23 Aug 1999 02:21:56 +1000 From: Bruce Evans Message-Id: <199908221621.CAA30375@godzilla.zeta.org.au> To: bde@zeta.org.au, phk@critter.freebsd.dk Subject: Re: cvs commit: src/sys/kern kern_physio.c Cc: cvs-all@FreeBSD.org, cvs-committers@FreeBSD.org, green@FreeBSD.org Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk >>btodb() probably shouldn't cast to daddr_t. This mainly prevents its >>use in code like the above. It is not a feature that it may prevent >>warnings about truncation when off_t's are assigned to daddr_t's. > >btodb() probably shouldn't be used for off_t... It seems to be used mostly to convert fs block sizes to "disk blocks". The places that use it for off_t's seem to mostly have the same bug that you fixed. There's one in vfs_aio.c, one in vinumio.c, and 3 in each of spec_vnops.c and devfs_vnops.c. Only he ones for getpages in the last to files have a bounds check, and it is verbose and broken (I forgot the sign bit in daddr_t and have been sitting on the fix for a year or 2) :-(. It is used with a long arg in a few places. Longs are the same as off_t's on alphas, so overflows can't be ruled out by compile-time checking. There don't seem to be enough checks for uio_offset < 0. Negative offsets may be set by lseek(), and I think they normally get passed to quite low level routines. ffs_read() handles them dubiously by interpreting them as large unsigned offsets and returning EFBIG. POSIX.1 seems to require disallowing bogus seeks so that read() and write() don't have to worry about bogus offsets (there is no documented error return for attempts to read from bogus offsets in POSIX. FreeBSD's read.2 documents EINVAL for attempts to read from negative offsets, but negative offsets may be non-bogus for some files, e.g., /dev/mem on a 64-bit system). Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message