Commit Graph

24856 Commits

Author SHA1 Message Date
bmilekic
4145a94569 Fix is a similar race condition as existed in the mbuf code. When we go
into an interruptable sleep and we increment a sleep count, we make sure
that we are the thread that will decrement the count when we wakeup.
Otherwise, what happens is that if we get interrupted (signal) and we
have to wake up, but before we get our mutex, some thread that wants
to wake us up detects that the count is non-zero and so enters wakeup_one(),
but there's nothing on the sleep queue and so we don't get woken up. The
thread will still decrement the sleep count, which is bad because we will
also decrement it again later (as we got interrupted) and are already off
the sleep queue.
2001-03-08 19:21:45 +00:00
iedowse
853980c173 It was possible for ip_forward() to supply to icmp_error()
an IP header with ip_len in network byte order. For certain
values of ip_len, this could cause icmp_error() to write
beyond the end of an mbuf, causing mbuf free-list corruption.
This problem was observed during generation of ICMP redirects.

We now make quite sure that the copy of the IP header kept
for icmp_error() is stored in a non-shared mbuf header so
that it will not be modified by ip_output().

Also:
- Calculate the correct number of bytes that need to be
  retained for icmp_error(), instead of assuming that 64
  is enough (it's not).
- In icmp_error(), use m_copydata instead of bcopy() to
  copy from the supplied mbuf chain, in case the first 8
  bytes of IP payload are not stored directly after the IP
  header.
- Sanity-check ip_len in icmp_error(), and panic if it is
  less than sizeof(struct ip). Incoming packets with bad
  ip_len values are discarded in ip_input(), so this should
  only be triggered by bugs in the code, not by bad packets.

This patch results from code and suggestions from Ruslan, Bosko,
Jonathan Lemon and Matt Dillon, with important testing by Mike
Tancsa, who could reproduce this problem at will.

Reported by:	Mike Tancsa <mike@sentex.net>
Reviewed by:	ru, bmilekic, jlemon, dillon
2001-03-08 19:03:26 +00:00
dwmalone
831901afd7 Make the wait for sendfile buffers interruptable. Stops one process
consuming them all and then getting stuck.

Reviewed by:	dg
Reviewed by:	bmilekic
Observed by:	Andreas Persson <pap@garen.net>
2001-03-08 16:28:10 +00:00
gallatin
7597b843e0 Take the KINFO_PROC_SIZE back down to 912 on alpha.
Since the compiler lays out the stuct so that pointers are naturally
(8-byte) aligned aligned, adding the int ki_layout didn't change the size of
the stuct; it just converted the alignment padding to a usable struct
field.
2001-03-08 15:17:38 +00:00
kato
4f7092532b Replaced p (undeclared) with curproc (after i386/isa/npx.c). 2001-03-08 14:25:51 +00:00
mdodd
d7a2c22e1e Move configuration of work_memory to oltr_init() rather than
oltr_pci_attach().  This only affects the OC-3139 and OC-3540.

MFC candidate.

PR:		kern/24074
2001-03-08 01:38:58 +00:00
tmm
526876863d Make the SYSCTL_OUT handlers sysctl_old_user() and sysctl_old_kernel()
more robust. They would correctly return ENOMEM for the first time when
the buffer was exhausted, but subsequent calls in this case could cause
writes ouside of the buffer bounds.

Approved by:	rwatson
2001-03-08 01:20:43 +00:00
wpaul
1fcaee7fa4 Remember to actually program the MAC address into the unicast filter
in vr_init(). The VIA Rhine chip happens to be able to automatically
read its station address from the EEPROM automatically when reset,
so you don't need to program the filter if you want to keep using the
factory default address, but if you want to change it with "ifconfig vr0
ether xx:xx:xx:xx:xx:xx" then we need to manually set it in the init
routine.
2001-03-07 18:52:22 +00:00
iwasaki
b7b587b172 Bring our local hack for wakeup back from
sys/contrib/dev/acpica/Subsystem/Hardware/Attic/hwxface.c to the proper
location after AcpiEnterSleepState().

 - Wait for the WAK_STS bit
 - Evaluate the _WAK method and check result code
2001-03-07 15:22:14 +00:00
sanpei
8d8af7f2f4 Add GVC1601 - Rockwell V.34 Plug & Play Modem
PR:		kern/25204
Submitted by:	Victor Ivanov <v0rbiz@icon.bg>
2001-03-07 14:27:56 +00:00
sanpei
b8e65b01f8 Add IOD0081 - I-O DATA DEVICE,INC. IFML-560
PR:		kern/25173
Submitted by:	Yohsuke Fujikawa <yohsuke@mx2.nisiq.net>
2001-03-07 14:19:55 +00:00
dcs
f18d132785 Goodbye vn, welcome md. 2001-03-07 09:42:41 +00:00
scottl
cf99267396 Set si_iosize_max to 64K, even though the adapter seems to be able to do more.
This puts us safely in line with Adaptec documentation and shouldn't really
affect anything.

MFC candidate for 4.3
2001-03-07 08:37:49 +00:00
mckusick
f01ec099d7 Fixes to track snapshot copy-on-write checking in the specinfo
structure rather than assuming that the device vnode would reside
in the FFS filesystem (which is obviously a broken assumption with
the device filesystem).
2001-03-07 07:09:55 +00:00
mckusick
2679d9c3cf Bitch more loudly when someone botches changes to kinfo_proc
in the hopes that they will actually *read* the comment above
it and *follow* the instructions so as to cause all the rest
of us less a lot less grief.
2001-03-07 06:52:12 +00:00
mckusick
6f7fda292b Apply i386 fix in 1.32 for the alpha too. 2001-03-07 06:48:41 +00:00
jhb
7520059833 Unrevert the pmap_map() changes. They weren't broken on x86.
Sense beaten into me by:	peter
2001-03-07 05:29:21 +00:00
jhb
7d66948cf0 - Don't hold the proc lock across VREF and the fd* functions to avoid lock
order reversals.
- Add some preliminary locking in the !RF_PROC case.
- Protect p_estcpu with sched_lock.
2001-03-07 05:21:47 +00:00
gsutter
3975ad8d23 Spelling and capitalization fixes.
Reviewed by:	gshapiro, jake, jhb, rwatson (all within 30 seconds)
2001-03-07 04:58:38 +00:00
jhb
3740c3ca81 - Release Giant a bit earlier on syscall exit.
- Don't try to grab Giant before postsig() in userret() as it is no longer
  needed.
- Don't grab Giant before psignal() in ast() but get the proc lock instead.
2001-03-07 03:53:39 +00:00
jhb
ea6f99c455 - Lock the process while sending it a signal.
- Attempt to define empty PROC_LOCK/UNLOCK when needed to help keep
  this driver portable.
2001-03-07 03:42:42 +00:00
jhb
44b0453b59 Grab the process lock while calling psignal and before calling psignal. 2001-03-07 03:37:06 +00:00
jhb
0efe7f19be Protect SIGDELSET of p_siglist with the proc lock. 2001-03-07 03:34:55 +00:00
jhb
0f64de3813 Proc locking including using proc lock in place of proctree where
appropriate and locking processes while we signal them.
2001-03-07 03:28:50 +00:00
jhb
76a3b7a8fb Proc locking. 2001-03-07 03:27:32 +00:00
jhb
cb62afb44c Use the proc lock to protect access to p_sigacts->ps_sigintr. 2001-03-07 03:26:39 +00:00
jhb
f315adf3e2 Just hold the proc lock while getting the parent's PID rather than a
proctree lock.
2001-03-07 03:21:26 +00:00
jhb
f4b79cb5b1 Use the proc lock to protect p_pptr when waking up our parent in cpu_exit()
and remove the mpfixme() message that is now fixed.
2001-03-07 03:20:15 +00:00
jhb
d6969a725b Just use proc lock to protect reading of p_pptr rather than a proctree
lock.
2001-03-07 03:18:36 +00:00
jhb
e83dac8c96 Proc locking identical to that of linprocfs' vnops except that we hold the
proc lock while calling psignal.
2001-03-07 03:15:05 +00:00
jhb
8d0f719bf3 Protect read to p_pptr with proc lock rather than proctree lock. 2001-03-07 03:10:20 +00:00
jhb
4341a84166 Proc locking. Lock around psignal() and also ensure both an exclusive
proctree lock and the process lock are held when updating p_pptr and
p_oppid.  When we are just reaading p_pptr we only need the proc lock and
not a proctree lock as well.
2001-03-07 03:09:40 +00:00
jhb
377240946c - Proc locking.
- Remove some unneeded spl()'s.
2001-03-07 03:06:18 +00:00
jhb
c434e6ea6c Lock the process while sending it SIGARLM and updating p_realtimer. 2001-03-07 03:02:56 +00:00
jhb
72d3d31e96 - Proc locking.
- Remove unneeded spl()'s.
2001-03-07 03:01:53 +00:00
jhb
78b4f51fab - Proc locking. Most of signal handling is now MP safe and doesn't require
Giant.  The only exception is the CANSIGNAL() macro.  Unlocking the proc
  lock around sendsig() in trapsignal() is also questionable.  Note that
  the functions sigexit(), psignal(), and issignal() must be called with
  the proc lock of the process in question held.  postsig() and
  trapsignal() should not be called with the proc lock held, but they
  also do not require Giant anymore either.
- Remove spl's that are now no longer needed as they are fully replaced.
2001-03-07 02:59:54 +00:00
jhb
157e2aac95 Lock initproc when we send SIGINT to init during shutdown. 2001-03-07 02:50:09 +00:00
jhb
c1beefd6af - Add an extra check in priority_propagation() for UP systems to ensure we
don't end up back at ourselves which would indicate deadlock.
- Add the proc lock to the witness dup_list as we may hold more than one
  process lock at a time.
- Don't assert a mutex is owned in _mtx_unlock_sleep() as that is too late.
  We do the checks in the macros instead.
2001-03-07 02:45:15 +00:00
jhb
4b1f571f83 - Use _PHOLD and move it before a PROC_UNLOCK to reduce the number of
mutex operations in kthread_create().
- Lock a kthread's proc before changing its parent via proc_reparent().
- Test P_KTHREAD not P_SYSTEM in kthread_suspend() and kthread_resume().
  P_SYSTEM just means that the process shouldn't be swapped and is used
  for vinum's daemon for example.
- Lock all the signal state used for suspending and resuming kthreads with
  the proc lock.
2001-03-07 02:36:47 +00:00
jhb
3d1a44cd56 - Lock the forklist with an sx lock.
- Add proc locking to fork1().  Always lock the child procoess (new
  process) first when both processes need to be locked at the same
  time.
- Remove unneeded spl()'s as the data they protected is now locked.
- Ensure that the proctree is exclusively locked and the new process is
  locked when setting up the parent process pointer.
- Lock the check for P_KTHREAD in p_flag in fork_exit().
2001-03-07 02:30:39 +00:00
jhb
b6e227dd17 Check to see if p_fd is NULL before derferencing it in checkdirs(). It's
possible for us to see a process in the early stages of fork before p_fd
has been initialized.  Ideally, we wouldn't stick a process on the allproc
list until it was fully created however.
2001-03-07 02:25:13 +00:00
jhb
50c16d6e21 - Call proc_reparent() when handing a process off to init in exit rather
than dinking around in the process lists explicitly.
- Hold both the proctree lock and proc lock of the child process when
  reparenting a process via proc_reparent.
- Lock processes while sending them signals.
- Miscellaenous proc locking.
- proc_reparent() now asserts that the child is locked in addition to an
  exclusive proctree lock.
2001-03-07 02:22:31 +00:00
jhb
6b3e8d1743 - Hold both an exclusive proctree lock and the proc lock when reparenting
a traced process during exit.
- Lock the parent process while sending it SIGCHLD.
2001-03-07 02:17:43 +00:00
jhb
4f238e0d87 Protect p_flag with the proc lock. 2001-03-07 02:07:56 +00:00
jhb
3f330f1780 - Include <sys/systm.h> for KASSERT().
- Move the _mtx_assert() prototype up to the top of the file with the rest
  of the function prototypes.
- Define all the mtx_foo() macros in terms of mtx_foo_flags().
- Add a KASSERT() to check for invalid options in mtx_lock_flags().
- Move the mtx_assert() to ensure a mutex is owned before releasing it
  in front of WITNESS_EXIT() in all the mtx_unlock_* macros.
- Change the MPASS* macros to be on #ifdef INVARIANTS, not just #ifdef
  MUTEX_DEBUG since most of them check to see that the mutex functions are
  called properly.  Define MPASS4() in terms of KASSERT() to do this.
- Define MPASS{,[23]} in terms of MPASS4() to simplify things and avoid
  code duplication.
2001-03-07 02:06:08 +00:00
jhb
e7ac0a66fd - In the locking key for struct proc, generalize the '+' symbol to mean
that write access to a member requires both locks and read access only
  requires one of the given locks.  Convert instances of '(c+)' to
  '(c + k)' as a result.
- Change p_pptr from (e) to (c + e).
- Change p_oppid from (c) to (c + e).
- Change p_args from (b?) to (c + k).
- Move the actual work of STOPEVENT, PHOLD, and PRELE to _STOPEVENT,
  _PHOLD, and _PRELE.  The new macros do not acquire the proc lock and
  simply assert that it is held.  The non _ prefixed macros acquire the
  proc lock and then call the _ prefixed macros.
- Add a PROC_LOCK_NOSWITCH() macro to be used when releasing the proc lock
  while already holding a spin lock (usually sched_lock).
- Add a PROC_LOCK_ASSERT() macro to be used to make assertions about the
  proc lock.  It takes the usual mtx_assert() macro arguments as its
  second argument.
2001-03-07 01:51:34 +00:00
jhb
32bd7ccaa2 Back out the pmap_map() change for now, it isn't completely stable on the
i386.
2001-03-07 01:04:17 +00:00
jhb
1da8282c33 In order to avoid recursing on the backing mutex for sx locks in the
INVARIANTS case, define the actual KASSERT() in _SX_ASSERT_[SX]LOCKED
macros that are used in the sx code itself and convert the
SX_ASSERT_[SX]LOCKED macros to simple wrappers that grab the mutex for the
duration of the check.
2001-03-06 23:13:15 +00:00
jhb
74bf2645d6 Get the arguments to the KASSERT() printf() in SX_ASSERT_XLOCKED() in
the proper order.
2001-03-06 22:41:31 +00:00
sos
2b02448def Split out the ata probes in seperate files for each bus type. 2001-03-06 21:43:46 +00:00