summaryrefslogtreecommitdiffstats
path: root/share/man/man9 (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Add refcnt_take_if_gt()Matt Dunwoodie2021-04-131-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This function (or of similar nature) is required to safely use a refcnt and smr_entry together. Such functions exist on other platforms as kref_get_unless_zero (on Linux) and refcount_acquire_if_gt (on FreeBSD). The following diagram details the following situation with and without refcnt_take_if_gt in 3 cases, with the first showing the "invalid" use of refcnt_take. Situation: Thread #1 is removing the global referenc (o). Thread #2 wants to reference an object (r), using a thread pointer (t). Case: 1) refcnt_take after Thread #1 has released "o" 2) refcnt_take_if_gt before Thread #1 has released "o" 3) refcnt_take_if_gt after Thread #1 has released "o" Data: struct obj { struct smr_entry smr; struct refcnt refcnt; } *o, *r, *t1, *t2; Thread #1 | Thread #2 ---------------------------------+------------------------------------ | r = NULL; rw_enter_write(&lock); | smr_read_enter(); | t1 = SMR_PTR_GET_LOCKED(&o); | t2 = SMR_PTR_GET(&o); SMR_PTR_SET_LOCKED(&o, NULL); | | if (refcnt_rele(&t1->refcnt) | smr_call(&t1->smr, free, t1); | | if (t2 != NULL) { | refcnt_take(&t2->refcnt); | r = t2; | } rw_exit_write(&lock); | smr_read_exit(); ..... // called by smr_thread | free(t1); | ..... | // use after free | *r ---------------------------------+------------------------------------ | r = NULL; rw_enter_write(&lock); | smr_read_enter(); | t1 = SMR_PTR_GET_LOCKED(&o); | t2 = SMR_PTR_GET(&o); SMR_PTR_SET_LOCKED(&o, NULL); | | if (refcnt_rele(&t1->refcnt) | smr_call(&t1->smr, free, t1); | | if (t2 != NULL && | refcnt_take_if_gt(&t2->refcnt, 0)) | r = t2; rw_exit_write(&lock); | smr_read_exit(); ..... // called by smr_thread | // we don't have a valid reference free(t1); | assert(r == NULL); ---------------------------------+------------------------------------ | r = NULL; rw_enter_write(&lock); | smr_read_enter(); | t1 = SMR_PTR_GET_LOCKED(&o); | t2 = SMR_PTR_GET(&o); SMR_PTR_SET_LOCKED(&o, NULL); | | if (t2 != NULL && | refcnt_take_if_gt(&t2->refcnt, 0)) | r = t2; if (refcnt_rele(&t1->refcnt) | smr_call(&t1->smr, free, t1); | rw_exit_write(&lock); | smr_read_exit(); ..... | // we need to put our reference | if (refcnt_rele(&t2->refcnt)) | smr_call(&t2->smr, free, t2); ..... // called by smr_thread | free(t1); | ---------------------------------+------------------------------------ Currently it uses atomic_add_int_nv to atomically read the refcnt, but I'm open to suggestions for better ways. The atomic_cas_uint is used to ensure that refcnt hasn't been modified since reading `old`.
* Push kernel lock within rtable_add(9) and rework it to return 0 in themvs2021-03-261-6/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | case when requested table is already exists. Except initialization time, route_output() and if_createrdomain() are the only paths where we call rtable_add(9). We check requested table existence by rtable_exists(9) and it's not the error condition if the table exists. Otherwise we are trying to create requested table by rtable_add(9). Those paths are kernel locked so concurrent thread can't create requested table just after rtable_exists(9) check. Also rtable_add(9) has internal rtable_exists(9) check and in this case the table existence assumed as EEXIST error. This error path is never reached. We are going to unlock PF_ROUTE sockets. This means route_output() will not be serialized with if_createrdomain() and concurrent thread could create requested table. Table existence check and creation should be serialized and it makes sense to do this within rtable_add(9). This time kernel lock is used for this so it pushed down to rtable_add(9). The internal rtable_exists(9) check was modified and table existence is not error now. Since the external rtable_exists(9) check is useless it was removed from if_createrdomain(). It still exists in route_output() path because the logic is more complicated here. ok mpi@
* s/struft/struct/; thanks James Hastingssthen2021-03-202-6/+6
|
* Add some references, most of these were removed when we stopped buildingjsg2021-03-081-2/+11
| | | | | | and installing USD/SMM/PSD docs. jmc@ agrees with the direction, ok millert@ on an earlier diff
* let m_copydata use a void * instead of caddr_tdlg2021-02-251-4/+4
| | | | | | | i'm not a fan of having to cast to caddr_t when we have modern inventions like void *s we can take advantage of. ok claudio@ mvs@ bluhm@
* Fix m_copyback(9) prototype in DESCRIPTION section.mvs2021-02-231-3/+3
| | | | ok millert@
* zap duplicate .Nm;jmc2021-02-211-2/+1
|
* i added stoeplitz_eaddrdlg2021-02-211-1/+11
|
* fix the names of the things that actually do the hashing.dlg2021-02-211-22/+23
|
* some article fixes; from eddie youseph and grepjmc2021-02-011-3/+3
|
* Private functions in the kernel do not to be prototyped.millert2021-01-221-6/+8
| | | | | | We don't use static in the kernel due to ddb so functions private to the compilation unit are basically equivalent. OK cheloha@ gnezdo@ mglocker@
* usb_init_task() wants a struct usb_task as the first argumentanton2021-01-191-3/+3
| | | | ok kn@ mvs@
* Introduce new function if_unit(9). This function returns a pointer themvs2021-01-181-2/+20
| | | | | | | | | | | interface descriptor corresponding to the unique name. This descriptor is guaranteed to be valid until if_put(9) is called on the returned pointer. if_unit(9) should replace already existent ifunit() which returns descriptor not safe for dereference when context was switched. This allow us to avoid some use-after-free issues in ioctl(2) path. Also this unifies interface descriptor usage. ok claudio@ sashan@
* Fix prototype for rw_assert_wrlock() function.mvs2021-01-161-3/+3
| | | | ok anton@ kn@
* zap trailing periodanton2021-01-151-2/+2
|
* add myself as the authoranton2021-01-151-2/+4
|
* Rename the macro MCLGETI to MCLGETL and removes the dead parameter ifp.jan2020-12-121-5/+5
| | | | | | OK dlg@, bluhm@ No Opinion mpi@ Not against it claudio@
* remove macro instances from arbitrary string width specifiers. for examplejmc2020-11-146-22/+22
| | | | | | | -width ".Dv BOB" -> -width "BOB" although they are not errors, they are misleading and probably should not get pasted around
* Kill unused IEEE80211_RADIOTAP_HWQUEUE.mpi2020-10-091-6/+3
| | | | | | | | | | Its value is conflicting with an effort to standardize TX flags fields of the radiotap header from Mathy Vanhoef. This flag used to indicate the presence of a specific hardware queue used by WME but is unchecked. ok sthen@, kn@
* Mention that kcov_remote_enter() and kcov_remote_leave() can now beanton2020-10-031-5/+7
| | | | called from interrupt context.
* documentation should say pool_init, not pmap_initderaadt2020-09-251-3/+3
|
* Document sysctl_bounded_args(9)gnezdo2020-09-011-6/+15
| | | | | | | Remove obsolete sysctl_int_arr documentation. Looks good, deraadt@ reads ok, jmc@
* Fix a few more typos in man9. Pointed out by jmc@, thanks!fcambus2020-08-282-6/+6
|
* Fix a bunch of typos in various man pages.fcambus2020-08-272-6/+6
|
* minor polishing: fix typos, add HISTORY and AUTHORS, a few wordingschwarze2020-08-102-22/+51
| | | | simplifications, add missing markup, and break an overlong line
* No longer prevent TCP connections to IPv6 anycast addresses.florian2020-08-081-4/+2
| | | | | | | | | | | | | | | | | | | | RFC 4291 dropped this requirement from RFC 3513: o An anycast address must not be used as the source address of an IPv6 packet. And from that requirement draft-itojun-ipv6-tcp-to-anycast rightly concluded that TCP connections must be prevented. The draft also states: The proposed method MUST be removed when one of the following events happens in the future: o Restriction imposed on IPv6 anycast address is loosened, so that anycast address can be placed into source address field of the IPv6 header[...] OK jca
* timeout(9): remove unused interfaces: timeout_add_ts(9), timeout_add_bt(9)cheloha2020-08-071-15/+3
| | | | | | | | | | These two interfaces have been entirely unused since introduction. Remove them and thin the "timeout" namespace a bit. Discussed with mpi@ and ratchov@ almost a year ago, though I blocked the change at that time. Also discussed with visa@. ok visa@, mpi@
* Document the p argument of vgonel(9) and vrecycle(9).tim2020-08-052-5/+13
| | | | Spotted by schwarze@, discussed with kn@ and schwarze@
* replace the excessively long, barely readable .Fn macros lines inschwarze2020-08-031-12/+75
| | | | the SYNOPSIS with the modern .Fo idiom; no output change
* put the descriptions of the different list types under subsection headings.dlg2020-08-031-4/+4
| | | | | it reads better to me. it might be worth considering this for queue(3) too.
* document SMR_{SLIST,LIST,TAILQ}_ENTRY by copying queue(3) bits.dlg2020-08-031-2/+18
|
* add a missing a worddlg2020-08-031-3/+3
|
* The difference between vgone(9) and vgonel(9) has changed after thetim2020-08-021-11/+7
| | | | | | | | removal of the vnode interlock in 2007. Reported by and original diff from Dominik Schreilechner. OK jmc@
* Catch up sysctl_int.9 to the updated signaturegnezdo2020-08-021-3/+3
| | | | OK kn@, "fine" deraadt@
* tweak previous; ok antonjmc2020-08-011-6/+5
|
* Add support for remote coverage to kcov. Remote coverage is collectedanton2020-08-012-3/+95
| | | | | | | | | | | | | | | | | | | | | from threads other than the one currently having kcov enabled. A thread with kcov enabled occasionally delegates work to another thread, collecting coverage from such threads improves the ability of syzkaller to correlate side effects in the kernel caused by issuing a syscall. Remote coverage is divided into subsystems. The only supported subsystem right now collects coverage from scheduled tasks and timeouts on behalf of a kcov enabled thread. In order to make this work `struct task' and `struct timeout' must be extended with a new field keeping track of the process that scheduled the task/timeout. Both aforementioned structures have therefore increased with the size of a pointer on all architectures. The kernel API is documented in a new kcov_remote_register(9) manual. Remote coverage is also supported by kcov on NetBSD and Linux. ok mpi@
* make a very quick and dirty pass on a manpage for the kstat api.dlg2020-07-063-2/+218
|
* In earlier commit, time_second.9 was removed from this directory.sthen2020-06-261-2/+2
| | | | Remove it from the Makefile too, unbreaking the tree.
* timecounting: deprecate time_second(9), time_uptime(9)cheloha2020-06-267-104/+22
| | | | | | | | | | | | | | | | | | | | | | | | time_second(9) has been replaced in the kernel by gettime(9). time_uptime(9) has been replaced in the kernel by getuptime(9). New code should use the replacement interfaces. They do not suffer from the split-read problem inherent to the time_* variables on 32-bit platforms. The variables remain in sys/kern/kern_tc.c for use via kvm(3) when examining kernel core dumps. This commit completes the deprecation process: - Remove the extern'd definitions for time_second and time_uptime from sys/time.h. - Replace manpage cross-references to time_second(9)/time_uptime(9) with references to microtime(9) or a related interface. - Move the time_second.9 manpage to the attic. With input from dlg@, kettenis@, visa@, and tedu@. ok kettenis@
* timecounting: add gettime(9), getuptime(9)cheloha2020-06-221-3/+13
| | | | | | | | | | | | | | | | | | | | | | time_second and time_uptime are used widely in the tree. This is a problem on 32-bit platforms because time_t is 64-bit, so there is a potential split-read whenever they are used at or below IPL_CLOCK. Here are two replacement interfaces: gettime(9) and getuptime(9). The "get" prefix signifies that they do not read the hardware timecounter, i.e. they are fast and low-res. The lack of a unit (e.g. micro, nano) signifies that they yield a plain time_t. As an optimization on LP64 platforms we can just return time_second or time_uptime, as a single read is atomic. On 32-bit platforms we need to do the lockless read loop and get the values from the timecounter. In a subsequent diff these will be substituted for time_second and time_uptime almost everywhere in the kernel. With input from visa@ and dlg@. ok kettenis@
* new sentence, new line;jmc2020-06-211-3/+3
|
* wireguard is taking over the gif mbuf tag.dlg2020-06-211-7/+6
| | | | | | | | | | | | | | gif used its mbuf tag to store it's interface index so it could detect loops. gre also did this, and i cut most of the drivers (including gif) over to using the gre tag. so the gif tag is unused. wireguard uses the tag to store peer information between different contexts the packet is processed in. it also needs a bit more space to do that. from Matt Dunwoodie and Jason A. Donenfeld ok deraadt@
* document mq_push()dlg2020-06-211-2/+21
|
* stoeplitz_to_key takes a void * now.dlg2020-06-191-3/+3
|
* Add entry for wsfont_init.9 in man9 Makefile.fcambus2020-06-181-2/+2
| | | | OK deraadt@, jmc@, mpi@
* put pci_intr_establish_cpu() in, but commented out for now.dlg2020-06-171-4/+25
| | | | | it's only available on amd64 (and i386), so don't really want to encourage it's use just yet.
* mark up an argument with Fa, not Vadlg2020-06-171-7/+5
|
* have a go at documenting pci_intr_map_msix.dlg2020-06-171-3/+29
| | | | | i feel like ive used the word vector too much, but hopefully someone who is good with english will check this and fix it.
* replace a long and wrapped Fn line with Fo Fa Fcdlg2020-06-171-4/+10
|
* tweak previous;jmc2020-06-171-3/+3
|