Commit Graph

19841 Commits

Author SHA1 Message Date
Mateusz Guzik
ddf6571230 amd64: align target memmove buffer to 16 bytes before using rep movs
See the review for sample test results.

Reviewed by:	kib (kernel part)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D18401
2018-12-01 14:20:32 +00:00
Mateusz Guzik
94243af2da amd64: handle small memmove buffers with overlapping stores
Handling sizes of > 32 backwards will be updated later.

Reviewed by:	kib (kernel part)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D18387
2018-11-30 20:58:08 +00:00
Mariusz Zaborski
77ebcc05ea libcasper: do not fail if Capsicum is not avilable
Casper service can be also used on the kernels without Capsicum support.

Reported by:	sbruno
Tested by:	sbruno
2018-11-30 19:27:14 +00:00
Eric van Gyzen
dbb1c64e82 Use _thr_isthreaded() and _thr_setthreaded() wrappers
...instead of directly using the global variable.

MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2018-11-30 03:02:49 +00:00
Eric van Gyzen
ad8c236b28 _thr_setthreaded() cannot fail; change return type to void
Also remove logic to avoid unnecessary stores to the global variable.
Thread creation and destruction are heavy enough that any supposed savings
is in the noise.

MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2018-11-30 03:01:32 +00:00
Mateusz Guzik
2847cfce54 amd64: remove stale attribution for memmove work
While the routine started as expanded bcopy, it is now entirely rewritten.

Sponsored by:	The FreeBSD Foundation
2018-11-30 00:47:36 +00:00
Mateusz Guzik
dd219e5ea5 amd64: tidy up copying backwards in memmove
For non-ERMS case the code used handle possible trailing bytes with
movsb first and then followed it up with movsq. This also happened
to alter how calculations were done for other cases.

Handle the tail with regular movs, just like when copying forward.
Use leaq to calculate the right offset from the get go, instead of
doing separate add and sub.

This adjusts the offset for non-rep cases so that they can be used
to handle the tail.

The routine is still a work in progress.

Sponsored by:	The FreeBSD Foundation
2018-11-30 00:45:10 +00:00
Dag-Erling Smørgrav
a768df3e91 When deciding whether to send the complete URL or just the document part,
we were looking at the original URL rather than the one we were currently
processing.  This meant that if we were trying to retrieve an HTTP URL but
were redirected to an HTTPS URL, and HTTPS proxying was enabled, we would
send an invalid request and most likely get garbage back.

MFC after:	3 days
2018-11-27 16:23:17 +00:00
Dag-Erling Smørgrav
cdd2df880d Add a “skip_dsn” option to g_part's bootcode verb to prevent g_part_mbr
from setting the volume serial number.  This unbreaks older boot blocks
that don't support serial numbers, and allows boot0cfg to set the serial
number itself if requested by the user.

Submitted by:	lev@, yuripv@
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D17386
2018-11-27 14:58:19 +00:00
Dag-Erling Smørgrav
ceedec4bce A few more cases where strcasecmp() is no longer required.
MFC after:	1 week
2018-11-27 11:22:19 +00:00
Dag-Erling Smørgrav
8d9de5b10a Improve URL parsing. In particular, convert scheme and host to lowercase.
MFC after:	1 week
2018-11-27 10:45:14 +00:00
Dag-Erling Smørgrav
b68815f088 Support proxying FTP over HTTPS, not just HTTP.
There is probably a PR for this, but I can't find this, or remember who
submitted it.  The patch got lost in the noise of another that wasn't
ready to commit.

MFC after:	3 days
2018-11-27 10:06:41 +00:00
Dag-Erling Smørgrav
e86caa0bd0 Style cleanup. 2018-11-27 09:41:47 +00:00
Kirk McKusick
4391a9c0e9 Bring up to date with recently added functions berase(3), getinode(3),
putinode(3), sbget(3), and sbput(3).

Sponsored by: Netflix
2018-11-26 23:09:45 +00:00
Martin Matuska
d28d5e1457 libarchive configuration changes
- move HAVE_BZLIB_H, HAVE_LIBLZMA and HAVE_LZMA_H to config_freebsd.h
- activate support for multi-threaded lzma encoding [1]

PR:		233543 [1]
Reported by:	cem
MFC after:	1 week
2018-11-26 21:45:27 +00:00
Ed Maste
cac83db9b7 revert r340640 "libc: forcibly disable BIND_NOW"
When immediate bind mode is requested, as of r340675 rtld processes
irelocs in PLT immediately after other PLT relocs.  That addresses the
libc + BIND_NOW startup crash the workaround is no longer needed.

PR:		233333
2018-11-26 13:56:19 +00:00
Baptiste Daroussin
6bbd1d19fd libedit: improve multibyte support
Until this commit libedit only supported UTF-8 for multibyte charset
Improve it to support other multibyte charsets

Tested with eucJP and SJIS charsets.
Note that this change as been review and committed in upstream libedit
as well via christos@NetBSD

Submitted by:	naito.yuichiro _at_ gmail.com
Reviewed by:	bapt, pfg, yuripv, 0mp
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D17903
2018-11-26 08:16:33 +00:00
Andrew Turner
266900be14 Re-enable the dynamiclib tests. These should be fixed by r340910. 2018-11-24 18:25:00 +00:00
Andrew Turner
e5c0fd4be6 Add the missing 0 at the end of the .jcr section.
Without this the dynamic library test was failing as it was calling
_Jv_RegisterClasses multiple times.
2018-11-24 18:23:53 +00:00
Andrew Turner
ab1e0d2410 Disable the dynamiclib test until a failure can be debugged 2018-11-24 16:05:40 +00:00
Andrew Turner
e1fa5626cf Mark the function called by the MIPS .init/.fini sequence with .local.
As with r328939 we need to mark local symbols as such. Without this the
assembly parser treats the symbols as global and created relocations
against these private symbols.

MFC with:	r339738
Sponsored by:	DARPA, AFRL
2018-11-23 16:33:03 +00:00
Yuri Pankov
63cbe8d1d9 regexec: fix processing multibyte strings.
Matcher function incorrectly assumed that moffset that we get from
findmust is in bytes. Fix this by introducing a stepback function,
taking short path if MB_CUR_MAX is 1, and going back byte-by-byte,
checking if we have a legal character sequence otherwise.

PR:		153502
Reviewed by:	pfg, kevans
Approved by:	kib (mentor, implicit)
Differential revision:	https://reviews.freebsd.org/D18297
2018-11-23 15:49:18 +00:00
Mateusz Piotrowski
f5c8cb4c35 Cross-reference libbe(3) and bectl(8).
Those two manual pages are already referencing each other in the HISTORY
sections, which people might skip. Mention those manual pages explicitly in
the SEE ALSO sections.  Also, remove a reference to be(1) from libbe(3).

Reviewed by:	bcr
Approved by:	krion (mentor, implicit), mat (mentor, implicit)
Differential Revision:	https://reviews.freebsd.org/D18136
2018-11-21 12:46:28 +00:00
Mateusz Piotrowski
cc58f749fb libbe(3): Put each error value in separate line.
As requested by a TODO in the source code.

Reviewed by:	bcr
Approved by:	krion (mentor, implicit), mat (mentor, implicit)
Differential Revision:	https://reviews.freebsd.org/D18063
2018-11-21 11:22:44 +00:00
Ed Maste
b18e62b6da csu: use BSD-1-clause license on csu files
Copyright on these files is held by kib@ and/or the Foundation, and both
agree to this change.

Approved by:	kib
2018-11-20 21:04:20 +00:00
Ed Maste
bbce18b8d1 Add NT_FREEBSD_FEATURE_CTL ELF note to csu
This note will be used to allow binaries to opt out of, or in to,
upcoming vulnerability mitigation and other features.  It is not yet
connected but being added now to facilitate testing and ensure
compatibility with existing kernels and tools.

Reviewed by:	brooks, jhb, kib, markj
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D17438
2018-11-20 20:59:49 +00:00
Edward Tomasz Napierala
a4f02d5d6d Make libthr(3) use sysconf(_SC_NPROCESSORS_CONF); this shaves off
two calls to sysctl(2) from the binary startup.

Reviewed by:	kib
MFC after:	2 weeks
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D18046
2018-11-19 18:24:08 +00:00
Edward Tomasz Napierala
3a9cdc5132 Make sysconf(_SC_PAGESIZE) return the value from getpagesize(3).
That avoids a syscall - getpagesize(3) gets the value from the ELF
aux strings.

Reviewed by:	kib
MFC after:	2 weeks
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D17989
2018-11-19 18:23:17 +00:00
Ed Maste
00bf4d2515 libc: forcibly disable BIND_NOW
Building libc WITH_BIND_NOW results in segfault at process start.  For
now force BIND_NOW off until the root cause can be identified and fixed.

PR:		233333
Sponsored by:	The FreeBSD Foundation
2018-11-19 18:12:39 +00:00
Mariusz Zaborski
2863fd2f27 libcasper: provide compatibility with the old version of service
Some external tools like tcpdump(1) have upstream the changes with old limits
name. Because of that provide compatibility with the old names.

Reported by:	emaste
2018-11-19 17:22:52 +00:00
Kyle Evans
4ab5187d38 libbe(3): Handle non-ZFS rootfs better
If rootfs isn't ZFS, current version will emit an error claiming so and fail
to initialize libbe. As a consumer, bectl -r (undocumented) can be specified
to operate on a BE independently of whether on a UFS or ZFS root.

Unbreak this for the UFS case by only erroring out the init if we can't
determine a ZFS dataset for rootfs and no BE root was specified. Consumers
of libbe should take care to ensure that rootfs is non-empty if they're
trying to use it, because this could certainly be the case.

Some check is needed before zfs_path_to_zhandle because it will
unconditionally emit to stderr if the path isn't a ZFS filesystem, which is
unhelpful for our purposes.

This should also unbreak the bectl(8) tests on a UFS root, as is the case in
Jenkins' -test runs.

MFC after:	3 days
2018-11-19 16:47:21 +00:00
Kyle Evans
af43c24d3d libbe(3): Properly account for altroot when creating new BEs
Previously we would blindly copy the 'mountpoint' property, which includes
the altroot. The altroot needs to be snipped off prior to setting it on the
new BE, though, or you'll end up with a new BE and a mountpoint of /mnt with
altroot=/mnt

MFC after:	3 days
2018-11-19 02:16:20 +00:00
Kyle Evans
cc624025b4 bectl(3)/libbe(3): Allow BE root to be specified
Add an undocumented -r option preceding the bectl subcommand to specify a BE
root to operate out of. This will remain undocumented for now, as some
caveats apply:

- BEs cannot be activated in the pool that doesn't contain the rootfs
- bectl create cannot work out of the box without the -e option right now,
  since it defaults to the rootfs and cross-pool cloning doesn't work like
  that (IIRC)

Plumb the BE root through to libbe(3) so that some things -can- be done to
it, e.g.

bectl -r tank/ROOT create -e default upgrade
bectl -r tank/ROOT mount upgrade /mnt

this aides in some upgrade setups where rootfs is not necessarily ZFS, and
also makes it easier/possible to regression-test bectl when combined with a
file-backed zpool.

MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D18029
2018-11-19 02:12:08 +00:00
Mariusz Zaborski
fd253945ac Update the names in the LIMITS and EXAMPLES sections after r340363.
Reported by:	markj
2018-11-18 11:11:27 +00:00
Kyle Evans
efd6500d03 libbe(3): Rewrite be_unmount to stop mucking with getmntinfo(2)
Go through the ZFS layer instead; given a BE, we can derive the dataset,
zfs_open it, then zfs_unmount. ZFS takes care of the dirty details and
likely gets it more correct than we did for more interesting setups.

MFC after:	3 days
2018-11-17 19:19:37 +00:00
Kyle Evans
51aecc893a libbe(3): rewrite init to support chroot usage
libbe(3) currently uses zfs_be_root and locates which of its children is
currently mounted at "/". This is reasonable, but not correct in the case of
a chroot, for two reasons:

- chroot root may be of a different zpool than zfs_be_root
- chroot root will not show up as mounted at "/"

Fix both of these by rewriting libbe_init to work from the rootfs down.
zfs_path_to_zhandle on / will resolve to the dataset mounted at the new
root, rather than the real root. From there, we can derive the BE root/pool
and grab the bootfs off of the new pool. This does no harm in the average
case, and opens up bectl to operating on different pools for scenarios where
one may be, for instance, updating a pool that generally gets re-rooted into
from a separate UFS root or zfs bootpool.

While here, I've also:
- Eliminated the check for /boot and / to be on the same partition. This
  leaves one open to a setup where /boot (and consequently, kernel/modules)
  are not included in the boot environment. This may very well be an
  intentional setup done by someone that knows what they're doing, we should
  not kill BE usage because of it.

- Eliminated the validation bits of BEs and snapshots that enforced
  'mountpoint' to be "/" -- this broke when trying to operate on an imported
  pool with an altroot, but we need not be this picky.

Reported by:	philip
Reviewed by:	philip, allanjude (previous version)
Tested by:	philip
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D18012
2018-11-17 19:15:29 +00:00
Mateusz Guzik
088ac3ef4b amd64: handle small memset buffers with overlapping stores
Instead of jumping to locations which store the exact number of bytes,
use displacement to move the destination.

In particular the following clears an area between 8-16 (inclusive)
branch-free:

movq    %r10,(%rdi)
movq    %r10,-8(%rdi,%rcx)

For instance for rcx of 10 the second line is rdi + 10 - 8 = rdi + 2.
Writing 8 bytes starting at that offset overlaps with 6 bytes written
previously and writes 2 new, giving 10 in total.

Provides a nice win for smaller stores. Other ones are erratic depending
on the microarchitecture.

General idea taken from NetBSD (restricted use of the trick) and bionic
string functions (use for various ranges like in this patch).

Reviewed by:	kib (previous version)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D17660
2018-11-16 00:44:22 +00:00
Mateusz Guzik
ad2ff705a4 amd64: sync up libc memset with the kernel version
- tidy up memset to have rax set earlier for small sizes
- finish the tail in memset with an overlapping store
- align memset buffers to 16 bytes before using rep stos

Sponsored by:	The FreeBSD Foundation
2018-11-15 20:28:35 +00:00
Mateusz Guzik
6fff634455 amd64: convert libc bzero to a C func to avoid future bloat
Reviewed by:	kib (previous version)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D17549
2018-11-15 20:20:39 +00:00
Alan Somers
a14a34ef62 fcntl.2: document an additional error condition
MFC after:	2 weeks
2018-11-15 16:13:25 +00:00
Konstantin Belousov
1c4ca77890 Add d_off support for multiple filesystems.
The d_off field has been added to the dirent structure recently.
Currently filesystems don't support this feature.  Support has been
added and tested for zfs, ufs, ext2fs, fdescfs, msdosfs and unionfs.
A stub implementation is available for cd9660, nandfs, udf and
pseudofs but hasn't been tested.

Motivation for this feature: our usecase is for a userspace nfs server
(nfs-ganesha) with zfs.  At the moment we cache direntry offsets by
calling lseek once per entry, with this patch we can get the offset
directly from getdirentries(2) calls which provides a significant
speedup.

Submitted by:	Jack Halford <jack@gandi.net>
Reviewed by:	mckusick, pfg, rmacklem (previous versions)
Sponsored by:	Gandi.net
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D17917
2018-11-14 14:18:35 +00:00
Yuri Pankov
98f3acfaaf Fix WITHOUT_ICONV build after r340276.
Reported by:	olivier
Approved by:	kib (mentor, implicit)
2018-11-14 09:06:15 +00:00
Kirk McKusick
9fc5d538fc In preparation for adding inode check-hashes, clean up and
document the libufs interface for fetching and storing inodes.
The undocumented getino / putino interface has been replaced
with a new getinode / putinode interface.

Convert the utilities that had been using the undocumented
interface to use the new documented interface.

No functional change (as for now the libufs library does not
do inode check-hashes).

Reviewed by:  kib
Tested by:    Peter Holm
Sponsored by: Netflix
2018-11-13 21:40:56 +00:00
Mark Johnston
991666adc7 Ensure that libnv can be used when kern.trap_enotcap=1.
libnv used fcntl(fd, F_GETFL) to test whether fd is a valid file
descriptor.  Aside from being racy, this check requires CAP_FCNTL
rights on fd.  Instead, use fcntl(fd, F_GETFD), which does not require
any capability rights.

Also remove some redundant fd_is_valid() checks to avoid extra system
calls; in many cases we were performing this check immediately before
dup()ing the descriptor.

Reviewed by:	cem, oshogbo (previous version)
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D17963
2018-11-13 20:07:55 +00:00
Andrew Turner
b7305f91e4 Run __cxa_finalize in shared objects in the destructor path.
When we have .dtors call them before .dtor handling, otherwise call from
a destructor.

PR:		233056
MFC with:	r339738
Sponsored by:	DARPA, AFRL
2018-11-13 15:28:27 +00:00
Ed Maste
7c807d7708 retire LINKER_FEATURES filter flag
And build libdl unconditionally.  All supported FreeBSD linkers accept
-F / --filter so there is no need to test for support.

Discussed with:	kib
Sponsored by:	The FreeBSD Foundation
2018-11-12 20:44:22 +00:00
Konstantin Belousov
44748aa487 Create namespace for the symbols added during 13-CURRENT cycle.
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2018-11-12 19:12:14 +00:00
Mariusz Zaborski
2607c01b66 Fix typo in the comparison.
This fix build with gcc.

Reported by:	jenkins
2018-11-12 18:37:31 +00:00
Mariusz Zaborski
cdd6ea94b0 libcasper: introduce cap_fileargs service
cap_fileargs is a Casper service which helps to sandbox applications that need
access to the filesystem namespace. The main purpose of the service is to make
easy to capsicumize applications that works on multiple files passed in argv.

We have a couple example of using it but we still treat this service as an
experimental one.

Reviewed by:	emsate (previous version), jonathan (partially)
Discussed with:	many
Differential Revision:	https://reviews.freebsd.org/D14407
2018-11-12 17:40:47 +00:00
Mariusz Zaborski
752d135e0d libcasper: ange the name of limits in cap_dns so the intentions are obvious.
Reported by:	pjd
MFC after:	3 weeks
2018-11-12 15:52:45 +00:00