Commit graph

21433 commits

Author SHA1 Message Date
Mark Johnston
f997253234 libradius: Fix attribute length validation in rad_get_attr(3)
The length of the attribute header needs to be excluded when comparing
the attribute length against the length of the packet.  Otherwise,
validation may incorrectly fail when fetching the final attribute in a
message.

Fixes:		8d5c78130 ("libradius: Fix input validation bugs")
Reported by:	Peter Eriksson
Tested by:	Peter Eriksson
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 6bb5699d2b)
2021-05-28 13:00:19 -04:00
Kristof Provost
48d771e579 pf: Track the original kif for floating states
Track (and display) the interface that created a state, even if it's a
floating state (and thus uses virtual interface 'all').

MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D30245

(cherry picked from commit d0fdf2b28f)
2021-05-27 09:06:14 +02:00
Kristof Provost
59f8fc3fbf pfctl: Use DIOCGETSTATESNV
Migrate to using the new nvlist-based DIOCGETSTATESNV call to obtain the
states list.

MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D30244

(cherry picked from commit bc94129147)
2021-05-27 09:06:00 +02:00
Mark Johnston
bec0d2c9c8 libradius: Fix input validation bugs
Approved by:	so
Security:	FreeBSD-SA-21:12.libradius
Security:	CVE-2021-29629
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit e73975dc321a9ccbbbd65b609aa386b187dad2c1)
2021-05-26 15:45:31 -04:00
Konstantin Belousov
824cca5934 openat(2): add O_EMPTY_PATH
(cherry picked from commit 5e7cdf1817)
2021-05-19 06:13:14 +03:00
Dmitry Wagin
2886c93d1b libc: Some enhancements to syslog(3)
- Defined MAXLINE constant (8192 octets by default instead 2048) for
  centralized limit setting up. It sets maximum number of characters of
  the syslog message. RFC5424 doesn't limit maximum size of the message.
  Named after MAXLINE in syslogd(8).
- Fixed size of fmt_cpy buffer up to MAXLINE for rendering formatted
  (%m) messages.
- Introduced autoexpansion of sending socket buffer up to MAXLINE.

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

(cherry picked from commit 9bd7345212)
2021-05-14 09:56:46 -04:00
Kristof Provost
8c610ccac6 pf: Support killing 'matching' states
Optionally also kill states that match (i.e. are the NATed state or
opposite direction state entry for) the state we're killing.

See also https://redmine.pfsense.org/issues/8555

Submitted by:	Steven Brown
Reviewed by:	bcr (man page)
Obtained from:	https://github.com/pfsense/FreeBSD-src/pull/11/
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D30092

(cherry picked from commit 93abcf17e6)
2021-05-14 10:42:07 +02:00
Kristof Provost
a9620e7c70 pf: Allow states to by killed per 'gateway'
This allows us to kill states created from a rule with route-to/reply-to
set.  This is particularly useful in multi-wan setups, where one of the
WAN links goes down.

Submitted by:	Steven Brown
Obtained from:	https://github.com/pfsense/FreeBSD-src/pull/11/
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D30058

(cherry picked from commit abbcba9cf5)
2021-05-14 10:24:00 +02:00
Kristof Provost
327310fcac pfctl: Start using DIOCKILLSTATESNV
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D30055

(cherry picked from commit 2a00c4db93)
2021-05-14 10:21:15 +02:00
Kristof Provost
66cff482be pfctl: Start using DIOCCLRSTATESNV
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D30053

(cherry picked from commit 53714a5861)
2021-05-14 10:20:36 +02:00
Kristof Provost
898407819d pf: Optionally attempt to preserve rule counter values across ruleset updates
Usually rule counters are reset to zero on every update of the ruleset.
With keepcounters set pf will attempt to find matching rules between old
and new rulesets and preserve the rule counters.

MFC after:	4 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D29780

(cherry picked from commit 42ec75f83a)
2021-05-11 17:04:45 +02:00
Kurosawa Takahiro
e49799dcf1 pf: Implement the NAT source port selection of MAP-E Customer Edge
MAP-E (RFC 7597) requires special care for selecting source ports
in NAT operation on the Customer Edge because a part of bits of the port
numbers are used by the Border Relay to distinguish another side of the
IPv4-over-IPv6 tunnel.

PR:		254577
Reviewed by:	kp
Differential Revision:	https://reviews.freebsd.org/D29468

(cherry picked from commit 2aa21096c7)
2021-05-11 17:04:45 +02:00
Alex Richardson
fc19e3cb4f libc/string/memset.c: Use unsigned long for stores
While most 64-bit architectures have an assembly implementation of this
file, RISC-V does not. As we now store 8 bytes instead of 4 it should speed
up RISC-V.

Reviewed By:	kib
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D29536

(cherry picked from commit ab147542b7)
2021-05-11 09:39:27 +01:00
Alex Richardson
0e1e71400a libc/string/bcopy.c: Use intptr_t as the copy type
While most 64-bit architectures have an assembly implementation of this
file RISC-V does not. As we now copy 8 bytes instead of 4 it should speed
up RISC-V. Using intptr_t instead of int also allows using this file for
CHERI pure-capability code since trying to copy pointers using integer
loads/stores will invalidate pointers.

Reviewed By:	kib
Obtained from:	CheriBSD (partially)
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D29535

(cherry picked from commit 0b4ad01d91)
2021-05-11 09:39:26 +01:00
Kristof Provost
c93907df7b pf: Allow multiple labels to be set on a rule
Allow up to 5 labels to be set on each rule.
This offers more flexibility in using labels. For example, it replaces
the customer 'schedule' keyword used by pfSense to terminate states
according to a schedule.

Reviewed by:	glebius
MFC after:	2 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D29936

(cherry picked from commit 6fcc8e042a)
2021-05-10 21:45:57 +02:00
Kristof Provost
b8b6ee3554 pf: Fix parsing of long table names
When parsing the nvlist for a struct pf_addr_wrap we unconditionally
tried to parse "ifname". This broke for PF_ADDR_TABLE when the table
name was longer than IFNAMSIZ. PF_TABLE_NAME_SIZE is longer than
IFNAMSIZ, so this is a valid configuration.

Only parse (or return) ifname or tblname for the corresponding
pf_addr_wrap type.

This manifested as a failure to set rules such as these, where the pfctl
optimiser generated an automatic table:

	pass in proto tcp to 192.168.0.1 port ssh
	pass in proto tcp to 192.168.0.2 port ssh
	pass in proto tcp to 192.168.0.3 port ssh
	pass in proto tcp to 192.168.0.4 port ssh
	pass in proto tcp to 192.168.0.5 port ssh
	pass in proto tcp to 192.168.0.6 port ssh
	pass in proto tcp to 192.168.0.7 port ssh

Reported by:	Florian Smeets
Tested by:	Florian Smeets
Reviewed by:	donner
X-MFC-With:	5c11c5a365
MFC after:	2 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D29962

(cherry picked from commit 402dfb0a8d)
2021-05-10 21:45:56 +02:00
Konstantin Belousov
51af250608 Add ptrace(PT_COREDUMP)
(cherry picked from commit 87a64872cd)
2021-05-10 04:03:06 +03:00
Kristof Provost
9c238775a8 libpfct: Fix PIC flag
Use ${PICFLAG} rather than hard-adding -fPIC, which removes the
requirement for libnv to be built PIC.

MFC after:      4 weeks
Sponsored by:   Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 8403170b3d)
2021-05-07 10:15:43 +02:00
Kristof Provost
65dd1a98de pfctl: Fix clearing rules counters
After the migration to libpfctl for rule retrieval we accidentally lost
support for clearing the rules counters.

Introduce a get_clear variant of pfctl_get_rule() which allows rules
counters to be cleared.

MFC after:	4 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D29727

(cherry picked from commit 4eabfe468b)
2021-05-07 10:15:43 +02:00
Kurosawa Takahiro
55059f9075 pfctl, libpfctl: introduce pfctl_pool
Introduce pfctl_pool to be able to extend the pool part of the pf rule
without breaking the ABI.

Reviewed by:	kp
MFC after:	4 weeks
Differential Revision:	https://reviews.freebsd.org/D29721

(cherry picked from commit 600bd6ce06)
2021-05-07 10:15:42 +02:00
Kristof Provost
b77243fe04 libnv: Use PICFLAG rather than -fPIC
Suggested by:	andrew
MFC after:	4 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 15ca662208)
2021-05-07 10:15:42 +02:00
Kristof Provost
1398367b3a libpfctl: Fix u_* counters
struct pf_rule had a few counter_u64_t counters. Those couldn't be
usefully comminicated with userspace, so the fields were doubled up in
uint64_t u_* versions.

Now that we use struct pfctl_rule (i.e. a fully userspace version) we
can safely change the structure and remove this wart.

Reviewed by:	glebius
MFC after:	4 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D29645

(cherry picked from commit ab5707a5cf)
2021-05-07 10:15:42 +02:00
Kristof Provost
6fd48efd8d libpfctl: Switch to pfctl_rule
Stop using the kernel's struct pf_rule, switch to libpfctl's pfctl_rule.
Now that we use nvlists to communicate with the kernel these structures
can be fully decoupled.

Reviewed by:	glebius
MFC after:	4 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D29644

(cherry picked from commit e9eb09414a)
2021-05-07 10:15:42 +02:00
Kristof Provost
0da554e4b6 pfctl: Move ioctl abstraction functions into libpfctl
Introduce a library to wrap the pf ioctl interface.

MFC after:	4 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D29562

(cherry picked from commit 0d71f9f36e)
2021-05-07 10:15:42 +02:00
Kristof Provost
259e52433f libnv: Build PIC
Build libnv as position independent code so we can use it from shared
libraries.

MFC after:	4 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D29561

(cherry picked from commit 0dd13c7743)
2021-05-07 10:15:41 +02:00
Mark Johnston
11af9a9cf9 cap_sysctl.3: Fix bugs in the example
- Correct the type of the sysctl value.
- Initialize the oldsize parameter to cap_sysctlbyname()

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 44bbda649d)
2021-05-05 11:01:56 -04:00
Piotr Pawel Stefaniak
c69775749f getdirentries.2: remove unnecessary space
(cherry picked from commit 1fdd6934d5)
2021-05-05 13:04:58 +02:00
Piotr Pawel Stefaniak
21b2920724 sh(1): autocomplete commands
(cherry picked from commit b315a7296d)
2021-05-05 13:04:57 +02:00
Konstantin Belousov
46ec1227e7 connectat(2): clarify that the s argument is socket
(cherry picked from commit 07f229d20c)
2021-05-03 04:26:50 +03:00
Mitchell Horne
e0ae2b39aa pmc_allocate(3): document the count argument
This was added in b2ca2e50b9, and serves to provide an initial value
to the PMC, eliminating the need for a second syscall via pmc_set(3).

Reviewed by:	gnn, 0mp (manpages)
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D29885

(cherry picked from commit 50f6c13997)
2021-04-29 10:13:57 -03:00
Renato Botelho
d7682961d3 libfetch: Retry with proxy auth when server returns 407
PR:		220468
Submitted by:	Egil Hasting <egil.hasting@higen.org> (based on)
Reviewed by:	kevans, kp
Approved by:	kp
MFC after:	2 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D29533

(cherry picked from commit 345c30a94f)
2021-04-28 16:21:26 -03:00
Ed Maste
e3bbb369c4 libkiconv: address memory leak in not-found cases
Found in "Understanding and Detecting Disordered Error Handling with
Precise Function Pairing" by Qiushi Wu et al.

Reviewed by:	imp, jhb
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D29896

(cherry picked from commit 3cfd08c1c7)
2021-04-27 20:10:12 -04:00
Alexander Motin
2f2a081e5c Fix race in case of device destruction.
During device destruction it is possible that open() succeed, but
fdevname() return NULL, that can't be assigned to string variable.
Fix that by adding explicit NULL check.

Also while there switch from fdevname() to fdevname_r().

Sponsored by:	iXsystems, Inc.
MFC after:	2 weeks

(cherry picked from commit e49d3eb403)
2021-04-27 08:47:39 -04:00
Konstantin Belousov
f1d1021fde O_PATH: allow vnode kevent filter on such files
(cherry picked from commit bbf7a4e878)
2021-04-23 14:14:10 +03:00
Konstantin Belousov
7a24523086 Make files opened with O_PATH to not block non-forced unmount
(cherry picked from commit a5970a529c)
2021-04-23 14:14:10 +03:00
Konstantin Belousov
b0c1b3827e open(2): Implement O_PATH
(cherry picked from commit 8d9ed174f3)
2021-04-23 14:14:10 +03:00
Konstantin Belousov
73a642c479 Add AT_EMPTY_PATH for several *at(2) syscalls
(cherry picked from commit 509124b626)
2021-04-23 14:14:10 +03:00
Konstantin Belousov
8bffc9b492 link(2): correct descriptor name in AT_RESOLVE_BENEATH description
(cherry picked from commit c78e124535)
2021-04-23 14:14:09 +03:00
Konstantin Belousov
7bbfb5d959 rtld: make dlerror() thread-local
(cherry picked from commit 4d9128da54)
2021-04-23 14:14:08 +03:00
Konstantin Belousov
b75aa0eaf3 rtld: workaround for broken ABI
(cherry picked from commit 08bfbd4359)
2021-04-23 14:14:08 +03:00
Konstantin Belousov
17ef58221c libc dl_iterate_phdr(): dlpi_tls_data is wrong
(cherry picked from commit dbd2053026)
2021-04-23 14:14:07 +03:00
Konstantin Belousov
4959d4f3ea libc: implement __tls_get_addr() for static binaries
(cherry picked from commit ca46b5698e)
2021-04-23 14:14:07 +03:00
Konstantin Belousov
41331ef7f6 libc: add _get_tp() private function
(cherry picked from commit 06d8a116bd)
2021-04-23 14:14:07 +03:00
Konstantin Belousov
166b390bc5 libc: include rtld.h into static implementations of rtld interface
(cherry picked from commit 7f7489eba3)
2021-04-23 14:14:07 +03:00
Konstantin Belousov
083df155ef libc: constify dummy error message string for dlfcn
(cherry picked from commit 93c14c55ec)
2021-04-23 14:14:07 +03:00
Konstantin Belousov
c3f97dd75a rtld dl_iterate_phdr(): dlpi_tls_data is wrong
(cherry picked from commit d36d681615)
2021-04-23 14:14:06 +03:00
Andrew Walker
8845eea6e2 Fix leak in libc NFSv4 ACL flags parsing
Free memory allocated by strdup() in parse_flags_verbose().

Submitted by:	Andrew Walker <walker.aj325_gmail.com>
Reported by:	valgrind
Reviewed by:	allanjude, freqlabs, rpokala
Sponsored by:	iXsystems, Inc.
Differential Revision:	https://reviews.freebsd.org/D29871

(cherry picked from commit dd559118ab)
2021-04-23 06:41:23 -04:00
Alex Richardson
b8beded343 Allow lib/msun/logarithm_test to pass on ld128 platforms
For some reason the ld128 log1pl() implementation is less accurate than
logl(), but does at least guarantee precision >= the ld80 implementation.
Mark log1p_accuracy_tests as XFAIL for ld128 and increase the log1p tolerance
to the ld80 equivalent in accuracy_tests to avoid losing test coverage for
the other functions.

PR:		253984
Reviewed By:	ngie, dim
Differential Revision: https://reviews.freebsd.org/D29039

(cherry picked from commit 1ad83445fc)
2021-04-22 10:44:55 +01:00
Alex Richardson
d08c4d80ab Remove XFAIL from tests/lib/msun/lround_test:main
This test no longer fails after 3b00222f15.

PR:		205451
MFC after:	1 week

(cherry picked from commit 062293c2c4)
2021-04-22 10:44:55 +01:00
Alex Richardson
959cda8efc Remove amd64 XFAIL from tests/lib/msun/fma_test:infinities
This test no longer fails after 3b00222f15.

PR:		205448
MFC after:	1 week

(cherry picked from commit 3f01d8c2fe)
2021-04-22 10:44:54 +01:00