Commit graph

437 commits

Author SHA1 Message Date
loos
ee7c8aecaa Add the ID for the Huawei ME909S LTE modem.
Submitted by:	svenauhagen at github
MFC after:	3 days
Sponsored by:	Rubicon Communications, LLC (Netgate)
2017-06-27 06:19:26 +02:00
Shawn Webb
d0bfc2b738
Revert "HBSD: Randomize top of per-thread stacks"
This reverts commit b7b19ffccfb139fc731dca94655b3531a50c61ca. The
per-thread stack randomization needs more thought. It's likely that this
implementation is being too aggressive.

Signed-off-by:	Shawn Webb <shawn.webb@hardenedbsd.org>
(cherry picked from commit 5d741f44acf944a48dd14390fec663b42f962e96)
(cherry picked from commit 233c617c4908a4249a70af89dcbea31575f0dc87)
2017-06-25 23:08:51 -04:00
Shawn Webb
ff0cec6dcb HBSD: Randomize top of per-thread stacks
The per-thread stack implementation in libthr supplies a hint to
mmap(2). ASLR will get applied to it, it could be hardened still.
Provide additional hardening by randomizing the size of the per-thread
stack guard provided by libthr. This will effectively randomize the top
of the per-thread stack at a page-level granularity. Additional entropy
could be provided by introducing a random-sized gap, thus getting better
than page-level granularity.

Signed-off-by:	Shawn Webb <shawn.webb@hardenedbsd.org>
Sponsored-by:	SoldierX
2017-06-25 21:29:53 +02:00
Shawn Webb
7e16dbbf12 HBSD: Do not allow non-stack mappings between bottom-most limit of stack and the top of the stack
The space between the bottom-most limit of the stack and the top of the
stack should not be able to be mapped via mmap(2). This should fully
mitigate Stack Clash in conjunction with the hardened stack guard.

Signed-off-by:	Shawn Webb <shawn.webb@hardenedbsd.org>
Sponsored-by:	SoldierX
2017-06-25 21:29:10 +02:00
Shawn Webb
da1579dfc8 HBSD: Harden per-thread stack guard
libthr inserts its own stack guard. Harden it for the same reasons as
commit 13971cb990b78e679ab338b4e8baf24f3e0d8730.

Signed-off-by:	Shawn Webb <shawn.webb@hardenedbsd.org>
Sponsored-by:	SoldierX
2017-06-25 21:18:15 +02:00
Shawn Webb
1af48f7b4b HBSD: Harden the stack guard
The Stack Clash article shows that a single page for the stack guard
isn't sufficient. Bump the size of the stack guard up to 2MB by default.
Provide a way for the stack guard size to be configurable with either a
custom kernel configuration or via a sysctl node. The sysctl node
(security.bsd.stack_guard_size) is only exposed if PAX_HARDENING is
disabled. Otherwise, the user must recompile with a custom kernel
(kernel option: STACK_GUARD_SIZE) to modify the size. The size MUST be
divisible by PAGE_SIZE (default: 4096 bytes) and cannot be zero.

ASLR does help address the Stack Clash, especially since HardenedBSD
follows the PaX design with true stack randomization (randomizing the
top of the stack while also inserting a random-sized gap). However, ASLR
does not mitigate the Stack Clash attack. It simply makes the attacker's
job much more difficult. Without ASLR, the attacker will know in advance
where the stack starts and can easily determine the current stack
layout. Utilizing that information, the attacker can figure out how to
manipulate the address space to clash with the stack.

Signed-off-by:	Shawn Webb <shawn.webb@hardenedbsd.org>
Sponsored-by:	SoldierX
2017-06-25 21:17:40 +02:00
Shawn Webb
ee1912f987
HBSD: Enable the stack guard by default
HardenedBSD has enabled the stack guard by default. The article Stack
Clash discusses FreeBSD having the stack guard disabled by default. ASLR
will help here, but is not a full mitigation against this kind of attack.

A follow-up commit from HardenedBSD will harden the stack guard page
even more so. Once that commit is tested and considered stable, it will
be merged over into OPNsense.

Signed-off-by:	Shawn Webb <shawn@opnsense.org>
2017-06-19 20:29:49 -04:00
sbruno
0357654fe9 Add Intel Atom Cherryview SOC HSUART support
PR:	207910
Submitted by:	johannes@brilliantservice.co.jp
MFC after:	1 week
2017-06-12 11:52:37 +02:00
Franco Fichtner
cf0039ade4 dhclient: support supersede statement for option 54
Submitted by: Fabian Kurtz <fabian.kurtz@udo.edu>
2017-05-08 06:28:45 +02:00
kp
f5dde2a92f pfctl: Allow TOS bits to be cleared
TOS value 0 is valid, so use 256 as an invalid value rather than zero.
This allows users to enforce TOS == 0 with pf.

Reported by:	Radek Krejča <radek.krejca@starnet.cz>
2017-05-06 11:26:32 +02:00
kp
fa04428122 pf: port extended DSCP support from OpenBSD
Ignore the ECN bits on 'tos' and 'set-tos' and allow to use
DCSP names instead of having to embed their TOS equivalents
as plain numbers.

Obtained from:	OpenBSD
Sponsored by:	OPNsense
Differential Revision:	https://reviews.freebsd.org/D8165
2017-05-06 11:18:52 +02:00
delphij
7c091a7bfe Fix ipfilter(4) fragment handling panic.
Security:	FreeBSD-SA-17:04.ipfilter
Approved by:	so
2017-04-27 09:14:52 +02:00
delphij
c4839b2532 Fix multiple vulnerabilities of ntp. [SA-17:03]
Xen migration enhancements. [EN-17:05]

Approved by:	so
2017-04-16 11:26:43 +02:00
Franco Fichtner
bfab6b00ca tzdata: bump to 2017b
Taken from: https://www.iana.org/time-zones
2017-03-23 11:37:17 +01:00
Codarren Velvindron
24b7d3a2c6 Discard 3072 bytes instead of 1024 bytes (#22)
* As per the recommendations outlined in Network Operations Division
Cryptographic Requirements published on Wikileaks on March 2017.

We discard more bytes of the first keysteam
to reduce the possibility of non-random bytes.

Similar to the already patched:
contrib/ntp/sntp/libevent/arc4random.c
in opnsense repository

* Format patch according to current:
9395fdf886
2017-03-20 19:01:49 +01:00
Franco Fichtner
e8a7b78239 ipsec: skip may be zero in IPv4 handling, but must not
ae@ says skip should not be needed anymore and is supposed to
always be the size of the IPv4 header.  The IPv6 code already
handles this more robustly so simply update IPv4 accordingly.
2017-03-15 06:34:35 +01:00
Franco Fichtner
45de4d85a9 Revert "enc: revert rcvif meddling"
This reverts commit 72c179bbf1.
2017-03-15 06:34:19 +01:00
Shawn Webb
06e2c3f857
HBSD: Only set SHLIBDIR with librt
The way I was doing it prevented cross-building from working. By only
setting SHLIBDIR, bsd.lib.mk will create the proper symlinks for me.

Signed-off-by:	Shawn Webb <shawn.webb@hardenedbsd.org>
Sponsored-by:	SoldierX
Discussed-with:	Bryan Drewery
MFC-to:		11-STABLE
(cherry picked from commit 1dfc1328ceabe5b68f3a5c46b7808735a0243d8e)
2017-03-08 18:29:20 -05:00
Franco Fichtner
ad79d45be4 tzdata: bumo to 2017a
Taken from: https://www.iana.org/time-zones
2017-03-01 05:39:12 +01:00
Franco Fichtner
72c179bbf1 enc: revert rcvif meddling 2017-02-28 14:51:05 +01:00
delphij
de57639d0e Fix multiple vulnerabilities of OpenSSL. [SA-17:02]
Fix system hang when booting when PCI-express HotPlug is enabled.
[EN-17:01]

Fix NIS master updates are not pushed to NIS slave. [EN-17:02]

Fix compatibility with Hyper-V/storage after KB3172614 or
KB3179574. [EN-17:03]

Make makewhatis output reproducible. [EN-17:04]

Approved by:	so
2017-02-23 11:39:29 +01:00
Franco Fichtner
cc26f593af Revert "hyperv: let there be IDE disks"
This reverts commit bdf347ea9d.
Addressed in the the FreeBSD advisoriy coming right up...
2017-02-23 11:39:02 +01:00
Franco Fichtner
6b79b52cf3 Revert "Microoptimize locking primitives by avoiding unnecessary atomic ops."
This reverts commit 25669dd1d9562b9b1717d5ef59b15e1716c81634.
2017-02-20 12:16:47 +01:00
Franco Fichtner
c2a8bcd3b1 run: add AE3000 and AE6000; closes #17 2017-02-16 17:33:28 +01:00
Franco Fichtner
b964935420 netinet/pf: shared forwarding additions 2017-02-15 21:51:35 +01:00
Franco Fichtner
48b69b0bd5 re: update to upstream version 1.93, full FreeBSD 11.0 support
Taken from: http://www.realtek.com.tw/Downloads/
2017-02-15 21:44:23 +01:00
Shawn Webb
98200ba098 HBSD: Also install a symlink to librt.a
Signed-off-by:	Shawn Webb <shawn.webb@hardenedbsd.org>
Sponsored-by:	SoldierX
MFC-to:		11-STABLE
(cherry picked from commit d5e458b8a500e240e034b3f4d56b58fd1fcc50d7)
(cherry picked from commit 71567ac8d8d58a41d049a83034a1649b52c9437e)
2017-02-13 09:43:30 -05:00
Franco Fichtner
59089894ed re: port driver to FreeBSD 11.0 2017-02-12 11:08:31 +01:00
Franco Fichtner
b5e9e2dcc4 re: use the upstream realtek driver 1.92
Taken from: http://www.realtek.com.tw/Downloads/
2017-02-12 11:08:31 +01:00
Shawn Webb
dbbb6b841f
Add sample HARDENED amd64 kernel config.
Signed-off-by:	Shawn Webb <shawn@opnsense.org>
2017-02-11 17:51:05 -05:00
Shawn Webb
c506eb78e2
Initialize generic hardening subsystem at prison start.
Signed-off-by:	Shawn Webb <shawn@opnsense.org>
2017-02-11 16:52:27 -05:00
Shawn Webb
77492e5bdb
Set security.bsd.unprivileged_proc_debug to 0 when PAX_HARDENING is enabled.
Signed-off-by:	Shawn Webb <shawn@opnsense.org>
github-issue:	#19
2017-02-11 16:41:46 -05:00
Shawn Webb
654d6151ef
Introduce HardenedBSD's procfs hardening.
OPNsense doesn't use procfs by default, but in case users try to use it,
prevent an interesting attack where an attacker can abuse procfs to
modify application execution state.

This commit also introduces the PAX_HARDENING kernel option.

Signed-off-by:	Shawn Webb <shawn@opnsense.org>
2017-02-11 16:39:16 -05:00
Shawn Webb
13b7766b60
HBSD: Add librt from /usr/lib to ObsoleteFiles.inc
Signed-off-by:	Shawn Webb <shawn@opnsense.org>
(cherry picked from commit 988e0b9eee28359697984d1e05efb1099e6f4f4d)
2017-02-11 14:27:32 -05:00
Shawn Webb
aac833acf7
HBSD: Link /usr/lib/librt.so to /lib/librt.so
lld wants /usr/lib/librt.so to exist.

Signed-off-by:	Shawn Webb <shawn.webb@hardenedbsd.org>
MFC-to:		11-STABLE
(cherry picked from commit a3e549f5eb5d48db7d162caea5ae333453cb5ab4)
(cherry picked from commit 51b4d62cdd2398bdb12545dc8a8c829b68d9ff1b)
2017-02-11 14:27:28 -05:00
Shawn Webb
6dcd682a54
HBSD: Style change to librt Makefile
No functional change.

Signed-off-by:	Shawn Webb <shawn.webb@hardenedbsd.org>
Reported-by:	Oliver Pinter <oliver.pinter@hardenedbsd.org>
github-issue:	#229
MFC-to:		11-STABLE
(cherry picked from commit 31756adc537dc7fdd289bf7085792798c72ae901)
(cherry picked from commit ab7fa1f59178fd478f05c512928adc39e389111c)
2017-02-11 14:27:24 -05:00
Shawn Webb
3aee0bc104
HBSD: Install librt to /lib
This is required for systems where /usr is on a different filesystem.

Signed-off-by:	Shawn Webb <shawn.webb@hardenedbsd.org>
github-issue:	#229
MFC-to:		11-STABLE
(cherry picked from commit cbf6cad428258f0ac894742b5a907b815bf25bd9)
(cherry picked from commit e6c0333fae2e6d2f042d34481649a2c1afa4c513)
2017-02-11 14:27:19 -05:00
Shawn Webb
bc5a22014e
HBSD: Add SafeStack src.conf.5 documentation glue
Signed-off-by:	Shawn Webb <shawn.webb@hardenedbsd.org>
(cherry picked from commit eb83cd3bac7c88d36032c5ce2117cc7fad879e7b)
(cherry picked from commit ea307f49b3c202742f5dff424aaa79a944f9b8a0)
(cherry picked from commit 959e122fc1a4472ac3658f334df2fa1eaf2dff22)
2017-02-11 14:27:15 -05:00
Shawn Webb
08d3fb3f49
HBSD: Enable SafeStack for amd64 by default
SafeStack isn't ready for architectures other than amd64.

Signed-off-by:	Shawn Webb <shawn.webb@hardenedbsd.org>
(cherry picked from commit c2aa81995f2d279ec24697b4f94a669bee096c5e)
(cherry picked from commit 52996a3565a03ef16e80c757ba89132282e3988f)
(cherry picked from commit 46cb6a0954aca39f5ca263633c364eb5dfc5e424)
2017-02-11 14:27:11 -05:00
Shawn Webb
71302d0856
HBSD: Do not enable SafeStack for LIB32
This is only for COMPAT_LIB32 on amd64. SafeStack doesn't apply in this
case.

Signed-off-by:	Shawn Webb <shawn.webb@hardenedbsd.org>
(cherry picked from commit dab578c527eaf4f98cf1d6aa99e9e90d7cb6b920)
(cherry picked from commit c04fd9f1a8ea65590c1d03080917961fa5225611)
(cherry picked from commit 905a6804f37346bbc481489076270dd59455ea61)
2017-02-11 14:26:57 -05:00
Shawn Webb
5e5cf8aa41
HBSD: Add SafeStack flags to CXXFLAGS
Signed-off-by:	Shawn Webb <shawn.webb@hardenedbsd.org>
(cherry picked from commit cd79fd25277b92b1377c786a1e5f7deb2aa8598c)
(cherry picked from commit 075466cb7e381a2e853f6e946a2bc8ccf7a67b5b)
(cherry picked from commit 45c237cb10553daf34cdda8b0acfefefc3627440)
2017-02-11 14:26:54 -05:00
Shawn Webb
22b77e012b
HBSD: Introducing SafeStack
Compile world with SafeStack from clang/llvm. Right now, only
applications are compiled with SafeStack, not libraries. clang 3.9.0
does not support compiling shared libraries with SafeStack, though a
patch has been proposed that would enable support.

This is very much still a work-in-progress. More research is needed.

Note that with clang's current implementation of SafeStack, ASLR and W^X
are prerequisites. SafeStack currently requires ASLR and W^X in order to
be effective.

Signed-off-by:	Shawn Webb <shawn.webb@hardenedbsd.org>
(cherry picked from commit bb9e4981334b2988325c3334fc88c89b76fea91f)
(cherry picked from commit 3b3b0b08f19ec7c2f4fad06baa72e0ce2b5ac801)
(cherry picked from commit 0c2abce516fcfd80a7e2424807839ad64b5cb263)
2017-02-11 14:26:46 -05:00
loos
7cdd26437e The stf(4) interface name does not conform with the default naming
convention for interfaces, because only one stf(4) interface can exist
in the system.

This disallow the use of unit numbers different than 0, however, it is
possible to create the clone without specify the unit number (wildcard).

In the wildcard case we must update the interface name before return.

This fix an infinite recursion in pf code that keeps track of network
interfaces and groups:

1 - a group for the cloned type of the interface is added (stf in this
    case);
2 - the system will now try to add an interface named stf (instead of
    stf0) to stf group;
3 - when pfi_kif_attach() tries to search for an already existing 'stf'
    interface, the 'stf' group is returned and thus the group is added
    as an interface of itself;

This will now cause a crash at the first attempt to traverse the groups
which the stf interface belongs (which loops over itself).

Obtained from:	pfSense
MFC after:	2 weeks
Sponsored by:	Rubicon Communications, LLC (Netgate)
2017-02-06 05:53:38 +01:00
Franco Fichtner
9dbd3471ce pf: must restore forwarding interface with PF_OUT
The old code did this while violating the pfil chain, but now we
need to look up the interface correctly.  Maybe this check should
be bubbled up in the future, but for now we should keep this with
pf(4) until we upstream these changes.
2017-02-04 04:39:16 +01:00
Franco Fichtner
8743ecdee9 pf: annotate that net.pf.share_forward is for IPv4 only 2017-02-05 12:27:56 +01:00
Franco Fichtner
d189241c36 pf: revive old forwarding code and separate it via sysctl 2017-02-03 23:05:04 +01:00
Franco Fichtner
3f4c4011db pf: do not reset forwarding information in pf_route() 2017-02-03 22:40:31 +01:00
Franco Fichtner
c509e8d159 netinet: give pfil forwarding requests priority in ip_output() 2017-02-03 22:39:57 +01:00
Franco Fichtner
bdf347ea9d hyperv: let there be IDE disks
Adapted from: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=212721
PR:           https://forum.opnsense.org/index.php?topic=4405.0
2017-02-02 15:01:50 +01:00
kp
48f38da3f4 MFC r309563: pflog: Correctly initialise subrulenr
subrulenr is considered unset if it's set to -1, not if it's set to 1.
See contrib/tcpdump/print-pflog.c pflog_print() for a user.

This caused incorrect pflog output (tcpdump -n -e -ttt -i pflog0):
  rule 0..16777216(match)
instead of the correct output of
  rule 0/0(match)

PR:		214832
Submitted by:	andywhite@gmail.com
2017-01-23 09:09:32 +01:00