Commit Graph

774 Commits

Author SHA1 Message Date
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
fox
ea2ed373b0 external/cddl/osnet: Do not suppress the warning output for libdtrace.
Changed -Wno-maybe-uninitialized to -Wno-error=maybe-uninitialized to allow
warnings to be printed out during build.

Suggested by: christos@
2020-03-17 01:36:29 +00:00
fox
cc6a7388a1 external/cddl/osnet: Fix -Werror=maybe-uninitialized error in zfs_acl.c.
Detected by build.sh with MKLIBCSANITIZER=yes and fixed upstream, pick only the fix from the commit.

Upstream commits

100a91aa3e
100a91aa3e

Cherry-pick:
From 100a91aa3e9773f2a2a373c5cb066b52c780716c Mon Sep 17 00:00:00 2001
From: Chunwei Chen <david.chen@osnexus.com>
Date: Fri, 17 Jun 2016 17:36:01 -0700
Subject: [PATCH] Fix NFS credential

Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #4772
Closes #4758

Reviewed by: kamil@
2020-03-17 00:54:03 +00:00
fox
6594959c4a external/cddl/osnet: Supress -Werror=maybe-uninitialized error in libdtrace.
It looks like this is a false positive, since the section of code triggering the error

external/cddl/osnet/dist/lib/libdtrace/common/dt_proc.c:400:42:

is only accessed after "err" is initialized.

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

Reviewed by: kamil@
2020-03-17 00:50:12 +00:00
ad
da3ef92bf6 Make uvm_pagemarkdirty() responsible for putting vnodes onto the syncer
work list.  Proposed on tech-kern@.
2020-03-14 20:45:23 +00:00
fox
9fab322cb1 external/cddl/osnet: Fix possible null pointer access.
Detected by UBSan and fixed upstream, pick only the fix from the commit.

Cherry-pick:
From 928e8ad47d3478a3d5d01f0dd6ae74a9371af65e Mon Sep 17 00:00:00 2001
From: Serapheim Dimitropoulos <serapheimd@gmail.com>
Date: Wed, 20 Feb 2019 09:59:57 -0800
Subject: [PATCH] Introduce auxiliary metaslab histograms

Reviewed by: Paul Dagnelie <pcd@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed by: Matt Ahrens <mahrens@delphix.com>
Signed-off-by: Serapheim Dimitropoulos <serapheim@delphix.com>
Closes #8358

Reviewed by: kamil@
2020-03-09 15:40:50 +00:00
fox
998369905c external/cddl/osnet: Fix possible signed integer overflow
Detected by UBSan and fixed upstream

Cherry-pick:
From 05852b3467b44cdf88541ec67624cd1f5f2ded1d Mon Sep 17 00:00:00 2001
From: luozhengzheng <luo.zhengzheng@zte.com.cn>
Date: Fri, 14 Oct 2016 05:25:05 +0800
Subject: [PATCH] Fix coverity defects: CID 147571, 147574

CID 147571: Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN)
CID 147574: Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN)

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: luozhengzheng <luo.zhengzheng@zte.com.cn>
Closes #5268

Reviewed by: kamil@
2020-03-09 15:37:46 +00:00
mgorny
d783b29581 Update dtrace errno.d mapping and add a script for it
Add a new script to autogenerate errno.d from errno.h, and use it
to regenerate the list to match NetBSD errno codes.
2020-03-08 22:11:48 +00:00
riastradh
9a5bc0da50 Avoid unnecessary zil_commit on rm.
1. Issue zil_commit only if we're actually updating something --
   there's no need to commit if we're unlinking the file or if
   there's no atime update being applied.

2. Issue zil_commit only if the zfs has sync=always set -- for
   sync=standard there's no need for us to commit anything here since
   no application asked for an explicit sync.

Speeds up untarring base.tgz on top of itself by a factor of about
2x, and speeds up rm by a factor of about 10x, on my system with an
SSD SLOG over SATA.  Histogram of unlink, rmdir, and rename timing
shows dramatic reduction in latency for most samples.

(To be fair, this was not an improvement over zfs; issuing the
unnecessary zil_commit was a self-inflicted performance wound.)
2020-03-08 19:59:45 +00:00
wiz
80e58ff06c genric -> generic 2020-03-05 22:44:19 +00:00
riastradh
3a391130d2 Revert "Add fixup operation to remove private mutex types for x86."
The x86 (and arm) definitions of struct kmutex are no longer defined
differently depending on __MUTEX_PRIVATE.
2020-03-05 16:05:05 +00:00
riastradh
338179b531 Use vpanic, not vprintf and then panic. 2020-03-03 06:44:38 +00:00
riastradh
ffcf681ee3 New ioctl DIOCGSECTORALIGN returns sector alignment parameters.
struct disk_sectoralign {
	/* First aligned sector number.  */
	uint32_t dsa_firstaligned;

	/* Number of sectors per aligned unit.  */
	uint32_t dsa_alignment;
};

- Teach wd(4) to get it from ATA.
- Teach cgd(4) to pass it through from the underlying disk.
- Teach dk(4) to pass it through with adjustments.
- Teach zpool (zfs) to take advantage of it.
  => XXX zpool doesn't seem to understand when the vdev's starting
     sector is misaligned.

Missing:

- ccd(4) and raidframe(4) support -- these should support _using_
  DIOCGSECTORALIGN to decide where to start putting ccd or raid
  stripes on disk, and these should perhaps _implement_
  DIOCGSECTORALIGN by reporting the stripe/interleave factor.

- sd(4) support -- I don't know any obvious way to get it from SCSI,
  but if any SCSI wizards know better than I, please feel free to
  teach sd(4) about it!

- any ld(4) attachments -- might be worth teaching the ld drivers for
  nvme and various raid controllers to get the aligned sector size

There's some duplicate logic here for now.  I'm doing it this way,
rather than gathering the logic into a new disklabel_sectoralign
function or something, so that this change is limited to adding a new
ioctl, without any new kernel symbols, in order to make it easy to
pull up to netbsd-9 without worrying about the module ABI.
2020-03-02 16:01:56 +00:00
kamil
ce57424237 Fix undefined behavior in misaligned pointer usage
Detected by UBSan and already fixed upstream.

Cherry-pick:
From aa0218d6a12814fac50b287214f9f3b0b99e11b1 Mon Sep 17 00:00:00 2001
From: Brian Behlendorf <behlendorf1@llnl.gov>
Date: Tue, 7 Jan 2014 23:24:37 +0100
Subject: [PATCH] Fix nvlist 'Bus Error' for Sparc

The mis-aligned memory accesses in nvpair_native_embedded() and
nvpair_native_embedded_array() will cause a 'Bus Error' for
architectures such as Sparc which not fully byte addressible.
To avoid this issue care is taken to avoid dereferencing the
potentially mis-aligned packed nvlist_t.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: marku89 <mar42@kola.li>
Issue #1700
2020-03-02 15:45:33 +00:00
mlelstv
8b765a5da5 Use utility functions to handle disk geometry. 2020-02-29 17:15:43 +00:00
mlelstv
5568ea814a Fix disk geometry calculation. Add DIOCGPARTINFO to support
getdisksize() used by other drivers, filesystems and specfs.
2020-02-29 17:03:33 +00:00