Commit Graph

204118 Commits

Author SHA1 Message Date
Jilles Tjoelker
d358fa780b wordexp: Rewrite to make WRDE_NOCMD reliable.
Shell syntax is too complicated to detect command substitution and unquoted
operators reliably without implementing much of sh's parser. Therefore, have
sh do this detection.

While changing sh's support anyway, also read input from a pipe instead of
arguments to avoid {ARG_MAX} limits and improve privacy, and output count
and length using 16 instead of 8 digits.

The basic concept is:
execl("/bin/sh", "sh", "-c", "freebsd_wordexp ${1:+\"$1\"} -f "$2",
    "", flags & WRDE_NOCMD ? "-p" : "", <pipe with words>);

The WRDE_BADCHAR error is still implemented in libc. POSIX requires us to
fail strings containing unquoted braces with code WRDE_BADCHAR. Since this
is normally not a syntax error in sh, there is still a need for checking
code in libc, we_check().

The new we_check() is an optimistic check that all the characters
  <newline> | & ; < > ( ) { }
are quoted. To avoid duplicating too much sh logic, such characters are
permitted when quoting characters are seen, even if the quoting characters
may themselves be quoted. This code reports all WRDE_BADCHAR errors; bad
characters that get past it and are a syntax error in sh return WRDE_SYNTAX.

Although many implementations of WRDE_NOCMD erroneously allow some command
substitutions (and ours even documented this), there appears to be code that
relies on its security (codesearch.debian.net shows quite a few uses).
Passing untrusted data to wordexp() still exposes a denial of service
possibility and a fairly large attack surface.

Reviewed by:	wblock (man page only)
MFC after:	2 weeks
Relnotes:	yes
Security:	fixes command execution with wordexp(untrusted, WRDE_NOCMD)
2015-09-30 21:32:29 +00:00
Bryan Drewery
24df1f7e7f Replace most of the beforeinstall: hack with FILES mechanism.
This now generates the files into the OBJDIR as needed.  Some of the files
are installed directly from the src directory.  Files which are generated
from the src directory are renamed to .in to generate them and avoid
colliding with the checked-in file when CURDIR=OBJDIR.

The remaining beforeinstall: handling still needs to be reworked as it does
not work well with staging for packaging.

MFC after:	2 weeks
Sponsored by:	EMC / Isilon Storage Division
2015-09-30 20:47:27 +00:00
Bryan Drewery
a0a7796dc0 META_MODE: Remove unneeded groff/tmac special GENDIRDEPS_FILTER.
This is converting the path usr/share/tmac.*stage to something else, but
nothing ever installs or reads from such a path.  They might look in
stage.*usr/share/tmac, but that's not what this is matching.  Additionally
the .dirdeps match all of the tmac files back to gnu/usr.bin/groff/tmac
fine.

Sponsored by:	EMC / Isilon Storage Division
2015-09-30 20:40:51 +00:00
Alexander Motin
f5a2bbe6d6 Use proper STAILQ_* macros where possible. 2015-09-30 20:38:35 +00:00
John Baldwin
2b75c8ad3d Several changes to truss.
- Refactor the interface between the ABI-independent code and the
  ABI-specific backends.  The backends now provide smaller hooks to
  fetch system call arguments and return values.  The rest of the
  system call entry and exit handling that was previously duplicated
  among all the backends has been moved to one place.
- Merge the loop when waiting for an event with the loop for handling stops.
  This also means not emulating a procfs-like interface on top of ptrace().
  Instead, use a single event loop that fetches process events via waitid().
  Among other things this allows us to report the full 32-bit exit value.
- Use PT_FOLLOW_FORK to follow new child processes instead of forking a new
  truss process for each new child.  This allows one truss process to monitor
  a tree of processes and truss -c should now display one total for the
  entire tree instead of separate summaries per process.
- Use the recently added fields to ptrace_lwpinfo to determine the current
  system call number and argument count.  The latter is especially useful
  and fixes a regression since the conversion from procfs.  truss now
  generally prints the correct number of arguments for most system calls
  rather than printing extra arguments for any call not listed in the
  table in syscalls.c.
- Actually check the new ABI when processes call exec.  The comments claimed
  that this happened but it was not being done (perhaps this was another
  regression in the conversion to ptrace()).  If the new ABI after exec
  is not supported, truss detaches from the process.  If truss does not
  support the ABI for a newly executed process the process is killed
  before it returns from exec.
- Along with the refactor, teach the various ABI-specific backends to
  fetch both return values, not just the first.  Use this to properly
  report the full 64-bit return value from lseek().  In addition, the
  handler for "pipe" now pulls the pair of descriptors out of the
  return values (which is the true kernel system call interface) but
  displays them as an argument (which matches the interface exported by
  libc).
- Each ABI handler adds entries to a linker set rather than requiring
  a statically defined table of handlers in main.c.
- The arm and mips system call fetching code was changed to follow the
  same pattern as amd64 (and the in-kernel handler) of fetching register
  arguments first and then reading any remaining arguments from the
  stack.  This should fix indirect system call arguments on at least
  arm.
- The mipsn32 and n64 ABIs will now look for arguments in A4 through A7.
- Use register %ebp for the 6th system call argument for Linux/i386 ABIs
  to match the in-kernel argument fetch code.
- For powerpc binaries on a powerpc64 system, fetch the extra arguments
  on the stack as 32-bit values that are then copied into the 64-bit
  argument array instead of reading the 32-bit values directly into the
  64-bit array.

Reviewed by:	kib (earlier version)
Tested on:	amd64 (FreeBSD/amd64 & i386), i386, arm (earlier version)
Tested on:	powerpc64 (FreeBSD/powerpc64 & powerpc)
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D3575
2015-09-30 19:13:32 +00:00
Enji Cooper
14044e16bc Skip the B_flag testcase to stop blowing up freebsd-current@ with
"test failure emails" because kyua report-jenkins doesn't properly
escape non-printable chars
2015-09-30 17:43:02 +00:00
Glen Barber
20297cbf78 Initial attempt to add support for building images for
BANANAPI, CUBIEBOARD, and CUBIEBOARD2 SoCs.

Obtained from:	Crochet, FreeBSD/arm/Allwinner Wiki page
Sponsored by:	The FreeBSD Foundation
2015-09-30 16:31:21 +00:00
Alexander Motin
de2393124c Make pass, sg and targ drivers respect HBA's maxio.
Previous limitation of 64K (DFLTPHYS) is quite annoying.
2015-09-30 13:31:37 +00:00
Christian Brueffer
2aea45f0d5 Join excessive split lines.
MFC after:	1 week
2015-09-30 12:40:51 +00:00
Andrey V. Elsukov
f367798498 Take extra reference to security policy before calling crypto_dispatch().
Currently we perform crypto requests for IPSEC synchronous for most of
crypto providers (software, aesni) and only VIA padlock calls crypto
callback asynchronous. In synchronous mode it is possible, that security
policy will be removed during the processing crypto request. And crypto
callback will release the last reference to SP. Then upon return into
ipsec[46]_process_packet() IPSECREQUEST_UNLOCK() will be called to already
freed request. To prevent this we will take extra reference to SP.

PR:		201876
Sponsored by:	Yandex LLC
2015-09-30 08:16:33 +00:00
Mark Johnston
3142b37664 Have lockstat(1) trace locks by name rather than by address.
Previously, lockstat(1) would use a lock's address as its identifier when
consuming data describing lock contention and hold events. After collecting
the requested data, it would use ksyms(4) to resolve lock addresses to
names. Of course, this doesn't work too well for locks contained in
dynamically-allocated memory. This change modifies lockstat(1) to trace the
lock names obtained from the base struct lock_object instead, leading to
output that is generally much more useful.

This change also removes the -c option, which is used to coalesce data for
locks in an array. It's not possible to support this option without also
tracing lock addresses, and since lock arrays in which the lock names are
distinct are not very common in FreeBSD, it's simpler to just remove the
option.

Reviewed by:	avg (earlier revision)
Differential Revision:	https://reviews.freebsd.org/D3661
2015-09-30 05:46:56 +00:00
Mark Johnston
b22ef02080 Update DTrace test makefiles after r288415. 2015-09-30 05:25:39 +00:00
Mark Johnston
f7c3db2537 MFV r288408:
6266 harden dtrace_difo_chunksize() with respect to malicious DIF

illumos/illumos-gate@395c7a3dcf

Reviewed by: Alex Wilson <alex.wilson@joyent.com>
Reviewed by: Dan McDonald <danmcd@omniti.com>
Approved by: Garrett D'Amore <garrett@damore.org>
Author: Bryan Cantrill <bryan@joyent.com>

MFC after:	1 week
2015-09-30 05:24:22 +00:00
Adrian Chadd
a3767659f0 modify the rssi logic a bit to actually return a useful rssi.
The fullmac firmware doesn't seem to populate a useful rssi indicator
in the RX descriptor, so if one plotted said values, they'd basically
look like garbage.

The reference driver implements a "get current rssi" firmware command
which I guess is really meant for station operation only (as hostap
operation would need rssi per station, not a single firmware read.)

So:

* populate sc_currssi during each calibration run;
* use this in the RX path instead of trying to reconstruct the RSSI
  value and passing it around as a pointer;
* do up a quick hack to map the rssi hardware value to some useful
  signal level;
* the survey results provide an RSSI value between 0..100, so just
  do another quick hack to map it into some usefulish signal level;
* supply a faked noise floor - I haven't yet found how to pull it
  out of the firmware.

The scan results and the station RSSI information is now more useful
for indicating signal strength / distance.
2015-09-30 05:19:16 +00:00
Mark Johnston
c5af5ada34 Stop hard-coding a 32-bit data model for USDT tests, and just use the native
model. This was causing many of the tests to fail on amd64 since USDT
support for 32-bit programs is currently non-functional.

MFC after:	1 week
2015-09-30 04:48:56 +00:00
Gleb Smirnoff
794ac42374 When processing ICMP need frag message, ignore the suggested MTU unless it
is smaller than the current one for this connection. This is behavior
specified by RFC 1191, and this is how original BSD stack behaved, but this
was unintentionally regressed in r182851.

Reported & tested by:	Richard Russo <russor whatsapp.com>
Differential Revision:	D3567
Sponsored by:		Nginx, Inc.
2015-09-30 03:37:37 +00:00
Mark Johnston
e4ab76dbb1 6266 harden dtrace_difo_chunksize() with respect to malicious DIF
illumos/illumos-gate@395c7a3dcf

Reviewed by: Alex Wilson <alex.wilson@joyent.com>
Reviewed by: Dan McDonald <danmcd@omniti.com>
Approved by: Garrett D'Amore <garrett@damore.org>
Author: Bryan Cantrill <bryan@joyent.com>
2015-09-30 03:30:24 +00:00
John Baldwin
9e07e493b3 Trim trailing whitespace. 2015-09-30 00:08:24 +00:00
John Baldwin
a061e3c50f Decode recently added procctl(2) operations. 2015-09-29 23:54:26 +00:00
Adrian Chadd
d46e82d63c Fix locking after my EDCA update change.
The net80211 lock is no longer held during this call, so we don't have
to unlock/relock.

Noticed by:	David Wolfskill
2015-09-29 19:15:08 +00:00
Bryan Drewery
fa5e9cbbd7 Fix the .MAKE added in r251750 to properly support the historical -n -n.
The condition used matches the condition in sys.mk for setting _+_ to blank
or +.

With this -n will continue to not descend into Makefile.inc1, while -n -n will
and cause Makefile.inc1's target to run with -n.

MFC after:	2 weeks
Sponsored by:	EMC / Isilon Storage Division
2015-09-29 18:57:30 +00:00
Bryan Drewery
10d8d828d3 When stopping ugidfw, it is not enough to just try unloading the module. If
the module is built-in to the kernel then the kldunload will fail.  Rather
than do this just check if there are rules and then remove them all.

Add requirement on FILESYSTEMS to ensure /usr is present for /usr/sbin/ugidfw
and /usr/bin/xargs.  This was already effectively the ordering from rcorder(8).

MFC after:	2 weeks
Relnotes:	yes
2015-09-29 18:51:56 +00:00
Bryan Drewery
66157b3899 Fix 'ugidfw remove' after r284251 incorrectly changed it.
The sysctl_rule() node removes entries when given a newptr and newlen == 0.
2015-09-29 18:48:12 +00:00
Xin LI
066c492a77 The Sun RPC framework uses a netbuf structure to represent the
transport specific form of a universal transport address.  The
structure is expected to be opaque to consumers.  In the current
implementation, the structure contains a pointer to a buffer
that holds the actual address.

In rpcbind(8), netbuf structures are copied directly, which would
result in two netbuf structures that reference to one shared
address buffer.  When one of the two netbuf structures is freed,
access to the other netbuf structure would result in an undefined
result that may crash the rpcbind(8) daemon.

Fix this by making a copy of the buffer that is going to be freed
instead of doing a shallow copy.

Security:	FreeBSD-SA-15:24.rpcbind
Security:	CVE-2015-7236
2015-09-29 18:05:54 +00:00
Xin LI
b95523e859 In this context fclose() can never fail, so assert it in the test
case.
2015-09-29 17:54:28 +00:00
Bryan Drewery
e0efd9ee69 All supported releases have the -m support from r186678, so remove
the mention of it and reword this a bit to remove 'you'.

MFC after:	3 days
2015-09-29 17:54:01 +00:00
Bryan Drewery
749146414d Document the post-merge actions of calling tzsetup(8) and services_mkdb(8)
added in r259134.

MFC after:	3 days
2015-09-29 17:49:59 +00:00
Christian Brueffer
3c88af1b35 Add otus(4) to the hardware notes. 2015-09-29 17:04:20 +00:00
Glen Barber
1bd59ef914 In addition to the ubldr file, also copy ubldr.bin to the
MS-DOS partition.  This will help with transitioning to
a single arm/armv6 userland build which could be used for
all FreeBSD/armv6 images without UBLDR_LOADADDR being set
for each board (ultimately requiring a separate buildworld
for each currently).

Requested by:	ian
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2015-09-29 16:09:59 +00:00
Konstantin Belousov
96cdb0ab9d Annotate arm userspace assembler sources stating their tolerance to
the non-executable stack.

Reviewed by:	andrew
Sponsored by:	The FreeBSD Foundation
2015-09-29 16:09:58 +00:00
John Baldwin
3e10dd1049 Use EFI page size constants instead of hardcoding 4096.
Reviewed by:	emaste
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D3692
2015-09-29 15:49:53 +00:00
John Baldwin
df66ebeba3 When XSAVE support was added on amd64, the FPU save area was moved
out of 'struct pcb' and into a variable-sized region after the
structure. The kgdb code currently only reads the pcb. It does not
read in the FPU save area but instead passes stack garbage as the
FPU's saved context. Fixing this would mean determining the proper
size of the area and fetching it. However, this state is not saved
for running CPUs in stoppcbs[], so the callback would also have to
know to ignore those pcbs. Instead, just remove the call since it is
of limited usefulness. It results in kgdb reporting the state of the
FPU/SIMD registers in userland, not their current values in the kernel.
In particular, it does not report the correct state for any code in
the kernel which does use the FPU and would report incorrect values
in that case.

Reviewed by:	kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D3743
2015-09-29 15:47:42 +00:00
Glen Barber
91c42fff77 In vm_copy_base(), turn off SU+J on the resultant filesystem,
leaving only SU enabled.

Discussed with:	kib (a few weeks ago)
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2015-09-29 15:30:27 +00:00
Alexander Motin
66b6967686 Really implement PREVENT ALLOW MEDIUM REMOVAL command. 2015-09-29 15:12:40 +00:00
Alexander Motin
7f3d6f1fe3 Don't report SYNC_NV bit set in SYNCHRONIZE CACHE as error.
While this bit is obsolete in SBC-3, behavior controlled by it is allowed
on device discretion.
2015-09-29 13:58:27 +00:00
Alexander Motin
862aedb0d6 Fix arguments order. 2015-09-29 12:53:41 +00:00
Andriy Gapon
6557a3b7dd sdt.h: no need for argtype_list_head
MFC after:	12 days
2015-09-29 12:14:59 +00:00
Andriy Gapon
a26cc6c081 sdt: static-ize couple of variables
MFC after:	11 days
2015-09-29 12:14:22 +00:00
Andriy Gapon
ab8d248801 sdt module does not seem to actually use any symbol from opensolaris module
MFC after:	11 days
2015-09-29 12:13:31 +00:00
Andriy Gapon
3bd9b9a600 std: it is important that func name is never an empty string
otherwise DTRACE_ANCHORED() returns false and that makes stack()
insert a bogus frame at the top.
For example:
dtrace -n 'test:dtrace_test::sdttest { stack(); }

This change is not really a solution, but just a work-around.
The real solution is to record the probe's call site and to use
that for resolving a function name.

PR:		195222
MFC after:	22 days
2015-09-29 12:02:23 +00:00
Andriy Gapon
09999d92b1 sdt: start checking version field when parsing probe definitions
This is an extra safety measure.

MFC after:	21 days
2015-09-29 11:58:21 +00:00
Andriy Gapon
c9d71814d5 dtrace_getarg: remove stray return statement on amd64, powerpc
MFC after:	10 days
2015-09-29 11:55:26 +00:00
Christian Brueffer
ff88b6a563 The Dt argument should be in capital letters. 2015-09-29 11:48:47 +00:00
Alexander Motin
6908da41fa Report that we can read all flavours of DVD. Why not? 2015-09-29 10:44:37 +00:00
Alexander Motin
d6e7f6e741 Add CD/DVD Capabilities and Mechanical Status Page.
This page is obsolete since MMC-4, but still used by some software.
2015-09-29 09:09:37 +00:00
Adrian Chadd
85dafc6977 rsu(4): Add support for 1T2R and 2T2R NICs.
This logic is mostly crimed from the reference driver and the linux
r92su driver.

I verified that it (a) worked on the rsu hardware I have, and (b)
did traffic testing whilst watching what ath(4) sent as a hostap.
It successfully sent MCS8..15 rates (which requires 2-stream reception)
as well as MCS0..7 (which is 1-stream.)

Tested:

* RTL8712, 1T1R NIC, MCS rates 0..7.
* RTL8712, 1T2R NIC, MCS rates 0..15

TODO:

* Find a 2T2R NIC!
2015-09-29 06:56:00 +00:00
Adrian Chadd
24c2763fb1 urtwn driver fixes - missing include, free node references, shut down xfers first
* include opt_wlan.h like a good little wlan driver;
* add a function to free the mbufq /and/ the node references on it, or we will leak
  said node references;
* free the mbufq upon NIC shutdown otherwise we may end up with a full list that
  we never begin transmit work on, and thus never drain it;
* .. which frees it upon NIC detach too;
* ensure urtwn_start() gets called after the completion of frame TX even if the
  pending queue is empty, otherwise transmit will stall.  It's highly unlikely that
  the usb tx queue would be empty whilst the incoming send queue is full, but hey,
  who knows.

This passes some iperf testing with and without the NIC being actively removed during
said active iperf test.

Tested:

* urtwn0: MAC/BB RTL8188EU, RF 6052 1T1R ; STA mode
2015-09-29 05:03:24 +00:00
Adrian Chadd
024223535f Add opt_wlan.h as requirements for the two drivers I'm currently working on. 2015-09-29 04:56:27 +00:00
Xin LI
55b2d63309 Use calloc() instead of malloc + memset.
MFC after:	2 weeks
2015-09-29 04:47:31 +00:00
Adrian Chadd
dd2fb488aa Defer calling into the driver to update the QOS (WME) configuration.
This gets called from the driver RX path which leads to driver re-entry.
2015-09-29 03:40:21 +00:00