HardenedBSD src tree
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

611 行
17KB

  1. [20191214] Jail parameter: {no}allow.extattr
  2. __HardenedBSD_version = 1300060
  3. Provide a new jail configuration parameter: allow.extattr (and
  4. noallow.extattr). Default: allow.
  5. Allow setting system-level filesystem extended attributes by
  6. default in a jailed environment.
  7. Change the default system behavior to be more relaxed. Prior
  8. to this change, privileged accounts in a jail could not set
  9. system-level filesystem extended attributes. This change now
  10. enables that ability by default.
  11. This is iin preparation for hbsdcontrol integration with
  12. ports/packages.
  13. [20191019] FreeBSD ASR with HardenedBSD ASLR
  14. __HardenedBSD_version = 1300059
  15. FreeBSD merged in their incomplete Address Space Randomization
  16. (ASR) patch. Undo the reversion of the ASR patch and rely on
  17. HardenedBSD's PaX ASLR implementation for the stack and shared
  18. page when FreeBSD's ASR is enabled.
  19. FreeBSD's ASR is disabled by default, but can be enabled at
  20. runtime by setting the `kern.elf64.aslr.pie_enable` and
  21. `kern.elf64.aslr.enable` sysctl nodes to 1. If HardenedBSD's
  22. `hardening.pax.aslr.status' sysctl node is greater than or
  23. equal to 2, the PaX ASLR implementation will only be in effect
  24. for the stack and the shared page.
  25. [20181019] shift to FreeBSD 13-CURRENT
  26. __HardenedBSD_version = 1300058
  27. FreeBSD started 13-CURRENT, do the same here.
  28. [20180701] OpenSSL
  29. __HardenedBSD_version = 1200058
  30. Switch back to OpenSSL as the default crypto library in base.
  31. [20180123] retpoline
  32. __HardenedBSD_version = 1200057
  33. Integrated the retpoline patch from llvm. The object
  34. tree should be removed fully prior to rebuilding
  35. world/kernel.
  36. [20180103] PAX_JAIL_SUPPORT
  37. __HardenedBSD_version = 1200056
  38. Added infrastructure to change hardening settings at
  39. jail creating time. You can use the same "mibs" as
  40. jail params, which exists under the hardening sysctl
  41. leaf. See the example jail.conf sniplet:
  42. exec.start = "/bin/sh /etc/rc";
  43. exec.stop = "/bin/sh /etc/rc.shutdown";
  44. exec.clean;
  45. mount.devfs;
  46. path = "/usr/jails/$name";
  47. host.hostname = "$name";
  48. hbsdnx {
  49. hardening.pax.segvguard.status = 3;
  50. hardening.pax.mprotect.status = 3;
  51. hardening.pax.pageexec.status = 3;
  52. hardening.pax.aslr.status = 3;
  53. persist;
  54. }
  55. In the current implementation the settings are still
  56. modifiable via sysctls inside from the jail, but this
  57. will change in the future. The same is true for the
  58. nested jails.
  59. [20170914] TOCTOU fix, PAX_CONTROL_{ACL,EXTATTR}
  60. __HardenedBSD_version = 1200055
  61. hbsdcontrol
  62. -----------------------------------------------------------------------
  63. The hbsdcontrol subsystem is an extattr(9) based control pane for
  64. HardenedBSD's security settings.
  65. Currently only the system namespace supported. (The FreeBSD's extattr
  66. subsystem has two namespace: system and user. The system namespace is
  67. writeable only from non-jail root user, the user namespace is writeable
  68. from all users.)
  69. This means only the root can assign rules to specific file. The other
  70. restriction is similar, only from the host is allowed to set rules to
  71. specific file, and prohibited a such operation from jails, for jail's
  72. root user too prohibited.
  73. To enable the hbsdcontrol subsystem, you should add the
  74. options PAX_CONTROL_EXTATTR
  75. kernel knob to your kernel config.
  76. The hbsdcontrol subsystem use the following extended attributes:
  77. hbsd.pax.aslr
  78. hbsd.pax.noaslr
  79. hbsd.pax.segvguard
  80. hbsd.pax.nosegvguard
  81. hbsd.pax.pageexec
  82. hbsd.pax.nopageexec
  83. hbsd.pax.mprotect
  84. hbsd.pax.nomprotect
  85. hbsd.pax.shlibrandom
  86. hbsd.pax.noshlibrandom
  87. hbsd.pax.disallow_map32bit
  88. hbsd.pax.nodisallow_map32bit
  89. Valid values are only the 0 (= disabled) and 1 (= enabled).
  90. Valid settings are the following in system FS-EA namespace (with the ASLR
  91. example, the same is true for the other settings):
  92. * no hbsd.pax.aslr, nor hbsd.pax.noaslr assigned to the file -> system default
  93. * hbsd.pax.aslr = 1 and hbsd.pax.noaslr = 0 -> enabled ASLR
  94. * hbsd.pax.aslr = 0 and hbsd.pax.noaslr = 1 -> disabled ASLR
  95. * hbsd.pax.aslr = 0 and hbsd.pax.noaslr = 0 -> invalid, warning message + execution error
  96. * hbsd.pax.aslr = 1 and hbsd.pax.noaslr = 1 -> invalid, warning message + execution error
  97. Attributes in user namespace are ignored.
  98. TOCTOU fix, PAX_ACL
  99. -----------------------------------------------------------------------
  100. As preparation to hbsdcontrol, and to clean up the whole control logic
  101. there is some new kernel knob:
  102. * PAX_CONTROL_ACL
  103. * PAX_CONTROL_ACL_OVERRIDE_SUPPORT
  104. * PAX_CONTROL_EXTATTR
  105. If you want to use the external secadm utility to manage hardenedbsd's
  106. security features, then you should add
  107. options PAX_CONTROL_ACL
  108. to your kernel config.
  109. If you want to use the extattr(9) based hbsdcontrol, you should add
  110. the
  111. options PAX_CONTROL_EXTATTR
  112. kernel knob.
  113. If you want to use both hbsdcontrol and secadm, and it's nice to add
  114. option PAX_CONTROL_ACL_OVERRIDE_SUPPORT
  115. too. This is nice in very special case, when you set rules both
  116. from hbsdcontrol and from secadm on the _same_ file. By default
  117. always the hbsdcontrol wins this situation, and what was set up
  118. by hbsdcontrol gets applied as policy. To override this behavior
  119. you can add a special flag in you secadm conf to override this
  120. behavior. For more details consult with secadm's source code /
  121. readme / man page.
  122. [20170914] Changed auxvector after e5ea82a50dd64a3e47767b132a16281242ff396d
  123. __HardenedBSD_version = 1200054
  124. After the following commit:
  125. > commit e5ea82a50dd64a3e47767b132a16281242ff396d
  126. > Author: jhb <jhb@FreeBSD.org>
  127. > Date: Thu Sep 14 14:26:55 2017 +0000
  128. > Add AT_HWCAP and AT_EHDRFLAGS on all platforms.
  129. >
  130. > A new 'u_long *sv_hwcap' field is added to 'struct sysentvec'. A
  131. > process ABI can set this field to point to a value holding a mask of
  132. > architecture-specific CPU feature flags. If an ABI does not wish to
  133. > supply AT_HWCAP to processes the field can be left as NULL.
  134. >
  135. > The support code for AT_EHDRFLAGS was already present on all systems,
  136. > just the #define was not present. This is a step towards unifying the
  137. > AT_* constants across platforms.
  138. >
  139. > Reviewed by: kib
  140. > MFC after: 1 month
  141. > Differential Revision: https://reviews.freebsd.org/D12290
  142. > Notes:
  143. > svn path=/head/; revision=323579
  144. the AT_PAXFLAGS has been changed from 24 to 26 position in
  145. elf auxvector. This may break some functionality, especially
  146. the SHLIBRAND feature, when you running on a newer kernel
  147. with an older user-space.
  148. [20170831] Changed pax_elf API
  149. __HardenedBSD_version = 1200053
  150. As preparation to hardenedBSD rationalize
  151. the pax_elf(...) functions signature, to
  152. follow the codes in kern_exec's style.
  153. For the details, see the code.
  154. [20170709] Enforced KPI
  155. __HardenedBSD_version = 1200052
  156. Enfore the KPI version at compile time. This
  157. will implicate the recompilation of external
  158. modules even once __HardenedBSD_version or
  159. __FreeBSD_version gets bumped.
  160. [20170624] Enable OpenNTPd by default
  161. __HardenedBSD_version = 1200051
  162. Enable WITH_OPENNTPD by default on HardenedBSD.
  163. After this point we deliver OpenNTPd as base
  164. ntp provider for HardenedBSD. ISC ntpd is still
  165. available, and accessible with WITHOUT_OPENNTPD=
  166. knob in src.conf(5).
  167. [20170616] Changed __HardenedBSD_version scheme
  168. __HardenedBSD_version = 1200050
  169. The version numbers may differ in different branches (10-STABLE,
  170. 11-STABLE, 12-CURRENT) and to keep the version number in pair
  171. with the features state, there is a need to allow to bump they
  172. differently.
  173. [20170616] Changed default protection settings for text section
  174. __HardenedBSD_version = 50
  175. Fixes the (theoretically) last outstanding memory
  176. protection related weakness in HBSD's user-space detectable
  177. with paxtest.
  178. [20170302] Enable CFI by default for amd64
  179. __HardenedBSD_version = 49
  180. Enable WITH_CFI by default on HardenedBSD/amd64.
  181. Control-Flow Integrity (CFI) is an exploit mitigation
  182. technique developed in the clang/llvm project. Now that
  183. base has clang 4.0.0, which brings a linker that supports
  184. Link-Time Optimization (LTO), lld, we can now make use of
  185. CFI, which requires LTO.
  186. This also enables lld by default for amd64 and arm64. Disable
  187. CFI by setting WITHOUT_CFI in src.conf(5).
  188. [20170112] Enable SafeStack by default for amd64
  189. __HardenedBSD_version = 48
  190. Enable WITH_SAFESTACK by default on HardenedBSD/amd64.
  191. SafeStack is an exploit mitigation technique developed in the
  192. clang/llvm project, born in the Code-Pointer Integrity
  193. (CPI) project. Now that base has clang 3.9.1, which contains
  194. a more mature CFI/CPI implementation, SafeStack can be enabled
  195. by default for amd64.
  196. Disable SafeStack for base by setting WITHOUT_SAFESTACK in
  197. src.conf(5).
  198. [20160820] Enable LibreSSL by default
  199. __HardenedBSD_version = 47
  200. Enable WITH_LIBRESSL by default on HardenedBSD.
  201. After this we point we deliver LibreSSL as base
  202. SSL engine for HardenedBSD. The OpenSSL is still
  203. available, and accessable with WITHOUT_LIBRESSL=
  204. knob in src.conf.
  205. [20160423] RELRO + BIND_NOW
  206. __HardenedBSD_version = 46
  207. Enable RELRO + BIND_NOW for base.
  208. Introduce WITHOUT_RELRO and WITHOUT_BIND_NOW.
  209. Setting WITHOUT_RELRO also sets WITHOUT_BIND_NOW.
  210. [20160408] PIEified base for amd64 and i386
  211. __HardenedBSD_version = 45
  212. Remove WANTS_PIE.
  213. Default PIE for base for amd64 and i386 only.
  214. When PIE is enabled, compile non-static libraries with -fPIC.
  215. Default WITH_SHARED_TOOLCHAIN to enabled by default.
  216. If you encounter build problems during make buildworld,
  217. try to clean the object files directory, which is typically
  218. /usr/obj:
  219. cd /usr/obj; rm -rf *
  220. And retry to build the world. This will require due to not
  221. proper cleaning mechanizm of FreeBSD's build framework.
  222. [201603XX] noexec and ASLR changes
  223. __HardenedBSD_version = 44
  224. Fixed noexec's paxflags parser to get usable system on
  225. bronen setups too.
  226. Changed ASLR stack randomization settings on 32 machines.
  227. [20160316] ASLR cleanup
  228. __HardenedBSD_version = 43
  229. Since the hardening.pax.aslr.*_len variables are no longer
  230. available outside of loader.conf(5), remove them from
  231. struct hbsd_features, which gets embedded in struct
  232. prison. This change makes the hardening.pax.aslr.*_len
  233. variables a global setting, rather than a per-jail setting.
  234. [20160225] RTLD noexec
  235. __HardenedBSD_version = 42
  236. Enforce nonexec thread stacks, driven by the RTLD.
  237. [20160213] rewritten internals
  238. __HardenedBSD_version = 41
  239. Changed hardenedBSD core structures.
  240. Dropped ptrace_hardening.
  241. Dropped ASLR bit settings.
  242. Fixed hbsd_update_build bug.
  243. Added skeleton file.
  244. Changed feature strings.
  245. Changed noexec implicit rules.
  246. [20160123] add pax_get_hardenedbsd_version API
  247. __HardenedBSD_version = 40
  248. Add pax_get_hardenedbsd_version() API to query hardening's version
  249. from kernel codes.
  250. Add new types, which represents the PAX_FLAGS.
  251. [20151225] redo rework internal structures
  252. __HardenedBSD_version = 39
  253. Change pax_get_prison(...) to pax_get_prison_td(...) where possible.
  254. Fix one segvguard related issue.
  255. Changed pax_elf signature.
  256. We reverted this code in version 37, because we observed weird
  257. issue, but this issues was unrelated to the reworked internals.
  258. The true root of the problem was a secadm bug and the issue fixed
  259. with version 38.
  260. [20151218] reworked MAP_32BIT mmap randomization
  261. __HardenedBSD_version = 38
  262. Previously the MAP_32BIT case mmap randomization was an ASR,
  263. to fix this and some other issue with the MAP_32BIT related
  264. mmap, implement a proper ASLR.
  265. Upstream fixed stability issues with higher order PID randomization
  266. [20151208] revert the reworked internal structures
  267. __HardenedBSD_version = 37
  268. revert: Change pax_get_prison(...) to pax_get_prison_td(...) where possible.
  269. revert: Changed pax_elf signature.
  270. [20151206] rework internal structures
  271. __HardenedBSD_version = 36
  272. Change pax_get_prison(...) to pax_get_prison_td(...) where possible.
  273. Change noexec's sysctl handlers.
  274. Fix one segvguard related issue.
  275. Fix randompid related issue.
  276. Changed pax_elf signature.
  277. [20151123] changed proc structure : added p_timekeep_base
  278. __HardenedBSD_version = 35
  279. Follow the recent VDSO changes from kib@.
  280. This required to introduce new field to struct proc.
  281. [20151018] disabled lib32 build by default
  282. __HardenedBSD_version = 34
  283. Do not build lib32 and 32bit related stuffs on 64bit platforms
  284. by default.
  285. [20150924] changed stack-protector level
  286. __HardenedBSD_version = 33
  287. Bump the default build settings from the --stack-protector
  288. to --stack-protector-strong.
  289. [20150915] ASLR changes
  290. __HardenedBSD_version = 32
  291. Changed default VDSO randomization from 20 bits to 28 bits.
  292. Fixed div by zero in rare cases in pax_aslr_init_vmspace.
  293. [20150907] Reworked DISALLOWMAP32BIT and changes some internal functions
  294. __HardenedBSD_version = 31
  295. Rename and correctly paxify the DISALLOWMAP32BIT.
  296. Changed pax flags setup.
  297. [20150905] Added MAP32_PROTECT
  298. __HardenedBSD_version = 30
  299. Added per-process mode to disable MAP_32BIT mode mmap(2).
  300. [20150823] Fixed pkg bootstrap
  301. __HardenedBSD_version = 29
  302. With FreeBSD commit 671f0b9, use of pubkey signature_type method is explicitly disallowed.
  303. This breaks bootstrapping with pubkey signature_type.
  304. [20150715] Fixed vdso randomization
  305. __HardenedBSD_version = 28
  306. Fixed and simplified vdso and stack mapping.
  307. [20150706] Added shared-page (vdso) randomization
  308. __HardenedBSD_version = 27
  309. This version brings in true stack randomization.
  310. Changed ASLR settings:
  311. vdso random : 20 bit
  312. [20150701] Rewriten stack randomization, and bumped ASLR settings
  313. __HardenedBSD_version = 26
  314. This version brings in true stack randomization.
  315. Changed ASLR settings:
  316. stack random : 26 -> 42 bit
  317. exec random : 21 -> 30 bit
  318. [20150605] ASLR "rewrite" and NOEXEC fixes after jhb's vm_mmap.c changes
  319. __HardenedBSD_version = 25
  320. __HardenedBSD_version = 24
  321. Move the mmap randomization to it's own place and add more state enforcements (KASSERTs).
  322. Added locking around pax_aslr_mmap(...).
  323. Factore out the MAP_32BIT related code from pax_aslr_mmap(...), and move to pax_aslr_mmap_map_32bit(...)
  324. [20150604] fix ASLR - randomize the rtld's shared object too
  325. __HardenedBSD_version = 23
  326. Randomize the rtld's address before load them in imgact_elf.c
  327. [20150604] added PAX_NOTE_{,NO}SHLIBRANDOM extension
  328. __HardenedBSD_version = 22
  329. This feature will fix the issue mentioned on issue #137
  330. [20150528] Changed internal structure, removed hardening.pax.segvguard.debug sysctl
  331. __HardenedBSD_version = 21
  332. Changed internal structure
  333. Removed hardening.pax.segvguard.debug sysctl
  334. [20150415] Bumped stack randomization
  335. __HardenedBSD_version = 20
  336. Increased stack randomization from 20 bit to 26 bit.
  337. [20150415] Fixed stack randomization
  338. __HardenedBSD_version = 19
  339. [20150408] How to get HardenedBSD and HardenedBSD-ports?
  340. Without git/svnlite:
  341. HardenedBSD source:
  342. # fetch https://github.com/HardenedBSD/hardenedBSD/archive/hardened/current/master.tar.gz -o hardenedbsd-src.tar.gz
  343. # tar xf hardenedbsd-src.tar.gz
  344. # mv hardenedBSD-hardened-current-master /usr/src
  345. HardenedBSD ports:
  346. # fetch https://github.com/HardenedBSD/freebsd-ports/archive/master.tar.gz -o hardenedbsd-ports.tar.gz
  347. # tar xf hardenedbsd-ports.tar.gz
  348. # mv freebsd-ports-master /usr/ports
  349. Secadm:
  350. # fetch https://github.com/HardenedBSD/secadm/archive/master.tar.gz -o secadm.tar.gz
  351. # tar xf secadm.tar.gz
  352. With git:
  353. HardenedBSD-source:
  354. # git clone https://github.com/HardenedBSD/hardenedBSD.git /usr/src
  355. HardenedBSD ports:
  356. # git clone https://github.com/HardenedBSD/freebsd-ports.git /usr/ports
  357. Secadm:
  358. # git clone https://github.com/HardenedBSD/secadm.git
  359. With svnlite (much more slower than git version):
  360. HardenedBSD-source:
  361. # svnlite co https://github.com/HardenedBSD/hardenedBSD.git /usr/src
  362. HardenedBSD ports:
  363. # svnlite co https://github.com/HardenedBSD/freebsd-ports.git /usr/ports
  364. Secadm:
  365. # svnlite co https://github.com/HardenedBSD/secadm.git
  366. [20150404] Added secadm hook to rtld
  367. __HardenedBSD_version = 18
  368. Added integriforce secadm hook to rtld to validate
  369. shared object before loading them.
  370. [20150318] Merged first part of NOEXEC project
  371. __HardenedBSD_version = 17
  372. This is the first part of PaX's MPROTECT restriction:
  373. * this merge brings per process level restriction settings
  374. * eliminated the linux's sound related mmap weakness
  375. * improved the logging
  376. ...
  377. If you have problem with your application, then install
  378. secadm:
  379. * from pkg:
  380. pkg install secadm
  381. * or from github:
  382. # git clone https://github.com/hardenedbsd/secadm
  383. # cd secadm
  384. # make && make install
  385. [201502011] Changed kernel knobs
  386. Added ``options PAX`` to enable the HardenedBSD framework.
  387. All other PAX_* knob depends on PAX knob.
  388. [20150131] Upgrading from systems before "HBSD: Revert the chacha20 import in full."
  389. After the "HBSD: Revert the chacha20 import in full." commit
  390. we lost the compatibility with the previous version, this
  391. means ABI break, and the system is unable to properly boot.
  392. In the background is the removed VM_INHERIT_ZERO flag, which
  393. was previously used in libc.
  394. The solution is to install the new world, before you booting to the new kernel.
  395. 1. make buildworld kernel
  396. 2. IMPORTANT: install world before you reboot
  397. 2.1. mergemaster -p && make installworld && mergemaster
  398. 3. reboot
  399. 4. start in single user mode
  400. 5. cd /usr/src
  401. 6. make delete-old delete-old-libs
  402. 7. if you have buildworld or buildkernel error,
  403. where the cc aborting and dumping core,
  404. then you need to delete the content of /usr/obj directory:
  405. 7.1 cd /usr/obj
  406. 7.2 rm -rf *
  407. And probably a full ports rebuild required too...