freebsd kernel with SKQ
Go to file
Kenneth D. Merry 79d49a061b Probable fix for the "cdda2wav" panics that various people have been
reporting since this past summer.  (I think Daniel O'Conner was the first.)

The problem appears to have been something like this:

 - cdda2wav by default passes in a buffer that is close to the 128K MAXPHYS
   limit.
 - many times, the buffer is not page aligned
 - vmapbuf() truncates the address, so that it is page aligned
 - that causes the total size of the buffer to be greater than MAXPHYS,
   which of course is a bad thing.

Here's a quote from the PR (kern/9067):

==================
In particular, note bp->b_bufsize = 0x0001f950 and bp->b_data = 0xf2219960
(which does not start on a page boundary).  vunmapbuf() loops through all
the pages without any difficulty until addr reaches 0xf2239000, and then
the panic occurs.  This seems to indicate that we are exceeding MAXPHYS
since we actually started from the middle of a page (the data is being
transfered to a non page aligned location).

To complete the description, note that the system call originates from
ReadCddaMMC12() (in scsi_cmds.c of cdda2wav) with a request to read 55
audio sectors of 2352 bytes (which is calculated to fall under MAXPHYS).
This in turn ends up calling scsi_send() (in scsi-bsd.c) which calls
cam_fill_csio() and cam_send_ccb().  This results in a CAMIOCOMMAND ioctl
with a ccb function code of XPT_SCSI_IO.
==================

The fix is to change the size check in cam_periph_mapmem() so that it is
like the one in minphys().  In particular, it is something like:

if ((buffer_length + (buf_ptr & PAGE_MASK)) > MAXPHYS)
	buffer is too big

My fix is based on the one in the PR, but I cleaned up a fair number of
things in cam_periph_mapmem().  The checks for each buffer to be mapped
are now in a separate loop from the actual mapping operation.  With the new
arrangement, we don't have to bother with unmapping any previously mapped
buffers if one of the checks fails.

Many thanks to James Liu for tracking this down.  I'd appreciate it if some
vm-savvy folks would look this over.  I believe this fix is correct, but I
could be wrong.

PR:		kern/9067 (also, kern/8112)
Reviewed by:	gibbs
Submitted by:	"James T. Liu" <jtliu@phlebas.rockefeller.edu>
1998-12-16 18:00:39 +00:00
bin Cleaning out old stuff from one of my source trees: 1998-12-16 05:29:09 +00:00
contrib Old stuff laying around: Don't use getstr which can conflict with some 1998-12-16 06:06:06 +00:00
crypto Old stuff laying around: Don't use getstr which can conflict with some 1998-12-16 06:06:06 +00:00
etc Document securelevel 3. 1998-12-16 17:14:16 +00:00
games Fix typo (if it's not a typo, then it doesn't make sense IMHO) 1998-11-09 05:40:22 +00:00
gnu Add support for building on MIPS based systems. 1998-12-16 04:59:53 +00:00
include Make this protototype of mmap return void *, like two other copies. 1998-12-14 19:23:16 +00:00
kerberos5 While I am no longer making a shared library, nuke the old one to prevent 1998-08-30 13:08:54 +00:00
kerberosIV Add an explicit dependency on libcrypt so that shared library 1998-11-18 00:40:07 +00:00
lib Declare setproctitle() as printf0-like. 1998-12-16 17:52:15 +00:00
libexec As previously threatened, clean up the rshd -a option and make it default 1998-12-16 07:20:45 +00:00
lkm Install kld version (there can be only one) 1998-11-11 07:04:49 +00:00
release Update to note which specific brand of IDE drive does this. 1998-12-16 07:14:01 +00:00
sbin Mention affect of securelevel 3 and higher on attempts to change filter lists. 1998-12-16 17:10:03 +00:00
secure Remove useless `BINOWN=root' now that it is the default. 1998-09-19 22:42:14 +00:00
share Add portal example 1998-12-15 19:05:35 +00:00
sys Probable fix for the "cdda2wav" panics that various people have been 1998-12-16 18:00:39 +00:00
tools Add some emacs code to make cc-mode almost compatible to style(9). 1998-12-15 16:51:49 +00:00
usr.bin Free memory from setmode. 1998-12-16 04:51:27 +00:00
usr.sbin Make it possible to have separate install scripts as well as have 1998-12-16 13:59:31 +00:00
COPYRIGHT Add Id keyword 1998-09-13 23:11:13 +00:00
Makefile Restored all lost user targets that are supported by bsd.subdir.mk: 1998-10-17 15:25:26 +00:00
Makefile.inc0 Remove appending objformat to obj prefix for 1998-12-16 11:45:51 +00:00
Makefile.inc1 Grr. removed. backed-out. sorry! 1998-12-13 04:39:01 +00:00
Makefile.upgrade 3.0-RELEASE and now the post-release 3.0-CURRENT were being declared 1998-10-17 05:40:46 +00:00
README Correct the facts. The kerberosIV/ directory is not export restricted. 1998-09-13 09:38:34 +00:00
UPDATING This file contains minimal instructions for the moderately clueful to 1998-12-15 00:24:32 +00:00

This is the top level of the FreeBSD source directory.  This file
was last revised on: $Id: README,v 1.12 1998/06/30 08:08:05 jkh Exp $

For copyright information, please see the file COPYRIGHT in this
directory (additional copyright information also exists for some
sources in this tree - please see the specific source directories for
more information).

The Makefile in this directory supports a number of targets for
building components (or all) of the FreeBSD source tree, the most
commonly used one being ``world'', which rebuilds and installs
everything in the FreeBSD system from the source tree except the
kernel and the contents of /etc.  Please see the top of the Makefile
in this directory for more information on the standard build targets
and compile-time flags.

Building a kernel with config(8) is a somewhat more involved process,
documentation for which can be found at:
   http://www.freebsd.org/handbook/kernelconfig.html
And in the config(8) man page.

The sample kernel configuration files reside in the sys/i386/conf
sub-directory (assuming that you've installed the kernel sources), the
file named GENERIC being the one used to build your initial installation
kernel.  The file LINT contains entries for all possible devices, not
just those commonly used, and is meant more as a general reference
than an actual kernel configuration file (a kernel built from it
wouldn't even run).


Source Roadmap:
---------------
bin		System/User commands.

contrib		Packages contributed by 3rd parties.

crypto		Export controlled stuff (see crypto/README).

etc		Template files for /etc

games		Amusements.

gnu		Various commands and libraries under the GNU Public License.
		Please see gnu/COPYING* for more information.

include		System include files.

kerberosIV	Kerberos package.

lib		System libraries.

libexec		System daemons.

lkm		Loadable Kernel Modules.

release		Release building Makefile & associated tools.

sbin		System commands.

secure		DES and DES-related utilities - NOT FOR EXPORT!

share		Shared resources.

sys		Kernel sources.

tools		Utilities for regression testing and miscellaneous tasks.

usr.bin		User commands.

usr.sbin	System administration commands.


For information on synchronizing your source tree with one or more of
the FreeBSD Project's development branches, please see:

  http://www.freebsd.org/handbook/synching.html