freebsd.git
9 years agoAdd an UPDATING entry and warning about the change in r274807 to help users
brooks [Tue, 16 Dec 2014 20:45:17 +0000 (20:45 +0000)]
Add an UPDATING entry and warning about the change in r274807 to help users
transition to the new behavior.

Discussed with: jmallett
Sponsored by: DARPA, AFRL

9 years agosed: Bounds check the file path used in the 'w' command.
pfg [Tue, 16 Dec 2014 20:26:11 +0000 (20:26 +0000)]
sed: Bounds check the file path used in the 'w' command.

Modified version of a diff from Sebastien Marie to prevent a crash found
with the afl fuzzer.

Obtained from: OpenBSD (CVS Rev. 1.37)
MFC after: 1 week

9 years agoThe iret instruction may generate #np and #ss fault, besides #gp.
kib [Tue, 16 Dec 2014 18:28:33 +0000 (18:28 +0000)]
The iret instruction may generate #np and #ss fault, besides #gp.
When returning to usermode, the handler for that exceptions is also
executed with wrong gs base.  Handle all three possible faults in the
same way, checking for iret fault, and performing full iret.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

9 years agoMake NanoBSD source-able from other scripts.
will [Tue, 16 Dec 2014 17:59:05 +0000 (17:59 +0000)]
Make NanoBSD source-able from other scripts.

Summary:
This change converts NanoBSD into a two-script bundle.
- defaults.sh contains all non-CLI code.  Most NanoBSD code is moved into
  this file.
- nanobsd.sh now consists just of a command line interface that calls into
  functions in defaults.sh.

Test Plan: Run NanoBSD using a previously-working configuration.

Reviewers: imp

Reviewed By: imp

Differential Revision: https://reviews.freebsd.org/D1321

9 years agoCopy elftoolchain readelf from vendor branch
emaste [Tue, 16 Dec 2014 16:23:54 +0000 (16:23 +0000)]
Copy elftoolchain readelf from vendor branch

9 years agoAdd ability to not specify a zone identifier twice, when both source and
ae [Tue, 16 Dec 2014 14:59:20 +0000 (14:59 +0000)]
Add ability to not specify a zone identifier twice, when both source and
destination addresses are specified.
For example:
# ping6 -S fe80::1%ix0 ff02::1
or
# ping6 -S fe80::1 fe80::2%ix0

Obtained from: Yandex LLC
Sponsored by: Yandex LLC

9 years agoAdd tests for pw -N
brd [Tue, 16 Dec 2014 14:50:33 +0000 (14:50 +0000)]
Add tests for pw -N

PR: 150449
Submitted by: Robert O'Neil <oneil.rs@gmail.com>
Approved by: will

9 years agoAdd missed break.
kib [Tue, 16 Dec 2014 09:49:07 +0000 (09:49 +0000)]
Add missed break.

CID: 1258587
Sponsored by: The FreeBSD Foundation
MFC after: 20 days

9 years agoAdd missed break.
kib [Tue, 16 Dec 2014 09:48:23 +0000 (09:48 +0000)]
Add missed break.

CID: 1258586
Sponsored by: The FreeBSD Foundation
MFC after: 4 days

9 years agoRename cpack*() to CMPLX*().
ed [Tue, 16 Dec 2014 09:21:56 +0000 (09:21 +0000)]
Rename cpack*() to CMPLX*().

The C11 standard introduced a set of macros (CMPLX, CMPLXF, CMPLXL) that
can be used to construct complex numbers from a pair of real and
imaginary numbers. Unfortunately, they require some compiler support,
which is why we only define them for Clang and GCC>=4.7.

The cpack() function in libm performs the same task as CMPLX(), but
cannot be used to generate compile-time constants. This means that all
invocations of cpack() can safely be replaced by C11's CMPLX(). To keep
the code building with GCC 4.2, provide copies of CMPLX() that can at
least be used to generate run-time complex numbers.

This makes it easier to build some of the functions outside of libm.

9 years agosbin/shutdown: Support time units as in 'shutdown -r +5sec'
gleb [Tue, 16 Dec 2014 08:29:02 +0000 (08:29 +0000)]
sbin/shutdown: Support time units as in 'shutdown -r +5sec'

Units supported: s, sec, m, min, h, hour.

Differential Revision: https://reviews.freebsd.org/D1272

9 years agoFor level triggered interrupts clear the PIC IRR bit when the interrupt pin
neel [Tue, 16 Dec 2014 06:33:57 +0000 (06:33 +0000)]
For level triggered interrupts clear the PIC IRR bit when the interrupt pin
is deasserted. Prior to this change each assertion on a level triggered irq
pin resulted in two interrupts being delivered to the CPU.

Differential Revision: https://reviews.freebsd.org/D1310
Reviewed by: tychon
MFC after: 1 week

9 years agoFix a bug introdiced in r217548. According to NS DP83815 data
yongari [Tue, 16 Dec 2014 06:13:30 +0000 (06:13 +0000)]
Fix a bug introdiced in r217548.  According to NS DP83815 data
sheet, RX filter should be disabled before programming.
Previously it was clearing wrong bits so RX filter was not
disabled in RX filter configuration.

Reported by: brad@OpenBSD.org

9 years agoUse standard BSD license disclaimer text
emaste [Mon, 15 Dec 2014 22:20:14 +0000 (22:20 +0000)]
Use standard BSD license disclaimer text

Approved by: benno, nwhitehorn

9 years agoProperly sort Xr to silence mandoc warnings.
dchagin [Mon, 15 Dec 2014 20:48:06 +0000 (20:48 +0000)]
Properly sort Xr to silence mandoc warnings.

Differential Revision: https://reviews.freebsd.org/D1314
Reviewed by: wblock
MFC after: 1 Month

9 years agoMFV r275784:
delphij [Mon, 15 Dec 2014 18:28:22 +0000 (18:28 +0000)]
MFV r275784:

Plug a memory leak in libzfs.  In zfs_iter_bookmarks, an nvlist is allocated
before calling lzc_get_bookmarks, which allocates the nvlist again (and
overwrites the pointer to previously allocated list).

Illumos issue:
    5427 memory leak in libzfs when doing rollback

MFC after: 2 weeks

9 years agoMFV r275783:
delphij [Mon, 15 Dec 2014 18:22:45 +0000 (18:22 +0000)]
MFV r275783:

Convert ARC flags to use enum.  Previously, public flags are defined in
arc.h and private flags are defined in arc.c which can lead to confusion
and programming errors.

Consistently use 'hdr' (when referencing arc_buf_hdr_t) instead of 'buf'
or 'ab' because arc_buf_t are often named 'buf' as well.

Illumos issue:
    5369 arc flags should be an enum
    5370 consistent arc_buf_hdr_t naming scheme

MFC after: 2 weeks

9 years agoCorrect elftoolchain strip(1) memory size calculation
emaste [Mon, 15 Dec 2014 18:18:57 +0000 (18:18 +0000)]
Correct elftoolchain strip(1) memory size calculation

Calculate the segment's memory size (p_memsz) using the virtual
addresses, not the file offsets. Otherwise padding preceeding SHT_NOBITS
sections may be excluded from the calculation, resulting in a segment
that is too small.

PR: 195653
Sponsored by: The FreeBSD Foundation

9 years agoCheck for SS_NBIO in so->so_state instead of sb->sb_flags in
jhb [Mon, 15 Dec 2014 17:52:08 +0000 (17:52 +0000)]
Check for SS_NBIO in so->so_state instead of sb->sb_flags in
soreceive_stream().

Differential Revision: https://reviews.freebsd.org/D1299
Reviewed by: bz, gnn
MFC after: 1 week

9 years agoMarkup fixes for kqueue(2), no content changes.
kib [Mon, 15 Dec 2014 14:58:10 +0000 (14:58 +0000)]
Markup fixes for kqueue(2), no content changes.

Reviewed by: brueffer (previous version)
Sponsored by: The FreeBSD Foundation
MFC after: 3 days

9 years agoFix incorrect type of "invalids" argument in __iconv() prototype.
kuriyama [Mon, 15 Dec 2014 14:36:04 +0000 (14:36 +0000)]
Fix incorrect type of "invalids" argument in __iconv() prototype.

9 years agoRemove empty generated file upon gperf failure
emaste [Mon, 15 Dec 2014 14:25:42 +0000 (14:25 +0000)]
Remove empty generated file upon gperf failure

Prior to this change the build could fail as follows, if gperf is not
available (or fails):

  - make(1) stops due to the gperf error, but an empty target file
    (cfns.h) is still created
  - the empty cfns.h is newer than the source cfns.gperf so it is not
    regenerated on subsequent builds
  - the gcc build fails (undefined reference to libc_name_p)

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

9 years agoFix typo.
br [Mon, 15 Dec 2014 12:15:18 +0000 (12:15 +0000)]
Fix typo.

9 years agoAdd a facility for non-init process to declare itself the reaper of
kib [Mon, 15 Dec 2014 12:01:42 +0000 (12:01 +0000)]
Add a facility for non-init process to declare itself the reaper of
the orphaned descendants.  Base of the API is modelled after the same
feature from the DragonFlyBSD.

Requested by: bapt
Reviewed by: jilles (previous version)
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 3 weeks

9 years agoFollow r275792 eliminating fdt_data_verify().
br [Mon, 15 Dec 2014 11:57:39 +0000 (11:57 +0000)]
Follow r275792 eliminating fdt_data_verify().

9 years agoEliminate fdt_data_verify(). The verification it proceed is wrong
br [Mon, 15 Dec 2014 09:40:25 +0000 (09:40 +0000)]
Eliminate fdt_data_verify(). The verification it proceed is wrong
disallowing us to encode 64-bit register numbers.

Discussed with: nwhitehorn, andrew

9 years agoRegenerate usb.conf .
hselasky [Mon, 15 Dec 2014 09:35:46 +0000 (09:35 +0000)]
Regenerate usb.conf .

MFC after: 1 week

9 years agoResolve USB driver identification conflict.
hselasky [Mon, 15 Dec 2014 09:23:40 +0000 (09:23 +0000)]
Resolve USB driver identification conflict.

Reported by: Anish Mistry <amistry@am-productions.biz>
MFC after: 1 week

9 years agoMFV r275551:
delphij [Mon, 15 Dec 2014 07:52:23 +0000 (07:52 +0000)]
MFV r275551:

Remove "dbuf phys" db->db_data pointer aliases.

Use function accessors that cast db->db_data to the appropriate
"phys" type, removing the need for clients of the dmu buf user
API to keep properly typed pointer aliases to db->db_data in order
to conveniently access their data.

sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_leaf.c:
        In zap_leaf() and zap_leaf_byteswap, now that the pointer alias
        field l_phys has been removed, use the db_data field in an on
        stack dmu_buf_t to point to the leaf's phys data.

sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c:
        Remove the db_user_data_ptr_ptr field from dbuf and all logic
        to maintain it.

sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dbuf.h:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu.h:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dir.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sa.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c:
        Modify the DMU buf user API to remove the ability to specify
        a db_data aliasing pointer (db_user_data_ptr_ptr).

cddl/contrib/opensolaris/cmd/zdb/zdb.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_diff.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_objset.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_traverse.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_tx.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_bookmark.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_deadlist.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_deleg.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_destroy.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dir.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_prop.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_synctask.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_userhold.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sa.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_history.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_leaf.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_dataset.h:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_dir.h:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap_impl.h:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap_leaf.h:
        Create and use the new "phys data" accessor functions
        dsl_dir_phys(), dsl_dataset_phys(), zap_m_phys(),
        zap_f_phys(), and zap_leaf_phys().

sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_dataset.h:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_dir.h:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap_impl.h:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap_leaf.h:
        Remove now unused "phys pointer" aliases to db->db_data
        from clients of the DMU buf user API.

Illumos issue:
    5314 Remove "dbuf phys" db->db_data pointer aliases in ZFS

MFC after: 2 weeks

9 years agoMFV r275550:
delphij [Mon, 15 Dec 2014 05:10:55 +0000 (05:10 +0000)]
MFV r275550:

In addition to r273158, make the code in spa_sync() that checks if the
current TXG is a no-op TXG less fragile.

Illumos issue:
    5347 idle pool may run itself out of space

MFC after: 2 weeks

9 years agoMFV r275549:
delphij [Mon, 15 Dec 2014 04:51:36 +0000 (04:51 +0000)]
MFV r275549:

Add a loader tunable, vfs.zfs.arc_meta_min, which controls how much metadata
ZFS should keep in ARC at minimum.

In arc_evict(), when doing recycle, take more factors into account by
applying the following policy:

  1. If no evictable data, evict metadata;
  2. If no evictable metadata, evict data;
  3. If we hit arc_meta_limit, evict metadata;
  4. If we haven't hit arc_meta_min, evict data;
  5* (Illumos only, not present in new FreeBSD code, yet) evict the oldest
     cached element from data and metadata.
     (FreeBSD) evict the data type specified by caller, which is the
     existing behavior.

Note that because of our splitted locks (implemented in r205231 to improve
scalability by reducing lock contention), implementing the fifth Illumos
behavior will not be cheap, so for now just implement the 1-4 and fall back
to current behavior for 5.

Illumos issue:
    5368 ARC should cache more metadata

MFC after: 2 months (assuming we didn't found better solution)

9 years agoMove ofw_cpu.c to sys/dev/ofw so that it can be used by other
rpaulo [Sun, 14 Dec 2014 22:41:08 +0000 (22:41 +0000)]
Move ofw_cpu.c to sys/dev/ofw so that it can be used by other
architectures.

Differential Revision: https://reviews.freebsd.org/D1307
Reviewed by: jhibbits

9 years agoUpdate clang patch for r275759 to use correct test cases.
dim [Sun, 14 Dec 2014 18:16:49 +0000 (18:16 +0000)]
Update clang patch for r275759 to use correct test cases.

9 years agoAdd a vigr(8) utility which does for /etc/group what vipw(8) does for
des [Sun, 14 Dec 2014 16:40:46 +0000 (16:40 +0000)]
Add a vigr(8) utility which does for /etc/group what vipw(8) does for
/etc/master.passwd.

9 years agosh: Make sure output suitable as shell input is also printable.
jilles [Sun, 14 Dec 2014 16:26:19 +0000 (16:26 +0000)]
sh: Make sure output suitable as shell input is also printable.

Commands like 'export -p', 'set' and 'trap', and tracing enabled via 'set
-x' generate output suitable as shell input by adding quotes as necessary.

If there are control characters other than newline or invalid UTF-8
sequences, use $'...' and \OOO to display them safely.

The resulting output is not parsable by a strict POSIX.1-2008 shell but sh
from FreeBSD 9.0 and newer and many other shells can parse it.

9 years agoClean up, reindent, add a special case for NIS / LDAP line
des [Sun, 14 Dec 2014 16:17:48 +0000 (16:17 +0000)]
Clean up, reindent, add a special case for NIS / LDAP line

MFC after: 1 week

9 years agoAdd clang patch corresponding to r275759.
dim [Sun, 14 Dec 2014 13:40:42 +0000 (13:40 +0000)]
Add clang patch corresponding to r275759.

9 years agoPull in r221170 from upstream clang trunk (by Roman Divacky):
dim [Sun, 14 Dec 2014 13:38:10 +0000 (13:38 +0000)]
Pull in r221170 from upstream clang trunk (by Roman Divacky):

  Implement vaarg lowering for ppc32. Lowering of scalars and
  aggregates is supported. Complex numbers are not.

This adds va_args support for PowerPC (32 bit) to clang.

Reviewed by: jhibbits
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D1308

9 years agoUpdate patch-r274286-llvm-r201784-asm-dollar.diff, so
dim [Sun, 14 Dec 2014 13:32:14 +0000 (13:32 +0000)]
Update patch-r274286-llvm-r201784-asm-dollar.diff, so
test/MC/AsmParser/macros.s is properly deleted when patching.

9 years agoFix bug that made automount(8) never unmount stale autofs(5) mounts,
trasz [Sun, 14 Dec 2014 10:49:22 +0000 (10:49 +0000)]
Fix bug that made automount(8) never unmount stale autofs(5) mounts,
ie mounts for entries that were there in auto_master(5), and then
got removed.

MFC after: 1 month
Sponsored by: The FreeBSD Foundation

9 years agoFix spurious "child process X terminated with exit status 1" messages
trasz [Sun, 14 Dec 2014 10:37:17 +0000 (10:37 +0000)]
Fix spurious "child process X terminated with exit status 1" messages
from automountd(8).

MFC after: 1 month
Sponsored by: The FreeBSD Foundation

9 years agoFix gcc build.
kib [Sun, 14 Dec 2014 08:43:13 +0000 (08:43 +0000)]
Fix gcc build.

Sponsored by: The FreeBSD Foundation
MFC after: 13 days

9 years agoFix quick_exit(3) manual page to match reality - the status was missing.
trasz [Sat, 13 Dec 2014 21:13:28 +0000 (21:13 +0000)]
Fix quick_exit(3) manual page to match reality - the status was missing.

MFC after: 1 month
Sponsored by: The FreeBSD Foundation

9 years agoAdd _NEW flag to mtx(9), sx(9), rmlock(9) and rwlock(9).
dchagin [Sat, 13 Dec 2014 21:00:10 +0000 (21:00 +0000)]
Add _NEW flag to mtx(9), sx(9), rmlock(9) and rwlock(9).
A _NEW flag passed to _init_flags() to avoid check for double-init.

Differential Revision: https://reviews.freebsd.org/D1208
Reviewed by: jhb, wblock
MFC after: 1 Month

9 years agoMFV r247174:
delphij [Sat, 13 Dec 2014 19:17:28 +0000 (19:17 +0000)]
MFV r247174:

Expose arc_meta_limit, et al via kstats.

Note that as a result, vfs.zfs.arc_meta_used is removed.
The existing vfs.zfs.arc_meta_limit sysctl/tunable is retained
with a SYSCTL_PROC wrapper.

Illumos ZFS issues:
    3561 arc_meta_limit should be exposed via kstats

Relnotes: yes
MFC after: 2 weeks

9 years agoUpdate llvm patches for r274286 and r275633 so all the tests will pass.
dim [Sat, 13 Dec 2014 18:54:46 +0000 (18:54 +0000)]
Update llvm patches for r274286 and r275633 so all the tests will pass.

9 years agoFix markup.
trasz [Sat, 13 Dec 2014 17:14:35 +0000 (17:14 +0000)]
Fix markup.

MFC after: 1 month
Sponsored by: The FreeBSD Foundation

9 years agoAdd facility to stop all userspace processes. The supposed use of the
kib [Sat, 13 Dec 2014 16:18:29 +0000 (16:18 +0000)]
Add facility to stop all userspace processes.  The supposed use of the
feature is to quisce the system before suspend.

Stop is implemented by reusing the thread_single(9) with the special
mode SINGLE_ALLPROC.  SINGLE_ALLPROC differs from the existing
single-threading modes by allowing (requiring) caller to operate on
other process.  Interruptible sleeps for !TDF_SBDRY threads are
suspended like SIGSTOP does it, instead of aborting the sleep, like
SINGLE_NO_EXIT, to avoid spurious EINTRs on resume.

Provide debugging sysctl debug.stop_all_proc, which causes total stop
and suspends syncer, while waiting for variable reset for resume.  It
is used for debugging; should be removed after the real use of the
interface is added.

In collaboration with: pho
Discussed with: avg
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks

9 years agoOnly sleep interruptible while waiting for suspension end when
kib [Sat, 13 Dec 2014 16:07:01 +0000 (16:07 +0000)]
Only sleep interruptible while waiting for suspension end when
filesystem specified VFCF_SBDRY flag, i.e. for NFS.

There are two issues with the sleeps.  First, applications may get
unexpected EINTR from the disk i/o syscalls.  Second, interruptible
sleep allows the stop of the process, and since mount point is
referenced while thread sleeps, unmount cannot free mount point
structure' memory, blocking unmount indefinitely.

Even for NFS, it is probably only reasonable to enable PCATCH for intr
mounts, but this information is currently not available at VFS level.

Reported and tested by: pho (previous version)
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

9 years agoThe vinactive() call in vgonel() may start writes for the dirty pages,
kib [Sat, 13 Dec 2014 16:02:37 +0000 (16:02 +0000)]
The vinactive() call in vgonel() may start writes for the dirty pages,
creating delayed write buffers belonging to the reclaimed vnode.  Put
the buffer cleanup code after inactivation.

Add asserts that ensure that buffer queues are empty and add BO_DEAD
flag for bufobj to check that no buffers are added after the cleanup.
BO_DEAD is only used by INVARIANTS-enabled kernels.

Reported and tested by: pho (previous version)
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

9 years agoMFV r275548:
delphij [Sat, 13 Dec 2014 02:08:18 +0000 (02:08 +0000)]
MFV r275548:

Verify that the block pointer is structurally valid, before attempting to
read it in.  It can only be invalid in the case of a ZFS bug, but this
change will help identify such bugs in a more transparent way, by
panic'ing with a relevant message, rather than indexing off the end of an
array or something.

Illumos issue:
    5349 verify that block pointer is plausible before reading

MFC after: 2 weeks

9 years agoMFV r275547:
delphij [Sat, 13 Dec 2014 01:55:02 +0000 (01:55 +0000)]
MFV r275547:

Port Illumos 'zfs allow' examples update.  While I'm there also fix
a typo.

Illumos issue:
    4181 zfs(1m): 'zfs allow' examples in the man page are outdated

MFC after: 2 weeks

9 years agoMFV r275546:
delphij [Sat, 13 Dec 2014 01:39:24 +0000 (01:39 +0000)]
MFV r275546:

Reduce scrub activities when system there is enough dirty data, namely when
dirty data is more than zfs_vdev_async_write_active_min_dirty_percent (once
we start to increase the number of concurrent async writes).

While there also correct rounding error which would make scrub end up
pausing for (zfs_txg_timeout + 1) seconds instead of the desired
zfs_txg_timeout seconds.

Illumos issue:
    5351 scrub goes for an extra second each txg
    5352 scrub should pause when there is some dirty data

MFC after: 2 weeks

9 years agoMFV r275545:
delphij [Sat, 13 Dec 2014 01:26:06 +0000 (01:26 +0000)]
MFV r275545:

If zio_checksum_error() returns other than ECKSUM (e.g. EINVAL), it does not
fill in the "zio_bad_cksum_t *info" parameter. Caller should not attempt to
use it in this case.

Illumos issue:
    5348 zio_checksum_error() only fills in info if ECKSUM

MFC after: 2 weeks

9 years agoMFV r275544:
delphij [Sat, 13 Dec 2014 01:18:23 +0000 (01:18 +0000)]
MFV r275544:

Clean up some duplicated code in dnode_sync() around freeing spill blocks.

Illumos issue:
    5350 clean up code in dnode_sync()

MFC after: 2 weeks

9 years agoMFV r275543:
delphij [Sat, 13 Dec 2014 01:14:59 +0000 (01:14 +0000)]
MFV r275543:

Remove always true tests for ds->ds_phys' presence.

Clean up assertions in dsl_dataset_disown.

Remove unreachable code in dsl_dataset_disown().

Illumos issue:
    5310 Remove always true tests for non-NULL ds->ds_phys

MFC after: 2 weeks

9 years agoMFV r275542:
delphij [Sat, 13 Dec 2014 01:10:17 +0000 (01:10 +0000)]
MFV r275542:

If a dnode has a spill block and there is an error while accessing
a data block then traverse_dnode() loses information about that error
and returns a status of visiting the spill block.

This issue is discovered by Spectra Logic.

Illumos issue:
    5311 traverse_dnode may report success when it should not

Original author: gibbs
MFC after: 2 weeks

9 years agoMove KTR_CXGBE from t4_tom.h to adapter.h so that the base if_cxgbe
np [Fri, 12 Dec 2014 21:54:59 +0000 (21:54 +0000)]
Move KTR_CXGBE from t4_tom.h to adapter.h so that the base if_cxgbe
code can use it too.

MFC after: 1 week

9 years agoAdd some new modes to OpenCrypto. These modes are AES-ICM (can be used
jmg [Fri, 12 Dec 2014 19:56:36 +0000 (19:56 +0000)]
Add some new modes to OpenCrypto.  These modes are AES-ICM (can be used
for counter mode), and AES-GCM.  Both of these modes have been added to
the aesni module.

Included is a set of tests to validate that the software and aesni
module calculate the correct values.  These use the NIST KAT test
vectors.  To run the test, you will need to install a soon to be
committed port, nist-kat that will install the vectors.  Using a port
is necessary as the test vectors are around 25MB.

All the man pages were updated.  I have added a new man page, crypto.7,
which includes a description of how to use each mode.  All the new modes
and some other AES modes are present.  It would be good for someone
else to go through and document the other modes.

A new ioctl was added to support AEAD modes which AES-GCM is one of them.
Without this ioctl, it is not possible to test AEAD modes from userland.

Add a timing safe bcmp for use to compare MACs.  Previously we were using
bcmp which could leak timing info and result in the ability to forge
messages.

Add a minor optimization to the aesni module so that single segment
mbufs don't get copied and instead are updated in place.  The aesni
module needs to be updated to support blocked IO so segmented mbufs
don't have to be copied.

We require that the IV be specified for all calls for both GCM and ICM.
This is to ensure proper use of these functions.

Obtained from: p4: //depot/projects/opencrypto
Relnotes: yes
Sponsored by: FreeBSD Foundation
Sponsored by: NetGate

9 years agoFix typo in comments.
imp [Fri, 12 Dec 2014 18:54:31 +0000 (18:54 +0000)]
Fix typo in comments.

Noticed by: brooks@

9 years agoProvide a dead version of if_get_counter.
jhb [Fri, 12 Dec 2014 16:10:42 +0000 (16:10 +0000)]
Provide a dead version of if_get_counter.

Submitted by: glebius
Reported by: np

9 years agoIncrease the buffer size to keep the list of programm names when
ae [Fri, 12 Dec 2014 11:29:54 +0000 (11:29 +0000)]
Increase the buffer size to keep the list of programm names when
parsing programm specification. It is safe to not check out of bounds
access, because !isprint(p[i]) check will stop reading, when '\0'
character will be read from the input string.

Obtained from: Yandex LLC
MFC after: 1 week
Sponsored by: Yandex LLC

9 years agoAdd virtio bus 'poll' method allowing us to inform backend we are
br [Fri, 12 Dec 2014 11:19:10 +0000 (11:19 +0000)]
Add virtio bus 'poll' method allowing us to inform backend we are
going to poll virtqueue.

Use on BERI soft-core to invalidate cpu caches.

Reviewed by: bryanv
Sponsored by: DARPA, AFRL

9 years agoFor architectures where time_t is wide enough, in particular, 64bit
kib [Fri, 12 Dec 2014 09:37:18 +0000 (09:37 +0000)]
For architectures where time_t is wide enough, in particular, 64bit
platforms, avoid overflow after year 2038 in clock_ct_to_ts().

PR: 195868
Reviewed by: bde
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

9 years agoThe size of the first level reference count table is given in terms of the
marcel [Fri, 12 Dec 2014 06:13:31 +0000 (06:13 +0000)]
The size of the first level reference count table is given in terms of the
number of clusters it occupies. It's not the number of entries in the table,
as it is for the L1 cluster table.

For small images, the two are the same. With the unit tests based on small
images, this change has therefore no effect on the unit test.  For larger
images (like the FreeBSD 10.1-RELEASE image), this gives a discrepancy that
actually shows up when running "qemu-img check".

Bump the version number of mkimg.

While here, fix a white-space bug.

MFC after: 1 week

9 years agoAdd new PowerPC relocations to binutils
jhibbits [Fri, 12 Dec 2014 03:58:51 +0000 (03:58 +0000)]
Add new PowerPC relocations to binutils

Summary:
LLVM/Clang generates relocations that our binutils doesn't understand, but newer
binutils does.  I got permission from the author of a series of patches to
relicense them as GPLv2 for use in FreeBSD.  The upstream git hashes are:

ac2df442ac7901f00af15b272fc48b594b433713
2b95367962dc14f69d3c338c4d54195266e2e169
102890f04c44b64cf5cef4588267dd9f24086ac7
b7fcf6f6bb53b5027e111107f5416769cb9a5798
1d483afedd5a628dc84fb58d1d570f79fdfbfa7b
90aecf7a80c1cefeb45fc10a6cd02c8338e34b4c
3a71aa26df2a372a58e9c11ef9ba51fd0e83320a
727fc41e077139570ea8b8ddfd6c546b2a55627c

With the import of clang 3.5, and a few backported patches, we should be able to
move powerpc and powerpc64 to clang-as-cc soon.

Test Plan: Passes make tinderbox, so no regressions.  Binaries built with clang
run on powerpc64.

Reviewers: #committers, dim

Reviewed By: dim

Differential Revision: https://reviews.freebsd.org/D1297

Obtained from: Alan Modra, upstream binutils-gdb git
MFC after: 3 weeks
Relnotes: yes

9 years agoDo not count security policy violation twice.
ae [Thu, 11 Dec 2014 19:20:13 +0000 (19:20 +0000)]
Do not count security policy violation twice.
ipsec*_in_reject() do this by their own.

Obtained from: Yandex LLC
Sponsored by: Yandex LLC

9 years agoUse ipsec6_in_reject() to simplify ip6_ipsec_fwd() and ip6_ipsec_input().
ae [Thu, 11 Dec 2014 19:09:57 +0000 (19:09 +0000)]
Use ipsec6_in_reject() to simplify ip6_ipsec_fwd() and ip6_ipsec_input().
ipsec6_in_reject() does the same things, also it counts policy violation
errors.

Do IPSEC check in the ip6_forward() after addresses checks.
Also use ip6_ipsec_fwd() to make code similar to IPv4 implementation.

Obtained from: Yandex LLC
Sponsored by: Yandex LLC

9 years agoAdd myself.
rpaulo [Thu, 11 Dec 2014 18:58:22 +0000 (18:58 +0000)]
Add myself.

9 years agoUse ipsec4_in_reject() to simplify ip_ipsec_fwd() and ip_ipsec_input().
ae [Thu, 11 Dec 2014 18:55:54 +0000 (18:55 +0000)]
Use ipsec4_in_reject() to simplify ip_ipsec_fwd() and ip_ipsec_input().
ipsec4_in_reject() does the same things, also it counts policy violation
errors.

Obtained from: Yandex LLC
Sponsored by: Yandex LLC

9 years agoTreat errors when retrieving security policy as policy violation.
ae [Thu, 11 Dec 2014 18:46:11 +0000 (18:46 +0000)]
Treat errors when retrieving security policy as policy violation.

Obtained from: Yandex LLC
Sponsored by: Yandex LLC

9 years agoInitialize error variable.
ae [Thu, 11 Dec 2014 18:40:56 +0000 (18:40 +0000)]
Initialize error variable.

Obtained from: Yandex LLC
Sponsored by: Yandex LLC

9 years agoRemove flag/flags argument from the following functions:
ae [Thu, 11 Dec 2014 18:35:34 +0000 (18:35 +0000)]
Remove flag/flags argument from the following functions:
 ipsec_getpolicybyaddr()
 ipsec4_checkpolicy()
 ip_ipsec_output()
 ip6_ipsec_output()

The only flag used here was IP_FORWARDING.

Obtained from: Yandex LLC
Sponsored by: Yandex LLC

9 years agohandle "Kana" and "Eisu" keys on Apple Wireless Keyboard (JIS)
emax [Thu, 11 Dec 2014 18:08:54 +0000 (18:08 +0000)]
handle "Kana" and "Eisu" keys on Apple Wireless Keyboard (JIS)

PR: 187470
Submitted by: naito.yuichiro
MFC after: 1 week

9 years agoRemove flags and tunalready arguments from ipsec4_process_packet()
ae [Thu, 11 Dec 2014 17:34:49 +0000 (17:34 +0000)]
Remove flags and tunalready arguments from ipsec4_process_packet()
and make its prototype similar to ipsec6_process_packet.
The flags argument isn't used here, tunalready is always zero.

Obtained from: Yandex LLC
Sponsored by: Yandex LLC

9 years agoRemove now unused mtag argument from ipsec*_common_input_cb.
ae [Thu, 11 Dec 2014 17:14:49 +0000 (17:14 +0000)]
Remove now unused mtag argument from ipsec*_common_input_cb.

Obtained from: Yandex LLC
Sponsored by: Yandex LLC

9 years agoRemove code related to PACKET_TAG_IPSEC_IN_CRYPTO_DONE mbuf tag.
ae [Thu, 11 Dec 2014 17:07:21 +0000 (17:07 +0000)]
Remove code related to PACKET_TAG_IPSEC_IN_CRYPTO_DONE mbuf tag.
It isn't used in FreeBSD.

Obtained from: Yandex LLC
Sponsored by: Yandex LLC

9 years agoRemove unused mtag variable.
ae [Thu, 11 Dec 2014 17:01:53 +0000 (17:01 +0000)]
Remove unused mtag variable.

Obtained from: Yandex LLC
Sponsored by: Yandex LLC

9 years agoMove ip_ipsec_fwd() from ip_input() into ip_forward().
ae [Thu, 11 Dec 2014 16:53:29 +0000 (16:53 +0000)]
Move ip_ipsec_fwd() from ip_input() into ip_forward().

Remove check for presence PACKET_TAG_IPSEC_IN_DONE mbuf tag from
ip_ipsec_fwd(). PACKET_TAG_IPSEC_IN_DONE tag means that packet is
already handled by IPSEC code. This means that before IPSEC processing
it was destined to our address and security policy was checked in
the ip_ipsec_input(). After IPSEC processing packet has new IP
addresses and destination address isn't our own. So, anyway we can't
check security policy from the mbuf tag, because it corresponds
to different addresses.

We should check security policy that corresponds to packet
attributes in both cases - when it has a mbuf tag and when it has not.

Obtained from: Yandex LLC
Sponsored by: Yandex LLC

9 years agoRemove PACKET_TAG_IPSEC_IN_DONE mbuf tag lookup and usage of its
ae [Thu, 11 Dec 2014 14:58:55 +0000 (14:58 +0000)]
Remove PACKET_TAG_IPSEC_IN_DONE mbuf tag lookup and usage of its
security policy. The changed block of code in ip*_ipsec_input() is
called when packet has ESP/AH header. Presence of
PACKET_TAG_IPSEC_IN_DONE mbuf tag in the same time means that
packet was already handled by IPSEC and reinjected in the netisr,
and it has another ESP/AH headers (encrypted twice?).
Since it was already processed by IPSEC code, the AH/ESP headers
was already stripped (and probably outer IP header was stripped too)
and security policy from the tdb_ident was applied to those headers.
It is incorrect to apply this security policy to current headers.

Also make ip_ipsec_input() prototype similar to ip6_ipsec_input().

Obtained from: Yandex LLC
Sponsored by: Yandex LLC

9 years agoRemove check for presence of PACKET_TAG_IPSEC_PENDING_TDB and
ae [Thu, 11 Dec 2014 14:43:44 +0000 (14:43 +0000)]
Remove check for presence of PACKET_TAG_IPSEC_PENDING_TDB and
PACKET_TAG_IPSEC_OUT_CRYPTO_NEEDED mbuf tags. They aren't used in FreeBSD.

Instead check presence of PACKET_TAG_IPSEC_OUT_DONE mbuf tag. If it
is found, bypass security policy lookup as described in the comment.

PACKET_TAG_IPSEC_OUT_DONE tag added to mbuf when IPSEC code finishes
ESP/AH processing. Since it was already finished, this means the security
policy placed in the tdb_ident was already checked. And there is no reason
to check it again here.

Obtained from: Yandex LLC
Sponsored by: Yandex LLC

9 years agoMake sure callbacks being freed are not pending when the
hselasky [Thu, 11 Dec 2014 10:47:50 +0000 (10:47 +0000)]
Make sure callbacks being freed are not pending when the
"mlx4_en_deactivate_cq()" function returns.

MFC after: 1 week
Sponsored by: Mellanox Technologies

9 years agoRevert r275695: nd6_dad_find() was already correct.
markj [Thu, 11 Dec 2014 09:16:45 +0000 (09:16 +0000)]
Revert r275695: nd6_dad_find() was already correct.

Reported by: ae, kib
Pointy hat to: markj

9 years agoMFV r275696: file 5.21.
delphij [Thu, 11 Dec 2014 06:52:10 +0000 (06:52 +0000)]
MFV r275696: file 5.21.

MFC after:  2 weeks

9 years agoVendor import of file 5.21.
delphij [Thu, 11 Dec 2014 06:00:53 +0000 (06:00 +0000)]
Vendor import of file 5.21.

9 years agoFix a bug in r266857: nd6_dad_find() must return NULL if it doesn't find
markj [Thu, 11 Dec 2014 00:41:54 +0000 (00:41 +0000)]
Fix a bug in r266857: nd6_dad_find() must return NULL if it doesn't find
a matching element in the DAD queue.

Reported by: Holger Hans Peter Freyther <holger@freyther.de>
MFC after: 3 days

9 years agoFix building termcap.db when make obj is run beforehand from a clean tree by
ngie [Wed, 10 Dec 2014 23:18:11 +0000 (23:18 +0000)]
Fix building termcap.db when make obj is run beforehand from a clean tree by
using make variables for the filenames, which helps resolve pathing
appropriately when running cap_mkdb

X-MFC with: r275687
Pointyhat to: me

9 years agoRemove termcap entry reordering; install the file verbatim instead
ngie [Wed, 10 Dec 2014 20:40:03 +0000 (20:40 +0000)]
Remove termcap entry reordering; install the file verbatim instead

termcap entry reordering requires ex (which is available via usr.bin/vi), which
breaks on build hosts where installworld is run with MK_VI == no (or when
make delete-old is run on ^/projects/building-blocks as vi, et al, are
removed on the branch when the knob is tweaked to => "no")

Reordering termcap was believed to improve performance, but the file is now
accessed via /etc/termcap.db, so /etc/termcap (and /usr/share/misc/termcap by
proxy) access is less preferred.

Reordering the file broke the historical comment <-> entry mapping as well,
which could muddle the purpose of entries in the file, so it could be
potentially harmful to readers in its reordered state.

Discussion took place on hackers@ here:
https://lists.freebsd.org/pipermail/freebsd-hackers/2014-December/046657.html

Discussed with: -hackers, mp
MFC after: 1 month
Sponsored by: EMC / Isilon Storage Division

9 years agoFix kernel build for booke.
andreast [Wed, 10 Dec 2014 20:23:19 +0000 (20:23 +0000)]
Fix kernel build for booke.

9 years agoFix build for powerpc(32|64) kernels.
andreast [Wed, 10 Dec 2014 18:13:14 +0000 (18:13 +0000)]
Fix build for powerpc(32|64) kernels.

9 years agoFix a typo reported by Lennart Grahl.
tuexen [Wed, 10 Dec 2014 14:50:57 +0000 (14:50 +0000)]
Fix a typo reported by Lennart Grahl.

MFC after: 3 days

9 years agoAdd "-media" autofs map, to access data on removable media, such as CD
trasz [Wed, 10 Dec 2014 14:36:44 +0000 (14:36 +0000)]
Add "-media" autofs map, to access data on removable media, such as CD
drives or flash keys.  It can be enabled by uncommenting a single entry
in default /etc/auto_master.  It can also be easily modified to use
fuse-based filesystems instead of in-kernel ones.

There is still one deficiency - the mountpoints are permanent, they
don't disappear when user removes the media.  Fixing it needs some
autofs changes.

Differential Revision: https://reviews.freebsd.org/D1210
MFC after: 1 month
Sponsored by: The FreeBSD Foundation

9 years agoAdd fstyp(8). This utility, named after its SVR4 counterpart, detects
trasz [Wed, 10 Dec 2014 14:14:16 +0000 (14:14 +0000)]
Add fstyp(8).  This utility, named after its SVR4 counterpart, detects
filesystems.  It differs from file(1) in that it gives machine-parseable
output, it outputs filesystem labels, doesn't get confused by other
formats metadata, and runs in Capsicum sandbox.

Differential Revision: https://reviews.freebsd.org/D1255
Relnotes: yes
Sponsored by: The FreeBSD Foundation

9 years agoxen/intr: balance dynamic interrupts across available vCPUs
royger [Wed, 10 Dec 2014 13:25:21 +0000 (13:25 +0000)]
xen/intr: balance dynamic interrupts across available vCPUs

By default Xen binds all event channels to vCPU#0, and FreeBSD only shuffles
the interrupt sources once, at the end of the boot process. Since new event
channels might be created after this point (because new devices or backends
are added), try to automatically shuffle them at creation time.

This does not affect VIRQ or IPI event channels, that are already bound to a
specific vCPU as requested by the caller.

Sponsored by: Citrix Systems R&D

9 years agoxen: mask event channels while binding them to a vCPU
royger [Wed, 10 Dec 2014 11:42:02 +0000 (11:42 +0000)]
xen: mask event channels while binding them to a vCPU

Mask the event channel source before trying to bind it to a CPU, this
prevents stray interrupts from firing while assigning them and hitting the
KASSERT in xen_intr_handle_upcall.

Sponsored by: Citrix Systems R&D

9 years agoxen: convert the Grant-table code to a NewBus device
royger [Wed, 10 Dec 2014 11:35:41 +0000 (11:35 +0000)]
xen: convert the Grant-table code to a NewBus device

This allows the Grant-table code to attach directly to the xenpv bus,
allowing us to remove the grant-table initialization done in xenpv.

Sponsored by: Citrix Systems R&D

9 years agoo Put () for p to avoid unexpected macro expansion
br [Wed, 10 Dec 2014 11:35:10 +0000 (11:35 +0000)]
o Put () for p to avoid unexpected macro expansion
o style(9) fix

Submitted by: Yonghyeon PYUN <pyunyh@gmail.com>

9 years agoxen: move grant table code
royger [Wed, 10 Dec 2014 11:21:52 +0000 (11:21 +0000)]
xen: move grant table code

Mave the grant table code into the dev/xen folder in preparation for turning
it into a device using the newbus interface. This is just code motion, no
functional changes.

Sponsored by: Citrix Systems R&D

9 years agoFix multiple vulnerabilities in file(1) and libmagic(3).
delphij [Wed, 10 Dec 2014 08:19:55 +0000 (08:19 +0000)]
Fix multiple vulnerabilities in file(1) and libmagic(3).

Security: FreeBSD-SA-14:28.file
Security: CVE-2014-3710, CVE-2014-8116, CVE-2014-8117

9 years agoIn r268924 __fflush was modified so that when write(2) was not successful,
delphij [Wed, 10 Dec 2014 08:18:22 +0000 (08:18 +0000)]
In r268924 __fflush was modified so that when write(2) was not successful,
_p and _w are adjusted to account for the partial write (if any).

However, _p and _w should not be unconditionally adjusted and should only
be changed when we actually wrote some bytes, or the accumulated accounting
error will eventually result in a heap buffer overflow.

Reported by: adrian and alfred (Norse Corporation)
Security: FreeBSD-SA-14:27.stdio
Security: CVE-2014-8611