Commit Graph

789 Commits

Author SHA1 Message Date
yhardy
afb8d88625 Use vn_close to release the vnodes in the error handling blocks, since
the vnodes were opened for writing. Fix proposed on current-users
and improved by hannken@.
2020-11-28 22:53:06 +00:00
chs
dfa4ab3ed8 Remove a pointless printf. 2020-11-17 03:20:33 +00:00
chs
55aacd0e65 Commit the ZFS file that I forgot in this previous commit:
Move the handling of PG_PAGEOUT from uvm_aio_aiodone_pages() to
uvm_page_unbusy() so that all callers of uvm_page_unbusy() don't need to
handle this flag separately.  Split out the pages part of uvm_aio_aiodone()
into uvm_aio_aiodone_pages() in rump just like in the real kernel.
In ZFS functions that can fail to copy data between the ARC and VM pages,
use uvm_aio_aiodone_pages() rather than uvm_page_unbusy() so that we can
handle these "I/O" errors.  Fixes PR 55702.
2020-11-15 00:54:13 +00:00
rin
087e008143 One more catch up with ``aarch64 is not mips'' change.
Fix evbarm-aarch64 build.
2020-11-12 02:15:56 +00:00
chs
b02dfdd14a kmem_cache_create()'s "name" parameter can be on the stack,
so make a copy of it rather than keeping a pointer to it.
2020-11-11 03:31:04 +00:00
hannken
ce6d7dcd35 Stub groupmember() has to test both group list and current group id.
Fixes kern/55675: ZFS mounts do not work with setuid programs
2020-10-12 08:21:21 +00:00
kardel
75839df013 PR kern/55705:
don't attempt to sleep for negative time, we are late anyway - avoids DIAGNOSTIC panic
2020-10-09 08:18:01 +00:00
christos
09db05edfe Comment out index out of bounds debugging code. 2020-09-07 19:04:27 +00:00
mrg
d4edddf34a i can't confirm or deny that GCC 9 is wrong about parity_valid[]
having uninitialised members, but since setting up reconstruct
isn't a hot path, just zero init the whole thing to be sure.
2020-09-07 07:44:53 +00:00
christos
86b0983bea Stop using alloca 2020-09-06 21:49:44 +00:00
christos
be20a654c6 Adjust string sizes 2020-09-06 21:49:32 +00:00
christos
a2d10af9ab fix zeroing 2020-09-06 16:44:16 +00:00
hannken
cf59275916 Glue operation secpolicy_fs_mount() passes wrong arguments to
operation kauth_authorize_system().

KAUTH_SYSTEM_MOUNT / KAUTH_REQ_SYSTEM_MOUNT_NEW wants the to be
covered vnode and the mount flags, not the mount structure.

Fix for PR kern/55602: zpool panic on mounting zfs filesystem
2020-08-28 16:13:48 +00:00
hannken
381048869c Enable NCLOOKUP for ZFS. 2020-08-27 09:57:33 +00:00
riastradh
25f11de3b9 mmap MAP_FAILED audit. 2020-08-20 15:54:11 +00:00
jdolecek
0762753c60 fix bug introduced in conversion to kmem(9), passing address of the local
variable instead of pointer to allocated memory

should fix PR kern/55426 by Andreas Gustafsson
2020-06-27 21:21:11 +00:00
wiz
2680eae4a7 Sort options and their descriptions.
Replace tab with space in table.
Make non-standard section subsections.
Comment out Xr to procsystime(1) which does not exist on NetBSD.
2020-06-26 15:45:18 +00:00
uwe
aa0264d3ca Try to improve markup. 2020-06-25 14:59:51 +00:00
uwe
9a3f56c91e Try to improve markup. 2020-06-25 14:08:48 +00:00
sevan
72bdb0fb50 space, tab 2020-06-25 09:48:29 +00:00
sevan
86e1b08aff Fix column layout 2020-06-25 09:39:19 +00:00
mlelstv
bf2615aa1b Don't assume everything is a wedge and has a parent device. On non-wedges
this crashes.

Instead, just talk to the referenced device and rely on the dk driver
to pass requests correctly.
2020-06-25 09:39:15 +00:00
sevan
5c85b20eb8 No truss here 2020-06-24 18:49:01 +00:00
sevan
115e612e0f mdocify 2020-06-24 18:43:38 +00:00
sevan
7226fd0ff8 mdocify 2020-06-24 18:06:01 +00:00
jdolecek
ce67beced2 reduce stack usage in dsl_scan_recurse() - allocate memory for
temporary zbookmark_phys_t using kmem_alloc() rather than stack;
this recuses several times usually, and this saves 2x
sizeof(zbookmark_phys_t) == 64 bytes per recursion

part of fix for PR kern/55402 by Frank Kardel
2020-06-24 16:29:34 +00:00
jdolecek
41a612de4f change dsl_scan_visitbp() to allocate blkptr_t dynamically rather than
on-stack - this function is called recursively, and the 120 bytes per call
add up; also remove unused variable

part of fix for PR kern/55402 by Frank Kardel
2020-06-24 16:23:16 +00:00
jdolecek
5964fe3b97 reduce stack usage in vdev_queue_io_to_issue() - zio_t is about 1KB, and
the function potentially recurses into itself

part of fix for PR kern/55402 by Frank Kardel
2020-06-24 16:16:01 +00:00
jmcneill
62a169693c If calling d_minphys on the parent disk device, make sure we use the
parent disk device's dev_t. Fixes zfs on wedges on ld(4).

XXX pullup-9
2020-06-21 21:29:11 +00:00
jdolecek
99379c717f use pool_cache for (meta)data buffers also on NetBSD
this should generally slightly improve performance on MP systems, and
specifically for xbd(4) storage avoids slow unaligned I/O buffer handling

this change requires updated kernel, to allow up to SPA_MAXBLOCKSHIFT item
size for pools

fixes PR kern/55397 by Frank Kardel
2020-06-19 14:13:23 +00:00
ad
4b8a875ae2 uvm_availmem(): give it a boolean argument to specify whether a recent
cached value will do, or if the very latest total must be fetched.  It can
be called thousands of times a second and fetching the totals impacts not
only the calling LWP but other CPUs doing unrelated activity in the VM
system.
2020-06-11 19:20:42 +00:00
fox
1644357e99 external/cddl/osnet: Suppress -Werror=stringop-truncation error
This logic correctly uses strncpy(3) to fully initialize a fixed-width field, and also ensures
NUL-termination on the next line as other users of the field expect.

Add -Werror=stringop-truncation to prevent build failure, when run with MKSANITIZER=yes.

Error was reported when build.sh was run with MKSANITIZER=yes flag.

Reviewed by: kamil@
2020-06-07 23:26:54 +00:00
hannken
24c6f44f9c Replace vp->v_count with vrefcnt(vp) and
remove now unneeded "#define v_count ...".
2020-05-26 08:39:27 +00:00
ad
0eaaa024ea Move proc_lock into the data segment. It was dynamically allocated because
at the time we had mutex_obj_alloc() but not __cacheline_aligned.
2020-05-23 23:42:41 +00:00
ad
154ae82447 Fix bugs in previous. 2020-05-21 20:43:23 +00:00
ad
e9af4fa226 zfs_netbsd_getpages:
- implement the PGO_LOCKED case
- handle npages > 1 for PGO_SYNCIO
2020-05-20 20:47:18 +00:00
christos
9aa2a9c323 Add ACL support for FFS. From FreeBSD. 2020-05-16 18:31:45 +00:00
ad
4c6ec8e8eb Bump PROF_ARTIFICIAL_FRAMES to 4 now that cyclics are run from statclock(). 2020-05-15 23:57:17 +00:00
chs
cc0d11d270 fix the handling in putpage of the page containing EOF. 2020-05-13 05:52:54 +00:00
ad
8122ec364a Run Solaris cyclics from statclock() so dtrace isn't locked out by IPL_SCHED
(assuming the machine has a separate statclock() which almost all don't).
2020-05-08 22:10:08 +00:00
hannken
f106ce5415 Operation zfs_zget_cleaner() cannot fail, comment and add assertions. 2020-05-07 09:13:06 +00:00
hannken
1243122ba6 Revert Rev. 1.31 as it is no longer possible for the handle to be NULL. 2020-05-07 09:12:31 +00:00
hannken
5e7dc406e9 Revert Rev. 1.63 and add a comment why we have to zil_commit() here:
Operation zfs_znode.c::zfs_zget_cleaner() depends on this
zil_commit() as a barrier to guarantee the znode cannot
get freed before its log entries are resolved.
2020-05-07 09:12:03 +00:00
maxv
daaf22542e Modify the hotpatch mechanism, in order to make it much less ROP-friendly.
Currently x86_patch_window_open is a big problem, because it is a perfect
function to inject/modify executable code with ROP.

 - Remove x86_patch_window_open(), along with its x86_patch_window_close()
   counterpart.
 - Introduce a read-only link-set of hotpatch descriptor structures,
   which reference a maximum of two read-only hotpatch sources.
 - Modify x86_hotpatch() to open a window and call the new
   x86_hotpatch_apply() function in a hard-coded manner.
 - Modify x86_hotpatch() to take a name and a selector, and have
   x86_hotpatch_apply() resolve the descriptor from the name and the
   source from the selector, before hotpatching.
 - Move the error handling in a separate x86_hotpatch_cleanup() function,
   that gets called after we closed the window.

The resulting implementation is a bit complex and non-obvious. But it
gains the following properties: the code executed in the hotpatch window
is strictly hard-coded (no callback and no possibility to execute your own
code in the window) and the pointers this code accesses are strictly
read-only (no possibility to forge pointers to hotpatch an area that was
not designated as hotpatchable at compile-time, and no possibility to
choose what bytes to write other than the maximum of two read-only
templates that were designated as valid for the given destination at
compile-time).

With current CPUs this slightly improves a situation that is already
pretty bad by definition on x86. Assuming CET however, this change closes
a big hole and is kinda great.

The only ~problem there is, is that dtrace-fbt tries to hotpatch random
places with random bytes, and there is just no way to make it safe.
However dtrace is only in a module, that is rarely used and never compiled
into the kernel, so it's not a big problem; add a shitty & vulnerable
independent hotpatch window in it, and leave big XXXs. It looks like fbt
is going to collapse soon anyway.
2020-05-02 11:37:17 +00:00
riastradh
499bfa80cb Fix crgetgroups shim.
- Don't use a static buffer for the result.

- kauth_cred_getgroups refuses to return more than the actual number
  of groups, so passing NGROUPS_MAX generally doesn't work.

To avoid patching zfs, just expose struct kauth_cred::cr_groups
directly, with __KAUTH_PRIVATE.  Unclear why the official API only
exposes it via memcpy or copyout anyway.

This makes unprivileged zfs operations work, by anyone with access to
/dev/zfs (which is conventionally mode 777, and which we should maybe
set it to by default; zfs has its own ACL system, zfs allow).
2020-04-29 05:54:37 +00:00
riastradh
e6079aec7f Set up more of a fake struct buf, for ldminphys.
Fixes:

arm64# zpool create rpool ld4
[ 198.4376097] panic: Trap: Data Abort (EL1): Translation Fault L1 with read access for 0000000000000178: pc ffffc0000017acf4: opcode f940bc00: ldr x0, [x0,#376]
[ 198.4694793] fp ffffc00073026660 ldminphys() at ffffc0000017acf4 netbsd:ldminphys+0x34
[ 198.4792624] fp ffffc00073026680 vdev_disk_open.part.4() at ffffc000013d4c4c zfs:vdev_disk_open.part.4+0x37c
[ 198.4792624] fp ffffc000730268d0 vdev_open() at ffffc000013d2530 zfs:vdev_open+0x68
[ 198.4792624] fp ffffc00073026920 vdev_open_children() at ffffc000013d2958 zfs:vdev_open_children+0x40
[ 198.4792624] fp ffffc00073026950 vdev_root_open() at ffffc000013dad48 zfs:vdev_root_open+0x30

XXX pullup-9
2020-04-29 04:30:40 +00:00
ad
23bf88000c Replace most uses of vp->v_usecount with a call to vrefcnt(vp), a function
that hides the details and does atomic_load_relaxed().  Signature matches
FreeBSD.
2020-04-13 19:23:17 +00:00
mlelstv
946cdc57b6 When collecting zpool devices, skip disks with wedges so that a
concurrent test of a wedge on that disk doesn't fail.
2020-04-04 13:45:22 +00:00
christos
d920a30f1a Add libproc 2020-04-04 13:15:48 +00:00
hannken
f829bc96b4 With zfs_netbsd_reclaim() no longer doing an unconditional
zil commit dmu_buf_get_user() may return a NULL handle when
the znode already disappeared.
2020-03-20 08:26:01 +00:00