Commit Graph

300737 Commits

Author SHA1 Message Date
skrll 1144d080df KASSERT(kpreempt_disabled()) before accessing curcpu() 2023-04-22 10:22:43 +00:00
tsutsui d6e282afba Remove ancient /*ARGSUSED*/ comments. 2023-04-22 10:09:12 +00:00
skrll 1674da94a1 G/C pte_index 2023-04-22 10:03:53 +00:00
tsutsui f9df6ee016 Remove ancient /*ARGSUSED*/ comments. 2023-04-22 10:00:24 +00:00
skrll 7fc70db482 Move fdt_update_stdout_path from evbarm code to MI code 2023-04-22 09:53:45 +00:00
rillig 8e1084f184 lint: fix typos in comments 2023-04-22 09:39:14 +00:00
tsutsui 521fe5f3f1 Remove ancient /* ARGSUSED */ lint comments. 2023-04-21 23:01:59 +00:00
tsutsui 6d7bfad47a Remove ancient /* ARGSUSED */ lint comments. 2023-04-21 22:44:27 +00:00
tsutsui 97076c53d9 Avoid an extern declaration in .c file. Just declare it as static.
Suggested on tech-userlevel@.
2023-04-21 22:43:11 +00:00
gutteridge 04d453bc9d Add new test t_open_pr_57260
New test case that reflects the fix in PR kern/57260. The majority of
work for this case itself was by riastradh@, who'd supplied the basis
for it in the ticket, and provided further guidance.
2023-04-21 21:50:04 +00:00
abs 384f6a9e2e Fix incorrect test for FUSE_USE_VERSION 34
(Thanks to Mark Davies for report)
2023-04-21 19:29:31 +00:00
riastradh 58e3e0ea57 dk(4): Narrow the scope of the device numbering lookup on detach.
Just need it for vdevgone, order relative to other things in detach
doesn't matter.

No functional change intended.
2023-04-21 18:54:09 +00:00
riastradh a3597aeef1 dk(4): dkdump: Simplify. No functional change intended. 2023-04-21 18:45:13 +00:00
riastradh 9c2d6869ce dk(4): Omit needless locking in dksize, dkdump.
All the members these use are stable after initialization, except for
the wedge size, which dkwedge_size safely reads a snapshot of without
locking in the caller.
2023-04-21 18:44:58 +00:00
riastradh a5eec8cb2f dk(4): Take a read-lock on dkwedges_lock if we're only reading.
- dkwedge_find_by_name
- dkwedge_find_by_parent
- dkwedge_print_wnames
2023-04-21 18:44:18 +00:00
riastradh 5f51c927dc dk(4): Set .d_cfdriver and .d_devtounit to plug open/detach race.
This way, opening dkN or rdkN will wait if attach or detach is still
in progress, and vdevgone will wake up such pending opens and make
them fail.  So it is no longer possible for a wedge to be detached
after dkopen has already started using it.

For now, we use a custom .d_devtounit function that looks up the
autoconf unit number via the dkwedges array, which conceivably may
use an independent unit numbering system -- nothing guarantees they
match up.  (In practice they will mostly match up, but concurrent
wedge creation could lead to different numbering.)  Eventually this
should be changed so the two numbering systems match, which would let
us delete the new dkunit function and just use dev_minor_unit like
many other drivers can.
2023-04-21 18:31:00 +00:00
riastradh 932706d0fa dk(4): Use disk_begindetach and rely on vdevgone to close instances.
The first step is to decide whether we can detach (if forced, yes; if
not forced, only if not already open), and prevent new opens if so.
There's no need to start closing open instances at this point --
we're just making a decision to detach, and preventing new opens by
transitioning state that dkopen will respect[*].

The second step is to force all open instances to close.  This is
done by vdevgone.  By the time vdevgone returns, there can be no open
instances, so if there _were_ any, closing them via vdevgone will
have passed through dklastclose.

After that point, there can be no opens and no I/O operations, so
dk_openmask must already be zero and the bufq must be empty.

Thus, there's no need to have an explicit call to dklastclose (via
dkwedge_cleanup_parent) before or after making the decision to
detach.

[*] Currently access to this state is racy: nothing serializes
    dkwedge_detach's state transition with dkopen's test.  TBD in a
    separate commit shortly.
2023-04-21 18:30:52 +00:00
riastradh 385414544c dk(4): Fix callout detach race.
1. Set a flag sc_iostop under the lock sc_iolock so dkwedge_detach
   and dkstart don't race over it.

2. Decline to schedule the callout if sc_iostop is set.  The callout
   is already only ever scheduled while the lock is held.

3. Use callout_halt to wait for any concurrent callout to complete.
   At this point, it can't reschedule itself.

Without this change, the callout could be concurrently rescheduling
itself as we issue callout_stop, leading to use-after-free later.
2023-04-21 18:30:32 +00:00
riastradh 30a457d3c8 dk(4): Add null d_cancel routine to devsw.
This way, dkclose is guaranteed that dkopen, dkread, dkwrite,
dkioctl, &c., have all returned before it runs.  For block opens,
setting d_cancel also guarantees that any buffered writes are flushed
with vinvalbuf before dkclose is called.
2023-04-21 18:30:21 +00:00
riastradh 22cd13ae33 disk(9): Fix use-after-free race with concurrent disk_set_info.
This can happen with dk(4), which allows wedges to have their size
increased without destroying and recreating the device instance.

Drivers which allow concurrent disk_set_info and disk_ioctl must
serialize disk_set_info with dk_openlock.
2023-04-21 18:30:04 +00:00
riastradh c882a32047 dk(4): Require dk_openlock in dk_set_geometry.
Not strictly necessary but this makes reasoning easier and documents
with an assertion how disk_set_info is serialized.
2023-04-21 18:29:43 +00:00
riastradh a1b9c8917b dk(4): Assert dkwedges[unit] is the sc we're about to free. 2023-04-21 18:29:33 +00:00
riastradh 5f20b99ff2 dk(4): Assert parent vp is nonnull before we stash it away.
Let's enable early attribution if this goes wrong.

If it's not the parent's first open, also assert the parent vp is
already nonnull.
2023-04-21 18:29:26 +00:00
riastradh 95a8f72e29 dk(4): Don't touch dkwedges or ndkwedges outside dkwedges_lock. 2023-04-21 18:29:18 +00:00
riastradh 693156e9b4 dk(4): Move CFDRIVER_DECL and CFATTACH_DECL3_NEW earlier in file.
Follows the pattern of most drivers, and will be necessary for
referencing dk_cd in dk_bdevsw and dk_cdevsw soon, to prevent
open/detach races.

No functional change intended.
2023-04-21 18:26:35 +00:00
riastradh bbf9e378e1 dk(4): Prevent races in access to struct dkwedge_softc::sc_size.
Rules:

1. Only ever increases, never decreases.

   (Decreases require removing and readding the wedge.)

2. Increases are serialized by dk_openlock.

3. Reads can happen unlocked in any context where the softc is valid.

Access is gathered into dkwedge_size* subroutines -- don't touch
sc_size outside these.  For now, we use rwlock(9) to keep the
reasoning simple.  This should be done with atomics on 64-bit
platforms and a seqlock on 32-bit platforms to avoid contention.
However, we can do that in a later change.
2023-04-21 18:25:49 +00:00
riastradh 2232f80f28 dk(4): <sys/rwlock.h> for rwlock(9). 2023-04-21 18:25:30 +00:00
riastradh 797500ada3 dk(4): KNF: Sort includes.
No functional change intended.
2023-04-21 18:25:22 +00:00
riastradh 783e976b26 dk(4): ENXIO, not ENODEV, means no such device.
ENXIO is `device not configured', meaning there is no such device.

ENODEV is `operation not supported by device', meaning the device is
there but refuses the operation, like writing to a read-only medium.

Exception: For undefined ioctl commands, it's not ENODEV _or_ ENXIO,
but rather ENOTTY, because why make any of this obvious when you
could make it obscure Unix lore?
2023-04-21 18:25:09 +00:00
riastradh 7f62a7fc94 dk(4): Fix typo in comment: dkstrategy, not dkstragegy.
No functional change intended.
2023-04-21 18:24:56 +00:00
riastradh 600b5399ed dk(4): Omit needless void * cast.
No functional change intended.
2023-04-21 18:24:47 +00:00
riastradh 30efe94ac2 dk(4): KNF: Whitespace.
No functional change intended.
2023-04-21 18:24:39 +00:00
riastradh 9fa4440b53 dk(4): KNF: return (v) -> return v.
No functional change intended.
2023-04-21 18:24:31 +00:00
riastradh b9b7baff4e dk(4): Avoid holding dkwedges_lock while allocating array.
This is not great -- we shouldn't be choosing the unit number here
anyway; we should just let autoconf do it for us -- but it's better
than potentially blocking any dk_openlock or dk_rawlock (which are
sometimes held when waiting for dkwedges_lock) for memory allocation.
2023-04-21 18:24:19 +00:00
riastradh b134e0f792 dk(4): Restore assertions in dklastclose.
We only enter dklastclose if the wedge is open (sc->sc_dk.dk_openmask
!= 0), which can happen only if dkfirstopen has succeeded, in which
case we hold a dk_rawopens reference to the parent that prevents
anyone else from closing it.  Hence sc->sc_parent->dk_rawopens > 0.

On open, sc->sc_parent->dk_rawvp is set to nonnull, and it is only
reset to null on close.  Hence if the parent is still open, as it
must be here, sc->sc_parent->dk_rawvp must be nonnull.
2023-04-21 18:09:38 +00:00
nikita 160c9084ef lua: fix formating diff to upstream in ldo.h 2023-04-21 17:48:06 +00:00
riastradh 019d618210 autoconf(9): Add a comment where we risk arithmetic overflow. 2023-04-21 17:35:43 +00:00
nikita 4fd395ecb3 lua: fix ftb in lvm.c 2023-04-21 17:31:33 +00:00
roy 1f7e02ab78 Note update to dhcpcd-10.0.1 2023-04-21 17:00:05 +00:00
roy 74820ea053 Merge changes 2023-04-21 16:54:26 +00:00
roy 794dfa7744 Update to dhcpcd-10.0.1 with the following changes:
* privsep: keep resources open rather than open/close
 * dhcp6: OPTION_NTP_SERVER is now preferred over OPTION_SNTP_SERVER
 * Misc bug fixes mainly around privsep for many platforms.
 * Fix for reading the some BSD routing table entries.
 * Fix reading authtokens from config.

Big new release, mainly around better privsep process management
which allows us to detect when they exit unexpectedly.
2023-04-21 16:52:28 +00:00
rillig 5d22d06a84 style: remove mentions of ANSI C
The distinction between traditional C and ISO C90 or later is no longer
needed in the style guide. Any old-style code is caught by the
compilers.

https://mail-index.netbsd.org/tech-userlevel/2023/04/15/msg013768.html
https://mail-index.netbsd.org/tech-userlevel/2023/04/17/msg013776.html
2023-04-21 16:12:53 +00:00
skrll 66be60e703 More devmap updates 2023-04-21 15:04:47 +00:00
skrll 30ba21540f Trailing whitespace 2023-04-21 15:00:27 +00:00
skrll c5a673c118 Trailing whitespace. 2023-04-21 14:58:34 +00:00
skrll 5ea443a011 Trailing whitespace 2023-04-21 14:57:52 +00:00
christos ef8fd1897c Align types with readline-8.2 (wiz@) 2023-04-21 14:56:13 +00:00
yamaguchi 55d6298230 virtio(4): change members of struct vring_desc_extra before free a slot
This prevents the following race condition.
1. Thread-A: calls virtio_dequeue_commit() and
             puts a slot into free descriptor chain in vq_free_slot()
2. Thread-B: calls virtio_enqueue_prep() and get the slot stored by Thread-A
3. Thread-B: calls virtio_enqueue_reserve() and
             changes desc_base and desc_free_idx for the slot
4. Thread-A: changes the same members updated by Thread-B

reported by hannken, thanks.
2023-04-21 02:17:32 +00:00
gutteridge 74010a1af9 resize.c: use estrdup(3) with basename(3)
basename(3) is invoked more than once on different paths. Retain the
correct name for the utility itself on error. Addresses PR bin/57355
from RVP, who provided the patch.
2023-04-20 22:23:53 +00:00
uwe a9b7771ff9 optstr(9): markup fixes
While here, wrap long .Fn lines for readability and make the
optstr_get_item list compact.
2023-04-20 10:43:17 +00:00