Commit graph

2083 commits

Author SHA1 Message Date
Bruce Evans 4c56fcdead Removed the cast to a pointer in the definition of PS_STRINGS and
adjusted related casts to match (only in the kernel in this commit).
The pointer was only wanted in one place in kern_exec.c.  Applications
should use the kern.ps_strings sysctl instead of PS_STRINGS, so they
shouldn't notice this change.
1998-12-16 16:28:58 +00:00
Bruce Evans 2caecceeb5 Removed all traces of SYSCTL_INTPTR(). Pointers can't really be passed
across the kernel -> application interface, and for the one sysctl where
they were passed and actually used (kern.ps_strings), the applications
want addresses represented as u_longs anyway (the other sysctl that
passed them, kern.usrstack, has never been used).

Agreed to by:	dfr, phk
1998-12-16 16:06:29 +00:00
Bruce Evans 4f2129fa86 Removed bogus casts of USRSTACK and/or the other operand in binary
expressions involving USRSTACK.
1998-12-16 15:21:51 +00:00
Dag-Erling Smørgrav e3b3ba2d79 Wrap two macros into do { ... } while (0), and fix the way they're used
in the kernel.

Reviewed by: bde
1998-12-15 17:38:33 +00:00
Matthew Dillon fe523aa107 fix intermediate overflow in 'quad = int * int' situation by casting
the arguments to the multiply to a quad equivalent.  In this case,
    vm_ooffset_t.

Reviewed by:	Archie Cobbs <archie@whistle.com>
1998-12-14 21:17:37 +00:00
Matthew Dillon 3ea57f9da2 Fixed problems with kernel config file overrides of sysv semaphore
parameters.  Prior to this fix a kernel config override would effect
only some of the kernel files, resulting in panics.

PR:	kern/9068
1998-12-14 08:34:55 +00:00
Matthew Dillon f7bb75c92a Fix -Wuninitialized warning regarding zero-length var-args ctl element.
( this isn't really an error, but I think it is important to fix the
    warning ).
1998-12-14 05:37:37 +00:00
Don Lewis 2b648ac0a1 Add a generic flag, CTLFLAG_SECURE, which can be used to mark a sysctl
variable unwriteable when securelevel > 0.
Reviewed by: jdp, eivind
1998-12-13 07:19:13 +00:00
Don Lewis 65de0c7a93 getpgid() and getsid() were doing a comparision rather than an assignment,
which is fortunate, because otherwise another bug would allow them to be
used to stomp on the syscall return value of another process.
1998-12-13 07:07:51 +00:00
Matthew Dillon 4c01697599 PR: kern/8965
Obtained from: Stephen Clawson <sclawson@cs.utah.edu>

    Wakeup anyone waiting on a mount point prior to returning from umount,
    whether an error occurs or not.  Fixes a stat/NFS-umount race and other
    potential future problems.  Fix taken from bug/pr which also indicated
    that the same fix has already been applied to OpenBSD and NetBSD.
1998-12-12 21:07:09 +00:00
Nick Hibma b3f65f42c0 When no driver was found for a device, the message 'not probed' appeared
This is odd, especially in the case of USB where the driver is found
in several tries: vendor specific, class specific, interface specific.
The mouse driver is found at the interface specific level...
Reviewed by:	Doug Rabson (dfr@freebsd.org)
1998-12-12 11:30:04 +00:00
Eivind Eklund 2ae353f9a7 Rename one of the two devfs_link's to devfs_makelink. 1998-12-10 19:57:01 +00:00
Jordan K. Hubbard 337c96916f poll(2) sets POLLNVAL for descriptors passed in that are less than
0.  This makes it difficult to do efficient manipulation of the
struct pollfd since you can't leave a slot empty.

PR:		8599
Submitted-by:	Marc Slemko <marcs@znep.com>
1998-12-10 01:53:26 +00:00
Robert V. Baron efb73e5aca In ktrwrite, use uio_procp = curproc vs 0 1998-12-10 01:47:41 +00:00
Eivind Eklund d51523c6c9 Get rid of CTLTYPE_OPAQUE in a SYSCTL_OPAQUE - it is added my the
SYSCTL_OPAQUE macro.
1998-12-09 02:26:45 +00:00
Bruce Evans e1501bb6eb Backed out the FIOASYNC fix in rev.1.108. fcntl(fd, F_SETFL, flags)
depends on the bug.  It does an FIOASYNC ioctl to sync the setting
of the O_ASYNC "file" flag with drivers even if the setting hasn't
changed.

PR:		9003
1998-12-08 10:22:07 +00:00
Archie Cobbs f1d19042b0 The "easy" fixes for compiling the kernel -Wunused: remove unreferenced static
and local variables, goto labels, and functions declared but not defined.
1998-12-07 21:58:50 +00:00
Eivind Eklund 4979978b8d Fix grouping of statements. This remove a potential panic in the soft
updates code.  While I'm here, remove an unintended trigraph.

Reviewed by:	Kirk McKusick <kirk@freebsd.org>
1998-12-07 17:23:45 +00:00
Andrey A. Chernov 8e3c23be56 Move stime declaration to main block, otherwise can left uninitialized
in rare cases.
Found by: Eivind Eklund <eivind@yes.no>
1998-12-07 07:59:20 +00:00
Archie Cobbs 2326715f79 Avoid compiler warning (printf arg type mismatch) when compiling #ifdef DEBUG 1998-12-06 00:03:30 +00:00
Kirk McKusick fcdfed00d5 Even the most recently allocated buffer may not have its b_blkno
field properly filled in, so we must do a VOP_BMAP on that buffer
as well if it is not resolved.
Submitted by: Luoqi Chen <luoqi@watermarkgroup.com>
1998-12-05 06:12:14 +00:00
Archie Cobbs 2127f26023 Examine all occurrences of sprintf(), strcat(), and str[n]cpy()
for possible buffer overflow problems. Replaced most sprintf()'s
with snprintf(); for others cases, added terminating NUL bytes where
appropriate, replaced constants like "16" with sizeof(), etc.

These changes include several bug fixes, but most changes are for
maintainability's sake. Any instance where it wasn't "immediately
obvious" that a buffer overflow could not occur was made safer.

Reviewed by:	Bruce Evans <bde@zeta.org.au>
Reviewed by:	Matthew Dillon <dillon@apollo.backplane.com>
Reviewed by:	Mike Spengler <mks@networkcs.com>
1998-12-04 22:54:57 +00:00
David Greenman 911e8dbc2a Fixed broken code in sendfile(2) when using file offsets. 1998-12-03 12:35:47 +00:00
Archie Cobbs 8245f3f5b4 Add snprintf(3) and vsnprintf(3) capability to the kernel.
Reviewed by:	bde
1998-12-03 04:45:57 +00:00
KATO Takenori 9ad861edee - For some old Cyrix CPUs, %cr2 is clobbered by interrupts. This
problem is worked around by using an interrupt gate for the page
   fault handler.  This code was originally made for NetBSD/pc98 by
   Naofumi Honda <honda@kururu.math.sci.hokudai.ac.jp> and has already
   been in PC98 tree.  Because of this bug, trap_fatal cannot show
   correct page fault address if %cr2 is obtained in this function.
   Therefore, trap_fatal uses the value from trap() function.
-  The trap handler always enables interruption when buggy application
   or kernel code has disabled interrupts and then trapped.  This code
   was prepared by Bruce Evans <bde@FreeBSD.org>.

Submitted by:	Bruce Evans <bde@FreeBSD.org>
		Naofumi Honda <honda@kururu.math.sci.hokudai.ac.jp>
1998-12-02 08:15:17 +00:00
Eivind Eklund 0bfe299097 Check return value of malloc() in expand_name.
Reviewed by:	sef
1998-12-02 01:53:48 +00:00
Poul-Henning Kamp 510eb5b9db Make the previous behaviour the default, add a sysctl which you
can set if your hw/sw produces the "calcru negative..." message.

Setting the alternate method (sysctl -w kern.timecounter.method=1)
makes the the get{nano|micro}*() functions call the real thing at
resulting in a measurable but minor overhead.

I decided to NOT have the "calcru" change the method automatically
because you should be aware of this problem if you have it.

The problems currently seen, related to usleep and a few other corners
are fixed for both methods.
1998-11-29 20:31:02 +00:00
David Greenman f2b678d4cb Compare p_cpulimit with RLIM_INFINITY before comparing it with the process
runtime. p_runtime is unsigned while p_cpulimit is not, so this avoids the
nasty side effect of the process getting killed when the runtime comes up
"negative" due to other bugs.
1998-11-27 11:44:22 +00:00
Tor Egge 18830dba83 Don't forget to update the pmap associated with aio daemons when adding
new page directory entries for a growing kernel virtual address space.
1998-11-27 01:14:21 +00:00
Tor Egge f0ac792bec Attempt to handle interrupts delivered to all IO APICs by using the first
IO APIC with a sufficient number of pins.
1998-11-26 23:14:23 +00:00
Eivind Eklund 9fcdafaefc Staticize. 1998-11-26 18:50:24 +00:00
Bruce Evans e7414d1bfa Fixed the previous fix - stathz doesn't give the statclock frequency
when it is 0.

Submitted by:	mostly by Hidetoshi Shimokawa <simokawa@sat.t.u-tokyo.ac.jp>
1998-11-26 16:49:55 +00:00
Bruce Evans 44f05f9c92 Oops, yet again back out some local changes that shouldn't have been
in the previous commit.
1998-11-26 14:05:58 +00:00
Bruce Evans e4d0e37b33 Fixed scaling of p_pctcpu. It was wrong by a factor of stathz/hz.
Until recently, this was half compensated for in at least ps and top
by multiplying by 100/stathz to get a better wrong factor of 100/hz.
1998-11-26 14:00:08 +00:00
Poul-Henning Kamp c2906d55d0 Make timecounters more resistant to badly behaved SW/HW which locks
out interrupts for too long.  If you still see the "calcru: negative
time..." message you can increase NTIMECOUNTER (see LINT).

Sideeffect is that a timecounter is required to not wrap around in
less than (1 + delta) seconds instead of the (1/hz + delta) required
until now.

Many thanks to: msmith, wpaul, wosch & bde
1998-11-23 09:59:02 +00:00
Søren Schmidt 8843cc3508 Add a kludge to prevent panicing when using VM86 and hitting here
with a NULL curproc.

Originally by: Tor Egge (IIRC)
1998-11-23 09:34:19 +00:00
Bruce Evans f6233520ce Fixed a missing include. `SYSININT(...);' garbage in gave null garbage out. 1998-11-23 09:33:35 +00:00
Don Lewis 9d2b090975 We can't call fsetown() from sonewconn() because sonewconn() is be called
from an interrupt context and fsetown() wants to peek at curproc, call
malloc(..., M_WAITOK), and fiddle with various unprotected data structures.
The fix is to move the code that duplicates the F_SETOWN/FIOSETOWN state
of the original socket to the new socket from sonewconn() to accept1(),
since accept1() runs in the correct context.  Deferring this until the
process calls accept() is harmless since the process can't do anything
useful with SIGIO on the new socket until it has the descriptor for that
socket.

One could make the case for not bothering to duplicate the
F_SETOWN/FIOSETOWN state and requiring the process to explicitly make the
fcntl() or ioctl() call on the new socket, but this would be incompatible
with the previous implementation and might break programs which rely on
the old semantics.

This bug was discovered by Andrew Gallatin <gallatin@cs.duke.edu>.
1998-11-23 00:45:39 +00:00
Bruce Evans 7dd89537f1 Fixed some missing cases in the check for ioctls that involve modification.
Many (mostly machine-dependent ones) are still missing.  NIST-PCTS found
this bug for all the ioctls used to implement the POSIX tc* functions
(TIOCCBRK, TIOCDRAIN, TIOCSPGRP, TIOCSBRK, TIOCSTART and TIOCSTOP), and
I found FIOASYNC, TIOCCONS, TIOCEXCL, TIOCHPCL, TIOCNXCL, TIOCSCTTY and
TIOCSDRAINWAIT by inspection.  TIOCSPGRP was ifdefed out for some reason.

Handle tcsetattr()'s historical speed conversions correctly and more
centrally:
- don't store speeds of 0 in the final termios struct.  Drivers can now
  depend on tp->t_ispeed and tp->t_ospeed giving the actual speed.
  Applications can now depend on tcgetattr() being POSIX.1 conformant.
- convert from a proposed input speed of 0 to the proposed output speed
  (except if that is 0, convert to the current output speed).  Drivers
  can now depend on the proposed input speed being nonzero.
- don't reject negative speeds.  Negative speeds can't happen now that
  speed_t is unsigned, and rejecting invalid speeds is a bug - tcsetattr()
  is supposed to succeed if it can "perform any of the requested actions",
  so it shouldn't fail in practice.
1998-11-22 09:04:09 +00:00
David Greenman 4f699173cb Closed a very narrow and rare race condition that involved net interrupts,
bio interrupts, and a truncated file that along with the precise alignment
of the planets could result in a page being freed multiple times or a
just-freed page being put onto the inactive queue.
1998-11-18 09:00:47 +00:00
Kirk McKusick 96334b8fc8 Because buffers may be tossed and recreated at will under the new VM
system, the mapping from logical to physical block number may be lost.
Hence we have to check for a reconstituted buffer and redo the call to
VOP_BMAP if the physical block number has been lost.
1998-11-17 00:31:12 +00:00
Kenneth D. Merry d9e371b995 Now that the wd driver is fixed (Thanks Bruce!), re-enable the
devstat_end_transaction error message that gets printed whenever the
busy count is < 0.

This will help catch drivers that improperly implement devstat(9) support.
1998-11-15 23:57:22 +00:00
Doug Rabson 921433915d A couple of minor sanity checks.
Submitted by: Nick Hibma <nick.hibma@jrc.it>
1998-11-15 18:11:21 +00:00
David Greenman efac52b4ab In sendfile(2), check against sb_lowat when filling the socket buffer,
rather than 0.
1998-11-15 16:55:09 +00:00
Bruce Evans 4ae860afde Fixed the type of vfs_modevent (a little late, to match the corresponding
change in sys/mount.h).
1998-11-15 15:18:30 +00:00
Bruce Evans 14fddaf97a Fixed a missing include. <sys/kernel.h> is needed by the new
MALLOC_DEFINE() and MALLOC_DEFINE() is needed by the recently
reenabled "reallocblks" code, but <sys/kernel.h> was only included
if CLUSTERDEBUG was defined.  This was too harmless.  gcc only
warns about garbage like `SYSINIT(blech);' at file scope ...
1998-11-15 14:11:06 +00:00
David Greenman f2efb8e4c8 Fixed a couple of nits in sendfile(2): clear PG_ZERO before unbusying
the page, and use passed-in "p" rather than curproc in uio struct.
1998-11-14 23:36:17 +00:00
Garrett Wollman 14177d72cd My changes to the new device interface:
- Interface wth the new resource manager.
	- Allow for multiple drivers implementing a single devclass.
	- Remove ordering dependencies between header files.
	- Style cleanup.
	- Add DEVICE_SUSPEND and DEVICE_RESUME methods.
	- Move to a single-phase interrupt setup scheme.

Kernel builds on the Alpha are brken until Doug gets a chance to incorporate
these changes on that side.

Agreed to in principle by: dfr
1998-11-14 21:58:51 +00:00
Mike Smith d02d6d040a Don't count non-local dirty buffers as outstanding when shutting down.
This avoids the fsck-on-reboot symptoms if you're shutting down with a
hung or unreachable NFS server mounted.  Also remove non-local
filesystems from the mount list to prevent the system hanging when it tries
to unmount them (for the same reason).

Drew points out that there's a good argument for forcibly removing all
"non syncable" filesystems from the mount list (eg. NFS mounts, disks
that aren't responding, etc.) as this then allows you to sync and
cleanly unmount their parents.  No such change is included in this
patch.

Submitted by:	Andrew Gallatin <gallatin@cs.duke.edu>
1998-11-13 22:40:37 +00:00
Doug Rabson 92c6ae04da A couple of fixes to device_delete_child() to delete all children of
the device and to free the device which is being deleted (not its
parent - oops).

Submitted by: Nick Hibma <nick.hibma@jrc.it>
1998-11-13 09:39:37 +00:00