summaryrefslogtreecommitdiffstats
path: root/share
AgeCommit message (Collapse)AuthorFilesLines
2021-04-13Add refcnt_take_if_gt()Matt Dunwoodie1-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`.
2021-04-02tweak previous;jmc1-3/+4
2021-04-02Document ioctl(2)'s for vmm(4). OK kn@.dv1-2/+43
2021-03-31document trusted_snapshotespie1-2/+8
2021-03-28list Dell DW5821e as supported for umb(4)sthen1-2/+4
2021-03-26Push kernel lock within rtable_add(9) and rework it to return 0 in themvs1-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@
2021-03-23change pfIfDescr and pfLogIfName from plain OCTET STRING (which has nosthen1-11/+16
textual-convention so is sometimes printed as hex dump) to DisplayString (ascii). likewise change pfLabelName and pfTblName to SnmpAdminString (UTF-8 textual-convention). feedback/tweaks (notably pointing out UTF-8)/ok martijn@
2021-03-23Document SIOCGIFADDR and SIOCSIFADDR ioctls for tap devices.claudio1-2/+6
OK kn@
2021-03-23Document the @version suffix that can be added when running 'portgen go'abieber1-2/+11
Patch from Josh Rickmar. Ty jrick!
2021-03-22document NEVER_CLEANespie1-2/+6
2021-03-20s/struft/struct/; thanks James Hastingssthen2-6/+6
2021-03-20Sync with apm(4/macppc) to document which ioctls are not supportedkn1-2/+13
Suspend/resume and other power events are NOT YET SUPPORTED.
2021-03-20End sentence and add .Pp after (all) "NOT SUPPORTED" lineskn1-7/+13
2021-03-18Update go-module docs for recent changes, from Josh Rickmar, small tweaksthen1-6/+4
from me
2021-03-18Document SIOCDELLABEL, link among MPLS driverskn3-9/+23
Use of the IOCTL section losely adopted from bridge(4), the list of ioctls however is still incomplete. mpw(4) and mpip(4) could use a reference to mpe(4) IOCTL or so, but this is good enough for starters. Feedback OK claudio
2021-03-17List the Qu-c0-hr-b0-48 firmware image in the iwx(4) man page.stsp1-2/+3
2021-03-16Describe what happens when RFC 4638 is not supported.millert1-7/+16
With help from sthen@. OK sthen@ jmc@
2021-03-14add HISTORY; from maxim vuetsjmc1-2/+7
2021-03-13sync usb_device_info with usb.h, spotted by Enrik Berkhan, and millert@sthen1-10/+8
noticed another change
2021-03-11Link to sh(1) and use the same wording and markup for EXTRACT_CASES codekn1-3/+6
"good idea" sthen
2021-03-10Typofix previouskn1-2/+2
2021-03-10cleanup the 3 ways (2 for ipv4, 1 for ipv6) of doing dynamic addressderaadt1-10/+21
allocation. not the perfect text yet, but it is better. discussed with florian and jmc
2021-03-09Remove documentation for all port modules no longer supported. ok sthen@tracey1-153/+12
2021-03-09document zstd support in EXTRACT_CASES and change from a big code samplesthen1-30/+32
that isn't directly usable to a shorter table and example of what one might need to add to EXTRACT_CASES when making a change; ok espie@
2021-03-08Note that slaacd(8) is enabled by default. Also note that if youflorian1-5/+2
disabled it in the past and then note that IPv6 autoconfiguration doesn't work for you, you will quickly note that we will point and laugh.
2021-03-08Add RK809 to list of supported chips for this driver.kurt1-3/+3
2021-03-08correct paper titlejsg1-3/+3
2021-03-08Add some references, most of these were removed when we stopped buildingjsg2-4/+30
and installing USD/SMM/PSD docs. jmc@ agrees with the direction, ok millert@ on an earlier diff
2021-03-04new sentence, new line;jmc1-9/+9
2021-03-03Add a configurable button mapping for tap gestures on touchpads.bru1-9/+20
Thanks to RJ Johnson for this work! ok mpi@
2021-03-01remove unneccessary Pp;jmc1-3/+2
2021-03-01document log entry W, reminded by naddy@espie1-2/+8
2021-03-01fix Nd and remove trailing whitespace;jmc1-4/+4
2021-03-01document pkg_check-versionespie2-3/+58
2021-02-28document the move of FIX_CRLF_FILES to the end of distpatchespie1-6/+6
2021-02-27removal of "must" missed in previous: spotted by george brown, who alsojmc1-2/+2
submitted the diff for the previous commit and who i forgot to credit...
2021-02-27remove some info related to compat;jmc1-5/+4
tweaked by deraadt ok kettenis deraadt
2021-02-27fix NAME;jmc1-2/+2
2021-02-27apldart(4)kettenis1-0/+42
2021-02-27aplpcie(4)kettenis1-0/+44
2021-02-27aipldart(4)kettenis1-2/+2
2021-02-27aplpcie(4)kettenis1-2/+3
2021-02-27Add logger(1) support for daemons that are logging to stdout/stderr (mostly fromajacoutot2-4/+16
the go ecosystem). Properly handle failing daemon startup now that we have pipefail. To take advantage of this new feature, just add foo_logger=facility to the daemon rc.d(8) script or in rc.conf.local(8) or use rcctl: rcctl set foo logger daemon.info tweak for checking flags in rcctl(8) from martijn@ "this looks pretty good" deraadt@ ok sthen@
2021-02-26Fix Typo, ok jcadanj1-2/+2
2021-02-26Add my copyright since I added most of the contentdanj1-2/+3
2021-02-25mention that FIX_CRLF_FILES is rooted in WRKDIST, pointed out by espie@.sthen1-1/+3
mention that shell wildcards may be used.
2021-02-25wrong annotationespie1-2/+2
2021-02-25make the timing of FIX_CRLF_FILES explicitespie1-2/+4
2021-02-25document FIX_CRLF_FILES.sthen1-2/+7
2021-02-25split off the large module documentations, so that port-modules is less ofespie7-573/+791
a monster. okay sthen@