dragonfly.git
11 years agoMerge remote branch 'crater/DragonFly_RELEASE_3_0' into rel3_0 v3.0.3
Thomas Nikolajsen [Tue, 21 Aug 2012 21:44:11 +0000 (23:44 +0200)]
Merge remote branch 'crater/DragonFly_RELEASE_3_0' into rel3_0

11 years agokernel/linprocfs: Add a missing header for spin_{,un}lock().
Sascha Wildner [Thu, 16 Aug 2012 14:05:38 +0000 (16:05 +0200)]
kernel/linprocfs: Add a missing header for spin_{,un}lock().

11 years agokernel/linprocfs: Fix accessing files in /proc (such as /proc/meminfo).
Sascha Wildner [Tue, 21 Aug 2012 18:57:19 +0000 (20:57 +0200)]
kernel/linprocfs: Fix accessing files in /proc (such as /proc/meminfo).

It is the same fix that was applied to procfs with 198c0ff2.

11 years agokernel/linprocfs: Fix a panic when accessing /proc/<pid>/maps.
Sascha Wildner [Tue, 21 Aug 2012 20:44:09 +0000 (22:44 +0200)]
kernel/linprocfs: Fix a panic when accessing /proc/<pid>/maps.

Analogous to procfs.

11 years agokernel - Fix condvar races
Matthew Dillon [Fri, 17 Aug 2012 19:40:09 +0000 (12:40 -0700)]
kernel - Fix condvar races

* Interlocked sleep was not using the PINTERLOCKED flag.

* Misc other adjustments.

11 years agokernel - Adjust UFS and HAMMER to use uiomovebp()
Matthew Dillon [Fri, 17 Aug 2012 00:54:16 +0000 (17:54 -0700)]
kernel - Adjust UFS and HAMMER to use uiomovebp()

* Add uiomovebp(), a version of uiomove() which is aware of a locked bp
  representing the to or from buffer and can work-around issues related
  to VM faults causing recursions and deadlocks on the user buffer.

  uiomovebp() does not yet detect or handle deadlocks.  Implementing
  deadlock handling will require a certain degree of finess related to
  the vnode and bp locks and we don't want to have to do it unless we
  actually deadlock.  TODO.

* Adjust UFS, HAMMER, TMPFS, MSDOSFS, NFS, NTFS to use uiomovebp().

11 years agokernel - Change lockmgr LK_SHARED behavior to fix improper recursion return
Matthew Dillon [Fri, 17 Aug 2012 00:40:38 +0000 (17:40 -0700)]
kernel - Change lockmgr LK_SHARED behavior to fix improper recursion return

* When obtaining a LK_SHARED lock in a situation where you already own the
  lock LK_EXCLUSIVE, lockmgr would downgrade the lock to shared.

  This creates a very serious problem when large procedural recursions get
  a lock that is already being held exclusively but request a shared lock.
  When these recursions return the original top level will find its lock is
  no longer exclusive.

* This problem occured with vnode locks when a VOP_WRITE operation on a mmap'd
  space causes a VM fault which then turns around and issues a read().
  When the fault returns the vnode wound up locked shared instead of
  exclusive.

* Fix the problem by NOT downgrading an exclusive lock to shared when
  recursing on LK_SHARED.  Simply add another count to the exclusive
  lock.

11 years agokernel - Fix incorrect dirty/reprotect code in pageout
Matthew Dillon [Thu, 16 Aug 2012 18:42:25 +0000 (11:42 -0700)]
kernel - Fix incorrect dirty/reprotect code in pageout

* vm_object_page_collect_flush() was trying to re-protect VM pages that
  were still marked dirty after pageout I/O was initiated without owning
  the BUSY bit on the page.  This operation could race whatever I/O was
  going on and multiple issues.  Remove the re-protect.

  Just don't do it.  It's an unnecessary operation.  We still re-set
  PG_CLEANCHK on the page and that should be fine insofar as the pageout
  daemon goes.

* Note that the pageout_flush code protects the VM pages properly (to
  read-only) prior to initiating I/O .

* Should fix bug #2350

* Might be related to the wire-count bug considering that we were messing
  with the page's pmap without owning the BUSY bit.  Small chance.

11 years agokernel - Fix long-standing vm_map token panic
Matthew Dillon [Thu, 16 Aug 2012 17:46:33 +0000 (10:46 -0700)]
kernel - Fix long-standing vm_map token panic

* Bug turned out to be an error path in vm_map_find().

* This bug ate a lot of hours from several people, but Antonio was able
  to instrument the token path in a way that allowed us to narrow down
  and locate the problem.

Submitted-by: tuxillo, vsrinivas
Debugging-by: tuxillo
11 years agokernel - Stop KTR logging during panic
Matthew Dillon [Thu, 16 Aug 2012 16:11:07 +0000 (09:11 -0700)]
kernel - Stop KTR logging during panic

* Stop all KTR logging when a panic occurs so the KTR buffer doesn't
  get wiped out by events during the panic & core dump.  This gives
  us a KTR buf snapshot as of the panic entry.

11 years agokernel - Fix numerous procfs/ptrace issues (3)
Matthew Dillon [Thu, 16 Aug 2012 01:17:43 +0000 (18:17 -0700)]
kernel - Fix numerous procfs/ptrace issues (3)

* Add a safety spin-lock around adjustments to p_stops so it hopefully
  interacts better with the event processing side of things.

11 years agokernel - Fix exit races which can lead to a corrupt p_children list
Matthew Dillon [Thu, 16 Aug 2012 01:11:11 +0000 (18:11 -0700)]
kernel - Fix exit races which can lead to a corrupt p_children list

* There are a few races when getting multiple tokens where a threaded
  process is wait*()ing for exiting children from multiple threads
  at once.

  Fix the problem by serializing the operation on a per-child basis,
  and by using PHOLD/PRELE prior to acquiring the child's p_token.
  Then re-check the conditions before accepting the child.

* There is a small chance this will also reduce or fix VM on-exit races
  in i386, as this bug could result in an already-destroyed process
  being pulled off by the racing wait*().  Maybe 25% chance.

11 years agoKernel - Fix numerous procfs/ptrace issues (2)
Matthew Dillon [Thu, 16 Aug 2012 00:49:47 +0000 (17:49 -0700)]
Kernel - Fix numerous procfs/ptrace issues (2)

* The last fix wasn't quite right.  Fix it for real.

11 years agoKernel - Fix numerous procfs/ptrace issues
Matthew Dillon [Thu, 16 Aug 2012 00:18:31 +0000 (17:18 -0700)]
Kernel - Fix numerous procfs/ptrace issues

* Fix interactions during exec and exit.  This should fix truss
  (bug 2313).

* Reset p_* fields related to tracing on last procfs close for the
  process.

11 years agokernel -- ffs: Compile fix for ffs_softdep.c
Venkatesh Srinivas [Thu, 16 Aug 2012 02:23:24 +0000 (19:23 -0700)]
kernel -- ffs: Compile fix for ffs_softdep.c

11 years agokernel - Fix two UFS+softupdates bugs
Matthew Dillon [Thu, 16 Aug 2012 01:14:27 +0000 (18:14 -0700)]
kernel - Fix two UFS+softupdates bugs

* The softdep sema_*() functions (the ones in ffs_softdep.c, not the sysv
  functions) were not MPSAFE for the case where the passed interlock is
  NULL.  Use a spinlock for that case.

* getdirtybuf()'s semantics were broken and could return success even
  after having released &lk with the bp still unlocked.

  Fixing this should fix most of the reported softdep panics.

11 years agokernel -- ffs: Softdep lock and assorted fixes
Venkatesh Srinivas [Mon, 7 May 2012 15:28:48 +0000 (08:28 -0700)]
kernel -- ffs: Softdep lock and assorted fixes

* Remove interlocked_sleep; we can just use lksleep directly

* sema_get no longer eats the interlock passed in; all of its
  callers were retaking the lock eventually or immediately.

* softdep was setting up a callout to wake itself in request_cleanup.
  Switch to directly using timeout in lksleep for this purpose.

* Do not access inodedep structure outside of softdep lock in
  softdep_update_inodeblock for buffer field.

* Remove prio field from semaphores; they were unused and the DFly
  tsleep routines do not respect priority anyway.

* Do not release softdep lock before panic()ing

11 years agoinstaller: When setting the slice type for >2TB, ignore fdisk warnings.
Sascha Wildner [Mon, 13 Aug 2012 18:42:13 +0000 (20:42 +0200)]
installer: When setting the slice type for >2TB, ignore fdisk warnings.

With disks >2TB this step will lead to some whining from fdisk(8), but
since we'll boot anyway (with 34ea800d, we resort to the media size
when a maxed out slice size is detected), just ignore any issues which
fdisk(8) reports in this case.

After this commit, installing and booting from that installation on a
disk which is >2TB will work (tested with a 3TB ahci attached drive as
well as with a 4.5TB hptrr(4) RAID).

Dragonfly-bug: <https://bugs.dragonflybsd.org/issues/2264>
Reported-by: ftigeot
11 years agoahci(4)/sili(4): Fix for drives >2TB.
Sascha Wildner [Mon, 13 Aug 2012 00:33:30 +0000 (02:33 +0200)]
ahci(4)/sili(4): Fix for drives >2TB.

CAM will issue the 16 byte version of the READ CAPACITY command when
maxsector is 0xffffffff:

----- scsi_da.c -----
if (maxsector == 0xffffffff) {
softc->state = DA_STATE_PROBE2;
kfree(rdcap, M_SCSIDA);
xpt_release_ccb(done_ccb);
xpt_schedule(periph, /*priority*/5);
return;
}
---------------------

However, we are subtracting 1 from it (presumably because it's a "last
sector on the device" value starting at 0) so in CAM, it ended up being
0xfffffffe, resulting in disks attached via ahci(4) and sili(4) to be
limited to 2TB.

To fix, set the local var to 0 in this case, so that after subtracting 1
from the value (cast to 32 bit) CAM gets 0xffffffff.

Fix-by: dillon
11 years agoboot - Fix boot probe ordering
Matthew Dillon [Sun, 12 Aug 2012 00:09:11 +0000 (17:09 -0700)]
boot - Fix boot probe ordering

* When boot loader support is compiled w/ UFS and HAMMER together, which
  is the default (note: HAMMER booting's never worked well)... the probe
  order was to check for the hammer volume header first and UFS second.

* Change the probe order to check for UFS first and HAMMER second.  The
  reason is that a 'newfs' (for UFS) doesn't wipe the hammer volume header
  because the ufs's newfs tries to 'skip' the partition reserved area of
  the disk.

  This is a huge throwback to the original BSD fdisk/disklabel which put
  the boot code INSIDE the 'a' partition.

* The DragonFly disklabel64 (which is now the default) does not have this
  problem so we could probably at some point adjust the UFS 'newfs' code to
  wipe the old 'reserve' area to really put a cap on the problem.

Reported-by: tuxillo
11 years agompt(4): Fix a porting mistake I did in 6d259fc1.
Sascha Wildner [Tue, 7 Aug 2012 07:16:38 +0000 (09:16 +0200)]
mpt(4): Fix a porting mistake I did in 6d259fc1.

I left in both the code of the "#if __FreeBSD_version" as well as that of
its "#else". This caused the geometry to be calculated twice.

11 years agoSync zoneinfo database with tzdata2012e from ftp://ftp.iana.org/tz/releases
Sascha Wildner [Fri, 3 Aug 2012 10:20:15 +0000 (12:20 +0200)]
Sync zoneinfo database with tzdata2012e from ftp://ftp.iana.org/tz/releases

* australasia (Pacific/Fakaofo): Tokelau is UTC+13, not UTC+14.
    (Thanks to Steffen Thorsen.)

11 years agohptmv(4): Reduce si_iosize_max to 64KB.
Sascha Wildner [Thu, 2 Aug 2012 22:42:39 +0000 (00:42 +0200)]
hptmv(4): Reduce si_iosize_max to 64KB.

This fixes busdma panics we were getting with it.

busdma-clue-by: sephe

11 years agokernel/cam: Make si_iosize_max overridable by drivers.
Sascha Wildner [Thu, 2 Aug 2012 22:14:28 +0000 (00:14 +0200)]
kernel/cam: Make si_iosize_max overridable by drivers.

11 years agogcore(1): Make it work again.
Sascha Wildner [Sat, 28 Jul 2012 20:29:43 +0000 (22:29 +0200)]
gcore(1): Make it work again.

Two commits broke things:

64fce751acfda11e21846e900fc774e88f32f52e which changed us to no longer
claiming that we're FreeBSD in core files.

0b684e3f9af3abc5ded676c43a1a5a478b45325c which added another field to
/proc/<pid>/map (the vnode path for vn-backed vm objects).

Both changes need adjustments in gcore(1).

11 years agorc.d/netif: Require cleanvar.
Sascha Wildner [Tue, 24 Jul 2012 21:19:23 +0000 (23:19 +0200)]
rc.d/netif: Require cleanvar.

Before the ipfilter removal, netif required ipfilter, which required
ipmon, which required cleanvar. In other words, cleanvar was run before
netif.

With the ipfilter requirement removed from netif, cleanvar was now
ordered at some place after netif, which caused the PID file and
control socket of wpa_supplicant(8) (which is started by netif if an
ifconfig_xxx="WPA" line is found in /etc/rc.conf) to be removed from
/var/run by cleanvar after they were created.

This caused trouble for wpa_cli(8), which needs the socket.

Found-by: Johannes Hofmann <Johannes.Hofmann@gmx.de>
11 years agolapic: Allow lapic enumeration to fail
Sepherosa Ziehau [Fri, 20 Jul 2012 02:59:08 +0000 (10:59 +0800)]
lapic: Allow lapic enumeration to fail

It is mainly used to workaround for some old brain dead BIOS, which
will set BSP's LAPIC apic id to 255, but all MADT LAPIC entries are
valid

Reported-by: klanger on #dragonflybsd
11 years agoapic: APIC ID should not be 255, which is used for broadcast
Sepherosa Ziehau [Fri, 20 Jul 2012 02:31:04 +0000 (10:31 +0800)]
apic: APIC ID should not be 255, which is used for broadcast

11 years agoaic7xxx: fix a pointer sign warning
François Tigeot [Mon, 23 Jul 2012 07:29:25 +0000 (09:29 +0200)]
aic7xxx: fix a pointer sign warning

11 years agoSync zoneinfo database with tzdata2012d from ftp://ftp.iana.org/tz/releases
Sascha Wildner [Fri, 20 Jul 2012 08:22:22 +0000 (10:22 +0200)]
Sync zoneinfo database with tzdata2012d from ftp://ftp.iana.org/tz/releases

* Removes the SCCS IDs

* africa: Morocco does not observe DST from Jul 20 03:00 to Aug 20 02:00.

11 years agoMerge remote-tracking branch 'crater/DragonFly_RELEASE_3_0' into rel3_0
Thomas Nikolajsen [Sat, 14 Jul 2012 09:08:13 +0000 (11:08 +0200)]
Merge remote-tracking branch 'crater/DragonFly_RELEASE_3_0' into rel3_0

11 years agokernel - Fix MP race in sysv semaphore code (2)
Matthew Dillon [Thu, 12 Jul 2012 02:50:13 +0000 (19:50 -0700)]
kernel - Fix MP race in sysv semaphore code (2)

* Add missing changes to proc.h

Reported-by: sephe
11 years agox86_64 FPU: Set 64-bit precision for fadd/fsub/fsqrt etc.
John Marino [Thu, 12 Jul 2012 11:15:12 +0000 (13:15 +0200)]
x86_64 FPU: Set 64-bit precision for fadd/fsub/fsqrt etc.

On AMD64, GCC and the ABI expects the x87 unit to be running in 80/64
mode rather than 64/53 mode seen on i386.  This corrects errors seen
in long double tests involving runtime calculations.  Previously, the
results of these runtime calculations would get rounded due to use
of 53-bit mantissas.

11 years agokernel - Fix MP race in sysv semaphore code
Matthew Dillon [Wed, 11 Jul 2012 22:29:55 +0000 (15:29 -0700)]
kernel - Fix MP race in sysv semaphore code

* Fix a serious MP race in the sysv semaphore code due to a lack of
  protection of the semu* global structures.

* The race occurs during semaphore allocation and deallocation vs ANY
  exiting process (even if it does not use semaphores), potentially
  leading to a live-lock in the semu_list scan code.

  The live-lock will prevent the cpu it occurs on from being able to
  switch to another kernel or user thread.  In the sample case it
  stopped pagedaemon from running, creating a backlog in the I/O
  subsystem which locked the computer up.

Reported-by: Peter Avalos
11 years agosysctl(8): Fix handling of uquad type sysctls (wrong variable was taken).
Sascha Wildner [Thu, 12 Jul 2012 11:11:37 +0000 (13:11 +0200)]
sysctl(8): Fix handling of uquad type sysctls (wrong variable was taken).

11 years agotwa(4)/twe(4): Move dev_ops_remove_minor() after destroy_dev().
Sascha Wildner [Sun, 8 Jul 2012 23:07:10 +0000 (01:07 +0200)]
twa(4)/twe(4): Move dev_ops_remove_minor() after destroy_dev().

Fixes crash on module unload.

11 years agotwa(4): Pass INTR_MPSAFE when setting up the interrupt.
Sascha Wildner [Sun, 8 Jul 2012 20:39:48 +0000 (22:39 +0200)]
twa(4): Pass INTR_MPSAFE when setting up the interrupt.

I removed it by mistake during porting.

While here, add some little fixes from FreeBSD.

Tested-with: 3ware 9650SE-2LP

11 years agosdpd(8): Fix a wrong sizeof.
Sascha Wildner [Fri, 6 Jul 2012 12:09:49 +0000 (14:09 +0200)]
sdpd(8): Fix a wrong sizeof.

11 years agokernel/sbuf: Add back a lost newline.
Sascha Wildner [Thu, 5 Jul 2012 19:16:18 +0000 (21:16 +0200)]
kernel/sbuf: Add back a lost newline.

11 years agosbuf_vprintf: ap is not consistent at second call of kvsnprintf. Use a copy
Mihai Carabas [Sun, 1 Jul 2012 19:18:25 +0000 (22:18 +0300)]
sbuf_vprintf: ap is not consistent at second call of kvsnprintf. Use a copy

11 years agoFix more wrong sizeof() usages, part 4/x
Sascha Wildner [Sat, 30 Jun 2012 08:44:33 +0000 (10:44 +0200)]
Fix more wrong sizeof() usages, part 4/x

We want struct sizes here, not pointer sizes.

Found-with: Coccinelle (http://coccinelle.lip6.fr/)

11 years agontfs - Set CNP_PDIRUNLOCK flag if we unlock the parent dir.
Antonio Huete Jimenez [Tue, 19 Jun 2012 22:05:41 +0000 (00:05 +0200)]
ntfs - Set CNP_PDIRUNLOCK flag if we unlock the parent dir.

If we unlocked the parent dir, we must specify it via CNP_PDIRUNLOCK
flag to avoid further vn_unlock attempts.

DragonFly-bug: http://bugs.dragonflybsd.org/issues/2388

Reported by: swildner, Raimundo Santos

11 years agoFix more wrong sizeof() usages, part 3/x
Sascha Wildner [Thu, 21 Jun 2012 02:25:19 +0000 (04:25 +0200)]
Fix more wrong sizeof() usages, part 3/x

Some comments:

* The gzip fix speeds up uncompression of compress(1)'d files with gzip.
  A test here took 9s with the fix when it previously took 15s.

* Our OpenSSH is without J-PAKE support, hence the OpenSSH fix is only
  cosmetical.

Found-with: Coccinelle (http://coccinelle.lip6.fr/)

11 years agocryptdisks(8): Fix a wrong sizeof.
Sascha Wildner [Mon, 18 Jun 2012 06:35:20 +0000 (08:35 +0200)]
cryptdisks(8): Fix a wrong sizeof.

Use the size passed to the alloc_safe_mem() here.

Found-with: Coccinelle (http://coccinelle.lip6.fr/)

11 years agovkernel: revert two commits that break i386 vkernel
Markus Pfeiffer [Sun, 17 Jun 2012 19:38:49 +0000 (19:38 +0000)]
vkernel: revert two commits that break i386 vkernel

revert i386 parts of
  commit c55fa5eeab3eaf11e01222d6412b91dafdcd9e94
  commit 1a482e3fea833c34264b54d566ddd0f4276d8bcf
because it breaks build. This is still a kludge.

11 years agohammer(8): Fix a wrong sizeof.
Sascha Wildner [Sun, 17 Jun 2012 19:21:15 +0000 (21:21 +0200)]
hammer(8): Fix a wrong sizeof.

Use the size passed to the malloc() here.

Found-with: Coccinelle (http://coccinelle.lip6.fr/)

11 years agoFix more wrong sizeof() usages, part 2/x
Sascha Wildner [Sun, 17 Jun 2012 01:28:37 +0000 (03:28 +0200)]
Fix more wrong sizeof() usages, part 2/x

Take the size of the struct instead of the size of its address.

Found-with: Coccinelle (http://coccinelle.lip6.fr/)

11 years agosavecore(8): Use the buf's size and not char *'s size for reading the kernel.
Sascha Wildner [Sat, 16 Jun 2012 23:42:28 +0000 (01:42 +0200)]
savecore(8): Use the buf's size and not char *'s size for reading the kernel.

This speeds up the kernel saving part by a couple of seconds.

11 years agoFix more wrong sizeof() usages, part 1/x
Sascha Wildner [Sat, 16 Jun 2012 10:31:23 +0000 (12:31 +0200)]
Fix more wrong sizeof() usages, part 1/x

These cases should all be taking the size of the pointed to struct etc.,
instead of the pointer size.

Found-with: Coccinelle (http://coccinelle.lip6.fr/)

11 years agovkernel/vkernel64: fix a bug in cpu_regs.c
Markus Pfeiffer [Sat, 16 Jun 2012 11:20:58 +0000 (11:20 +0000)]
vkernel/vkernel64: fix a bug in cpu_regs.c

followup to the previous typo which was repeated in the handling
of old FreeBSD style arguments.

11 years agovkernel/vkernel64: fix a bug in cpu_regs.c
Markus Pfeiffer [Sat, 16 Jun 2012 10:52:43 +0000 (10:52 +0000)]
vkernel/vkernel64: fix a bug in cpu_regs.c

the sendsig function incorrectlty delivered tf_err in the
si_addr field of siginfo leading to weird behaviour.

11 years agotimed(8): Add missing braces.
Sascha Wildner [Thu, 14 Jun 2012 17:29:07 +0000 (19:29 +0200)]
timed(8): Add missing braces.

11 years agoarcmsr(4): To check for sense data, use sense_len.
Sascha Wildner [Sat, 9 Jun 2012 07:56:39 +0000 (09:56 +0200)]
arcmsr(4): To check for sense data, use sense_len.

Checking the address of a variable or field is going to be always true.

11 years agore: Fix size of the bcopy when extracting ethernet address
Sepherosa Ziehau [Mon, 11 Jun 2012 08:30:49 +0000 (16:30 +0800)]
re: Fix size of the bcopy when extracting ethernet address

Reported-by: swildner@
11 years agokernel/ufs: Bring in a fix to ufsdirhash_hash() from FreeBSD.
Sascha Wildner [Sun, 10 Jun 2012 02:31:33 +0000 (04:31 +0200)]
kernel/ufs: Bring in a fix to ufsdirhash_hash() from FreeBSD.

"When looking for some extra data to include in the hash, use the
 address of the dirhash, rather than the first sizeof(struct dirhash *)
 bytes of the structure (which, thankfully, seem to be constant)."

While here, fix some typos in the comment.

In-discussion-with: thesjg, vsrinivas

11 years agoFix two wrong sizeof() usages.
Sascha Wildner [Sat, 9 Jun 2012 09:04:18 +0000 (11:04 +0200)]
Fix two wrong sizeof() usages.

It should be taking the size of the variable the pointer points to,
instead of the size of the pointer itself.

11 years agoFix for password truncation when using crypt(3) with DES
Aggelos Economopoulos [Wed, 30 May 2012 14:03:21 +0000 (16:03 +0200)]
Fix for password truncation when using crypt(3) with DES

Passwords containing a 0x80 byte (UTF-8 encoded ones, ASCII and
ISO-8859-* not affected) would get truncated as if a '\0' byte
had been encountered. This could result in some very weak passwords.

Reported-by: Rubin Xu, Joseph Bonneau, Donting Yu (CVE-2012-2143)
11 years agokernel/linux: Fix a wrong cast (introduced in e54488bb).
Sascha Wildner [Wed, 23 May 2012 19:28:32 +0000 (21:28 +0200)]
kernel/linux: Fix a wrong cast (introduced in e54488bb).

11 years agotcp: Ignore TCP_NOPUSH socketopt by default
Sepherosa Ziehau [Thu, 17 May 2012 09:58:41 +0000 (17:58 +0800)]
tcp: Ignore TCP_NOPUSH socketopt by default

For ill optimized programs which misuses this sockopt will cause
unpredicted length of network stalling, if the total sending size
is not TCP sending segment size aligned.

sysctl node net.inet.tcp.disable_nopush controls whether TCP_NOPUSH
will take effect or not

I am not going to fight agaist the stupid programs in the wild.

DragonFly-bug: http://bugs.dragonflybsd.org/issues/2368

This is actually _not_ a bug on our side.

11 years agoUpdate to OpenSSL-1.0.0j.
Peter Avalos [Sun, 13 May 2012 20:22:28 +0000 (13:22 -0700)]
Update to OpenSSL-1.0.0j.

This diverges from master, but I thought it was important to get the
latest updates to the 1.0.0 version that's still in
DragonFly_RELEASE_3_0.

      o Fix DTLS record length checking bug CVE-2012-2333
      o Fix for ASN1 overflow bug CVE-2012-2110
      o Fix for CMS/PKCS#7 MMA CVE-2012-0884
      o Corrected fix for CVE-2011-4619
      o Various DTLS fixes.

11 years agomake upgrade: Now that we have devfs, don't try to remove any /dev/*
Sascha Wildner [Fri, 4 May 2012 19:15:54 +0000 (21:15 +0200)]
make upgrade: Now that we have devfs, don't try to remove any /dev/*

11 years agodevelopment.7: Fix the git documentation URL.
Sascha Wildner [Mon, 7 May 2012 13:02:20 +0000 (15:02 +0200)]
development.7: Fix the git documentation URL.

Reported-by: Joachim de Groot <jdegroot@web.de>
11 years agoHAMMER VFS - Only set B_CLUSTEROK on 64K buffers
Matthew Dillon [Mon, 30 Apr 2012 22:48:32 +0000 (15:48 -0700)]
HAMMER VFS - Only set B_CLUSTEROK on 64K buffers

* Only set B_CLUSETEROK on 64K buffers.  This should fix a fairly rare
  panic related to buffer size mismatches due to the bufdaemon crossing
  the 16K/64K buffer size boundary when clustering buffers.

11 years agokernel - Fix degenerate cluster_write() cases
Matthew Dillon [Mon, 30 Apr 2012 22:44:53 +0000 (15:44 -0700)]
kernel - Fix degenerate cluster_write() cases

* cluster_write() should bdwrite() as a fallback, not bawrite().

  Note that cluster_awrite() always bawrite()'s or equivalent.  The
  DragonFly API split the functions out, so cluster_write() can now
  almost always bdwrite() for the non-clustered case.

* Solves some serious performance and real-time disk space usage issues
  when HAMMER1 was updated to use the cluster calls.  The disk space
  would be recovered by the daily cleanup but the extra writes could
  end up being quite excessive, 25:1 unnecessary writes vs necessary
  writes.

Reported-by: multiple, testing by tuxillo
11 years agokill zombies if the parent set SIG_IGN on SIGCHLD
Matthias Rampke [Tue, 17 Apr 2012 21:33:16 +0000 (23:33 +0200)]
kill zombies if the parent set SIG_IGN on SIGCHLD

fix for http://bugs.dragonflybsd.org/issues/2349

Conflicts:

sys/sys/param.h

11 years agokernel -- ffs: Soft updates locking fixes
Venkatesh Srinivas [Sun, 22 Apr 2012 03:05:06 +0000 (20:05 -0700)]
kernel -- ffs: Soft updates locking fixes

1) Do not take mplock in bioops callbacks; the lock was no longer synchronizing
   against mainline code.

2) Do not hold softdep lock around bwillinode()

3) Take softdep lock in softdep_process_worklist bioops callback. This callback
   was previously using the mplock for synchronization (insufficiently!)

4) Modify process_worklist_item to expect the softdep lock to be held on
   entry and release it at appropriate times.

Prevents a panic seen when running fsstress on a UFS+softdep fs, where fsync
finds a null buffer on vnode trees. This arose from a front-end/back-end
race in softdep_process_worklist.

11 years agoHAMMER VFS - Fix assertion with multi-volume setup
Matthew Dillon [Sun, 1 Apr 2012 01:35:33 +0000 (18:35 -0700)]
HAMMER VFS - Fix assertion with multi-volume setup

* The RB compare code for hammer_io was extracting the volume number
  from the wrong place, creating a situation where duplicate hammer_io's
  would sometimes be inserted in the RB tree (causing an assertion + panic).

* Pull the volume number from a different field.

Reported-by: Mark Saad <nonesuch@longcount.org>
11 years agokernel -- vm_pageout: Handle pages w/ NULL vm_objects on the act/in pageqs.
Venkatesh Srinivas [Sat, 21 Apr 2012 18:40:41 +0000 (11:40 -0700)]
kernel -- vm_pageout: Handle pages w/ NULL vm_objects on the act/in pageqs.

vm_page_unwire could end up putting pages w/ NULL object fields onto the
active or inactive page queues. Allow the active/inactive scans to deal with
these pages rather than panic-ing. This pages can be disposed of normally.

Closes-bug: 2338
Suggested-by: dillon
Reported-by: sephe, JustinS
11 years agomake upgrade: Don't remove /var/heimdal.
Sascha Wildner [Sat, 28 Apr 2012 11:41:10 +0000 (13:41 +0200)]
make upgrade: Don't remove /var/heimdal.

pkgsrc's heimdal package will create it, too.

11 years agomsgport: Implement dropmsg for spin port
Sepherosa Ziehau [Sat, 28 Apr 2012 01:45:54 +0000 (09:45 +0800)]
msgport: Implement dropmsg for spin port

DragonFly-bug: http://bugs.dragonflybsd.org/issues/2354

11 years agopthread_join(3): If the target thread is detached, return EINVAL.
Sascha Wildner [Sat, 21 Apr 2012 10:17:07 +0000 (12:17 +0200)]
pthread_join(3): If the target thread is detached, return EINVAL.

We were returning ESRCH previously, which is wrong, as it indicates
that the thread could not be found. Fix this in both libthread_xu
and libc_r.

See http://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_join.html

----->8-----
[ESRCH]
    No thread could be found corresponding to that specified by the
    given thread ID.

...

[EINVAL]
    The value specified by thread does not refer to a joinable thread.
-----8<-----

12 years agompt(4): Pass INTR_MPSAFE when setting up the interrupt.
Sascha Wildner [Tue, 17 Apr 2012 16:03:15 +0000 (18:03 +0200)]
mpt(4): Pass INTR_MPSAFE when setting up the interrupt.

It's a porting mistake I did back then.

12 years agokernel - Do not use M_USE_INTERRUPT_RESERVE for M_NOWAIT
Matthew Dillon [Sun, 1 Apr 2012 01:33:59 +0000 (18:33 -0700)]
kernel - Do not use M_USE_INTERRUPT_RESERVE for M_NOWAIT

* Redefine M_NOWAIT to not use M_USE_INTERRUPT_RESERVE.  This can result
  in mbuf exhaustion during bursts of mbuf allocations and cause kernel
  kvm expansion to assert and panic.

Reported-by: sephe
12 years agokernel - Fix signal masking race assertion panic w/vkernel
Matthew Dillon [Sun, 1 Apr 2012 01:30:13 +0000 (18:30 -0700)]
kernel - Fix signal masking race assertion panic w/vkernel

* sigsuspend() and pselect() record the old signal mask in order to
  allow an interrupting signal to run its handler before the old mask
  is restored.

* When multiple threads are present a race can ensue where another thread
  changes the signal handler after sigsuspend() or pselect() have interrupted,
  but before they are able to process the signal.

* If the signal is no longer enabled the old signal mask is not restored
  on system call return, resulting in an assertion and panic.

* Fix the problem by checking the flag and restoring the old signal mask
  on return (rather than asserting when the flag is found to be non-zero
  on return).

Reported-by: Venkatesh Srinivas
12 years agopst(4): Add a missing contigfree().
Sascha Wildner [Mon, 9 Apr 2012 02:37:14 +0000 (04:37 +0200)]
pst(4): Add a missing contigfree().

12 years agomps(4): Add a missing kfree().
Sascha Wildner [Mon, 9 Apr 2012 01:31:45 +0000 (03:31 +0200)]
mps(4): Add a missing kfree().

12 years agokernel: Fix building with USERCONFIG but without VISUAL_USERCONFIG.
Sascha Wildner [Sat, 7 Apr 2012 11:15:38 +0000 (13:15 +0200)]
kernel: Fix building with USERCONFIG but without VISUAL_USERCONFIG.

Reported-by: v_2e on users@
12 years agokernel/ufs: Fix compilation without INVARIANTS.
Sascha Wildner [Thu, 5 Apr 2012 17:10:51 +0000 (19:10 +0200)]
kernel/ufs: Fix compilation without INVARIANTS.

12 years agokernel -- ffs: Do not dereference NULL inodes in ffs_sync_scan1.
Venkatesh Srinivas [Fri, 30 Mar 2012 06:33:08 +0000 (23:33 -0700)]
kernel -- ffs: Do not dereference NULL inodes in ffs_sync_scan1.

ffs_sync_scan1 is a fast callback from vmntvnodescan; it is not called
with vnodes locked. It is possible for an ffs_reclaim to have reclaimed
the vnode in question, NULL-ing out ip, without having removed the vnode
from the per-mount list. If we see a NULL inode, return failure from the
fast callback.

12 years agokernel -- FFS: Take softdep lock in softdep_disk_io_initiation.
Venkatesh Srinivas [Mon, 2 Apr 2012 17:02:25 +0000 (10:02 -0700)]
kernel -- FFS: Take softdep lock in softdep_disk_io_initiation.

softdep_disk_io_initiation was using the mplock rather than the softdep
lock to protect the softdep work queue and items on it. Take the softdep
lock and allow it to be taken recursively, so that io_start bioops can
call into other parts of softdep. Prevents softdep completion callback
from racing softdep_disk_io_initiation, remaining panics of 2291.

Eventually the MPLOCK in the bio_ops callback can go away, but that will
require more testing.

Closes-bug: 2291

12 years agokernel -- ffs: Replace softupdates critical section locks with lockmgr.
Venkatesh Srinivas [Wed, 28 Mar 2012 18:09:15 +0000 (11:09 -0700)]
kernel -- ffs: Replace softupdates critical section locks  with lockmgr.

ffs softupdates was using a combination of critical sections and the mplock
to construct its acquire_lock/free_lock/interlocked_sleep primitives.

The softupdates I/O completion callback had a few points where it could block,
causing it to lose the mplock and any critical sections it held. When it did
so, front-end softupdates code would try to grab the lock but panic on seeing
the I/O completion callback in progress. This was not a problem in older
systems, as splx() would prevent the I/O callback from starting while
softdep code was executing.

This patch converts to using hard locks (lockmgr), which are held even while
a thread is blocked.

getdirtybuf(), locking a dirty buffer via BUF_LOCK, was changed to not
deadlock against the I/O completion path; specifically it drops the softdep
lock when its non-blocking attempt to lock a dirty buffer fails. One caller
of getdirtybuf() also required changes to retry locking buffers.

Closes-bug: 2291
Partially-from: FreeBSD r140709
Reported-by: tuxillo, marino, Rumko, vsrinivas
Discussed-with: dillon

12 years agoSync zoneinfo database with tzdata2012c from munnari.oz.au
Sascha Wildner [Mon, 2 Apr 2012 08:21:42 +0000 (10:21 +0200)]
Sync zoneinfo database with tzdata2012c from munnari.oz.au

africa:         8.33 -> 8.35
asia:           8.70 -> 8.73
northamerica:   8.53 -> 8.54

* africa: Morocco 2012 DST from last Sunday in April through last
    Sunday in September.

* asia: Change start of DST in Syria to last Friday in March in
    2012 and (as a guess) forward. Starts and (guessed) ends of
    DST in West Bank and Gaza for 2012. Also add a missing HTML
    directive at the top of the file.

* northamerica: Start and end of DST in Haiti in 2012 according
    to US rules.

12 years agokernel - MFC missing removal of bremfree() call
Matthew Dillon [Sun, 1 Apr 2012 01:18:01 +0000 (18:18 -0700)]
kernel - MFC missing removal of bremfree() call

* buf_daemon*() -> flushbufqueues() had an improper bremfree().

Reported-by: tuxillo
12 years agopcn(4): Add missing braces.
Sascha Wildner [Sat, 31 Mar 2012 02:10:59 +0000 (04:10 +0200)]
pcn(4): Add missing braces.

12 years agolgue(4): Add missing braces and fix indentation.
Sascha Wildner [Sat, 31 Mar 2012 01:46:53 +0000 (03:46 +0200)]
lgue(4): Add missing braces and fix indentation.

It was returning too early in some cases.

While here, add an error message.

12 years agohptiop(4): Add missing braces.
Sascha Wildner [Sat, 31 Mar 2012 01:26:52 +0000 (03:26 +0200)]
hptiop(4): Add missing braces.

12 years agortld: Add a special case in do_dlsym() for TLS stored symbols.
Sascha Wildner [Fri, 2 Mar 2012 09:15:56 +0000 (10:15 +0100)]
rtld: Add a special case in do_dlsym() for TLS stored symbols.

Submitted-by: Markus Pfeiffer <markus.pfeiffer@morphism.de>
Conflicts:

libexec/rtld-elf/rtld.c

12 years agorwhod(8): Prevent clobbering the neighboring field by a wrong cast.
Sascha Wildner [Fri, 30 Mar 2012 16:36:50 +0000 (18:36 +0200)]
rwhod(8): Prevent clobbering the neighboring field by a wrong cast.

The time stamps in the rwhod(8) network datagram and, based on that,
/var/rwho/whod.* spool files are typed as 32bit int and cannot accept
a 64bit time_t.

The old code clobbered the first bytes of the adjacent "hostname"
field, yielding empty hostnames in local rwho(1) and ruptime(1) output.
(Outgoing datagrams to other hosts were not affected.)

Re-code to let the compiler do the proper coercion (well, until 2038).

Submitted-by: Martin Neitzel
Dragonfly-bug: <https://bugs.dragonflybsd.org/issues/2339>

12 years agokernel - Cluster fixes + Enable clustering for HAMMER1
Matthew Dillon [Thu, 22 Mar 2012 23:45:55 +0000 (16:45 -0700)]
kernel - Cluster fixes + Enable clustering for HAMMER1

* Add cluster_awrite(), which replaces vfs_bio_awrite() and has the same
  basic semantics as bawrite().

* Remove vfs_bio_awrite(), which had an odd API that required the buffer
  to be locked but not removed from its queues.

* Make cluster operations work on disk device buffers as well as on
  regular files.

* Add a blkflags argument to getcacheblk(), allowing GETBLK_NOWAIT to
  be passed to it.

* Enhance cluster_wbuild() to support cluster_awrite() by having it take
  an optional bp to incorporate into the cluster.  The caller disposes of
  the bp by calling bawrite() if the cluster_wbuild() code could not use it.

* Certain adjustments to cluster_write() and related code in checking against
  the file EOF to not break when variable block sizes are used.

* Fix a bug in calls made to buf_checkwrite().  The caller is required to
  initiate the I/O if the function returns good (0).  HAMMER1 uses this
  save side effects and blows up if the I/O is then not initiated.

* Enable clustering in HAMMER1 for both data and meta-data.

12 years agokernel - Fix improper BUF_UNLOCK() with spinlock held
Matthew Dillon [Wed, 28 Mar 2012 02:10:14 +0000 (19:10 -0700)]
kernel - Fix improper BUF_UNLOCK() with spinlock held

* Fix improper BUF_UNLOCK()s in the buf daemon threads.  Use a
  marker and rearrange the code to release the spinlock before
  executing BUF_UNLOCK().

12 years agokernel - Improve NFS server error responses when an inode goes away
Matthew Dillon [Fri, 23 Mar 2012 20:38:29 +0000 (13:38 -0700)]
kernel - Improve NFS server error responses when an inode goes away

* When an inode goes away and FHTOVP fails return ESTALE instead of
  what the VFS returned.

* Greatly improves the re-acquisition of files on NFS clients which have
  been ripped out by the server or other clients.

12 years agokernel - Fix improper unlock/relock sequence in HAMMER
Matthew Dillon [Fri, 23 Mar 2012 20:36:27 +0000 (13:36 -0700)]
kernel - Fix improper unlock/relock sequence in HAMMER

* VOP_FSYNC() can be called during a vnode inactivation or reclaim.
  In this case the vnode lock absolutely cannot be released or it
  can create a window of opportunity for another thread that results
  in a panic.

* Fixes a NFS server crash when multiple clients are trying to
  delete/create/write the same file at the same time.

12 years agokernel - Fix bug in SILI, remove debugging in AHCI
Matthew Dillon [Fri, 23 Mar 2012 16:06:57 +0000 (09:06 -0700)]
kernel - Fix bug in SILI, remove debugging in AHCI

* Fix the same unlock/lock sequence bug in the SILI driver that was
  fixed in the AHCI driver.

* Remove a flag that was being added to the service set in AHCI for
  debugging purposes.

12 years agokernel - Fix another AHCI bug
Matthew Dillon [Fri, 23 Mar 2012 08:47:48 +0000 (01:47 -0700)]
kernel - Fix another AHCI bug

* Remove the unlock/lock sequences around the xpt_done() calls.  These
  temporary unlocks create a gap which can allow another interrupt to
  squeeze in and interfere with the interrupt thread that is already
  running, resulting in corruption.

  This bug occurs under very heavy loads, and typically required multiple
  concurrent ops to a SSD to trigger.

* Add additional assertions to catch issues and reorder one of the
  chiploads.

* This is a bit non-optimal, be on the lookout for deadlocks in case it
  turns out that holding the lock is a bad idea.

12 years agokernel - Fix mount refs interactions and umount races
Matthew Dillon [Fri, 23 Mar 2012 04:37:25 +0000 (21:37 -0700)]
kernel - Fix mount refs interactions and umount races

* It is possible for a umount to race other operations on active mount
  point, causing one or the other to deadlock.

* vfs_busy()/vfs_unbusy() now incr/decr mp->mnt_refs.

* cache_findmount() now increments mp->mnt_refs, and add a new API
  function cache_dropmount() which decrements it.

12 years agokernel - Fix three AHCI bugs
Matthew Dillon [Fri, 23 Mar 2012 04:31:31 +0000 (21:31 -0700)]
kernel - Fix three AHCI bugs

* This fixes spurious timeouts which occur on SMP boxes with faster devices
  (such as SSDs or more recent hard drives)

* The global interrupt status register appears to be latched on some parts
  rather than wire-or.  Clearing it after signaling the port threads or
  processing the interrupt can cause interrupts to be lost.

* In cases where it is actually wire-or we may get a double-interrupt,
  but stability is more important here.

* Fix the port signaling code.  The mask was being cleared with the
  port interlock released.  It has to be cleared when the interlock is
  held.

* Reorder the per-port interrupt status register clearing code in two
  places to execute before processing the operation rather than after,
  which may fix another source of lost interrupts.

12 years agokernel - Add workaround for errata #721 on AMD cpus (found by Matt Dillon)
Matthew Dillon [Fri, 23 Mar 2012 22:49:54 +0000 (15:49 -0700)]
kernel - Add workaround for errata #721 on AMD cpus (found by Matt Dillon)

* Official reference for errata 721:

    http://support.amd.com/us/Processor_TechDocs/41322_10h_Rev_Gd.pdf

* This is the cpu bug found by Matthew Dillon, present on all K10 cores
  (so far).  AMD has indicated that the bug is not present on Bulldozer
  cpus.

* The MSR workaround is now reported and programmed during kernel boot.

* No discernable difference in performance was detected running GCC
  with and without the MSR adjustment.

* Verified to have fixed our test case w/GCC.  It no longer seg-faults.

12 years agolibc - Do not allow a stuck syslogd to screw up the entire system
Matthew Dillon [Sat, 24 Mar 2012 00:33:51 +0000 (17:33 -0700)]
libc - Do not allow a stuck syslogd to screw up the entire system

* If syslogd gets stuck the socket buffer will still full forever.
  Only try writing a limited number of times before giving up.

12 years agokernel: msdosfs -- Use -1 rather than 32-bit 0xffffffff in mount().
Venkatesh Srinivas [Mon, 26 Mar 2012 15:59:02 +0000 (08:59 -0700)]
kernel: msdosfs -- Use -1 rather than 32-bit 0xffffffff in mount().

Corrects bug mounting 8GB msdosfs filesystem on x86-64.

Submitted-by: G. Isenmann
12 years agotcp/sack: Prevent invalid SACK option from being processed
Sepherosa Ziehau [Mon, 26 Mar 2012 03:36:53 +0000 (11:36 +0800)]
tcp/sack: Prevent invalid SACK option from being processed

If the received SACK blocks contain one invalid SACK block,
discard the whole SACK blocks.