Revision tags: release/14.2.0, release/13.4.0 |
|
#
d2be7ed6 |
| 02-Aug-2024 |
Olivier Certner <olce@FreeBSD.org> |
cred: proc_set_cred(), proc_unset_cred(): Update user's process count
As a process really changes credentials at the moment proc_set_cred() or proc_unset_cred() is called, these functions are the pr
cred: proc_set_cred(), proc_unset_cred(): Update user's process count
As a process really changes credentials at the moment proc_set_cred() or proc_unset_cred() is called, these functions are the proper locations to perform the update of the new and old real users' process count (using chgproccnt()).
Before this change, change_ruid() instead would perform that update, although it operates only on a passed credential which is a priori not tied to the calling process (or not to any process at all). This was arguably a flaw of commit b1fc0ec1a7a49ded, r77183, based on its commit message, and in particular the portion "(...) In each case, the call now acts on a credential not a process (...)".
Fixing this makes using change_ruid() more natural when building candidate credentials that in the end are not applied to a process, e.g., because of some intervening privilege check. Also, it removes a hack around this unwanted process count change in unionfs.
We also introduce the new proc_set_cred_enforce_proc_lim() so that callers can respect the per-user process limit, and will use it for the upcoming setcred(). We plan to change all callers of proc_set_cred() to call this new function instead at some point. In the meantime, both proc_set_cred() and the new function will coexist.
As detailed in some proc_set_cred_enforce_proc_lim()'s comment, checking against the process limit is currently flawed as the kernel doesn't really maintain the number of processes per UID (besides RLIMIT_NPROC, this in fact also applies to RLIMIT_KQUEUES, RLIMIT_NPTS, RLIMIT_SBSIZE and RLIMIT_SWAP). The applied limit is currently that of the old real UID. Root (or a process granted with PRIV_PROC_LIMIT) is not subject to this limit.
Approved by: markj (mentor) Fixes: b1fc0ec1a7a49ded MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D46923
show more ...
|
#
9b505845 |
| 13-Jul-2024 |
Jason A. Harmening <jah@FreeBSD.org> |
unionfs: fix LINT build
Fix a stale variable name that snuck into a tracepoint from an earlier version of the change.
Fixes: eb60ff1e "unionfs: rework locking scheme to only lock a single vnode" R
unionfs: fix LINT build
Fix a stale variable name that snuck into a tracepoint from an earlier version of the change.
Fixes: eb60ff1e "unionfs: rework locking scheme to only lock a single vnode" Reported by: jenkins
show more ...
|
#
53a777bb |
| 14-Jun-2024 |
Jason A. Harmening <jah@FreeBSD.org> |
unionfs: do not create a new status object during vop_close()
Split the portion of unionfs_get_node_status() that searches for an existing status object into a new helper function, unionfs_find_node
unionfs: do not create a new status object during vop_close()
Split the portion of unionfs_get_node_status() that searches for an existing status object into a new helper function, unionfs_find_node_status(), and use that in unionfs_close().
Additionally, modify unionfs_close() to accept a NULL status object if unionfs_find_node_status() does not find a matching status object. This can happen due to the unconditional VOP_CLOSE() operation issued by vgonel().
Differential Revision: https://reviews.freebsd.org/D45398 Reviewed by: olce Tested by: pho
show more ...
|
Revision tags: release/14.1.0, release/13.3.0 |
|
#
eb60ff1e |
| 28-Feb-2024 |
Jason A. Harmening <jah@FreeBSD.org> |
unionfs: rework locking scheme to only lock a single vnode
Instead of locking both the lower and upper vnodes, which is both complex and deadlock-prone, only lock the upper vnode, or the lower vnode
unionfs: rework locking scheme to only lock a single vnode
Instead of locking both the lower and upper vnodes, which is both complex and deadlock-prone, only lock the upper vnode, or the lower vnode if no upper vnode is present.
In most cases this is all that is needed; for the cases in which both vnodes do need to be locked, this change also employs deadlock- avoiding techniques such as LK_NOWAIT and vn_lock_pair().
There are still some corner cases in which the current implementation ends up taking multiple vnode locks across different filesystems without taking special steps to avoid deadlock; those cases have been noted in the comments.
Differential Revision: https://reviews.freebsd.org/D45398 Reviewed by: olce Tested by: pho
show more ...
|
#
6c8ded00 |
| 02-Jan-2024 |
Jason A. Harmening <jah@FreeBSD.org> |
unionfs: accommodate underlying FS calls that may re-lock
Since non-doomed unionfs vnodes always share their primary lock with either the lower or upper vnode, any forwarded call to the base FS whic
unionfs: accommodate underlying FS calls that may re-lock
Since non-doomed unionfs vnodes always share their primary lock with either the lower or upper vnode, any forwarded call to the base FS which transiently drops that upper or lower vnode lock may result in the unionfs vnode becoming completely unlocked during that transient window. The unionfs vnode may then become doomed by a concurrent forced unmount, which can lead to either or both of the following:
--Complete loss of the unionfs lock: in the process of being doomed, the unionfs vnode switches back to the default vnode lock, so even if the base FS VOP reacquires the upper/lower vnode lock, that no longer translates into the unionfs vnode being relocked. This will then violate that caller's locking assumptions as well as various assertions that are enabled with DEBUG_VFS_LOCKS.
--Complete less of reference on the upper/lower vnode: the caller normally holds a reference on the unionfs vnode, while the unionfs vnode in turn holds references on the upper/lower vnodes. But in the course of being doomed, the unionfs vnode will drop the latter set of references, which can effectively lead to the base FS VOP executing with no references at all on its vnode, violating the assumption that vnodes can't be recycled during these calls and (if lucky) violating various assertions in the base FS.
Fix this by adding two new functions, unionfs_forward_vop_start_pair() and unionfs_forward_vop_finish_pair(), which are intended to bookend any forwarded VOP which may transiently unlock the relevant vnode(s). These functions are currently only applied to VOPs that modify file state (and require vnode reference and lock state to be identical at call entry and exit), as the common reason for transiently dropping locks is to update filesystem metadata.
Reviewed by: olce Tested by: pho MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D44076
show more ...
|
#
a2ddbe01 |
| 24-Dec-2023 |
Jason A. Harmening <jah@FreeBSD.org> |
unionfs: work around underlying FS failing to respect cn_namelen
unionfs_mkshadowdir() may be invoked on a non-leaf pathname component during lookup, in which case the NUL terminator of the pathname
unionfs: work around underlying FS failing to respect cn_namelen
unionfs_mkshadowdir() may be invoked on a non-leaf pathname component during lookup, in which case the NUL terminator of the pathname buffer will be well beyond the end of the current component. cn_namelen in this case will still (correctly) indicate the length of only the current component, but ZFS in particular does not currently respect cn_namelen, leading to the creation on inacessible files with slashes in their names. Work around this behavior by temporarily NUL- terminating the current pathname component for the call to VOP_MKDIR().
https://github.com/openzfs/zfs/issues/15705 has been filed to track a proper upstream fix for the issue at hand.
PR: 275871 Reported by: Karlo Miličević <karlo98.m@gmail.com> Tested by: Karlo Miličević <karlo98.m@gmail.com> Reviewed by: kib, olce MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D43818
show more ...
|
#
29363fb4 |
| 23-Nov-2023 |
Warner Losh <imp@FreeBSD.org> |
sys: Remove ancient SCCS tags.
Remove ancient SCCS tags from the tree, automated scripting, with two minor fixup to keep things compiling. All the common forms in the tree were removed with a perl s
sys: Remove ancient SCCS tags.
Remove ancient SCCS tags from the tree, automated scripting, with two minor fixup to keep things compiling. All the common forms in the tree were removed with a perl script.
Sponsored by: Netflix
show more ...
|
Revision tags: release/14.0.0 |
|
#
2ff63af9 |
| 16-Aug-2023 |
Warner Losh <imp@FreeBSD.org> |
sys: Remove $FreeBSD$: one-line .h pattern
Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/
|
Revision tags: release/13.2.0 |
|
#
ba8cc6d7 |
| 12-Mar-2023 |
Mateusz Guzik <mjg@FreeBSD.org> |
vfs: use __enum_uint8 for vtype and vstate
This whacks hackery around only reading v_type once.
Bump __FreeBSD_version to 1400093
|
#
08091729 |
| 26-Mar-2023 |
Jason A. Harmening <jah@FreeBSD.org> |
unionfs: fixes to unionfs_nodeget() error handling
If either the lower or upper vnode is found to be doomed after locking it, the newly-created unionfs node won't be associated with it and its lock
unionfs: fixes to unionfs_nodeget() error handling
If either the lower or upper vnode is found to be doomed after locking it, the newly-created unionfs node won't be associated with it and its lock will be dropped. In that case, clear the uppervp and lowervp locals as necessary to avoid further use of the vnode in unionfs_nodeget(). If the upper vnode is doomed but the lower vnode remains valid, additionally reset the unionfs node's v_vnlock field to point to the lower vnode lock.
Reviewed by: kib, markj Tested by: pho Differential Revision: https://reviews.freebsd.org/D39767
show more ...
|
#
bb24eaea |
| 06-Apr-2023 |
Konstantin Belousov <kib@FreeBSD.org> |
vn_lock_pair(): allow to request shared locking
If either of vnodes is shared locked, lock must not be recursed.
Requested by: rmacklem Reviewed by: markj, rmacklem Tested by: pho Sponsored by: The
vn_lock_pair(): allow to request shared locking
If either of vnodes is shared locked, lock must not be recursed.
Requested by: rmacklem Reviewed by: markj, rmacklem Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D39444
show more ...
|
#
829f0bcb |
| 19-Dec-2022 |
Mateusz Guzik <mjg@FreeBSD.org> |
vfs: add the concept of vnode state transitions
To quote from a comment above vput_final: <quote> * XXX Some filesystems pass in an exclusively locked vnode and strongly depend * on the lock being h
vfs: add the concept of vnode state transitions
To quote from a comment above vput_final: <quote> * XXX Some filesystems pass in an exclusively locked vnode and strongly depend * on the lock being held all the way until VOP_INACTIVE. This in particular * happens with UFS which adds half-constructed vnodes to the hash, where they * can be found by other code. </quote>
As is there is no mechanism which allows filesystems to denote that a vnode is fully initialized, consequently problems like the above are only found the hard way(tm).
Add rudimentary support for state transitions, which in particular allow to assert the vnode is not legally unlocked until its fate is decided (either construction finishes or vgone is called to abort it).
The new field lands in a 1-byte hole, thus it does not grow the struct.
Bump __FreeBSD_version to 1400077
Reviewed by: kib (previous version) Tested by: pho Differential Revision: https://reviews.freebsd.org/D37759
show more ...
|
#
8f7859e8 |
| 14-Dec-2022 |
Mateusz Guzik <mjg@FreeBSD.org> |
vfs: retire the now unused SAVESTART flag
Bump __FreeBSD_version to 1400075
Tested by: pho
|
Revision tags: release/12.4.0 |
|
#
8f874e92 |
| 10-Nov-2022 |
Mateusz Guzik <mjg@FreeBSD.org> |
vfs: make relookup take an additional argument
instead of looking at SAVESTART
This is a step towards removing the flag.
Reviewed by: mckusick Tested by: pho Differential Revision: https://reviews
vfs: make relookup take an additional argument
instead of looking at SAVESTART
This is a step towards removing the flag.
Reviewed by: mckusick Tested by: pho Differential Revision: https://reviews.freebsd.org/D34468
show more ...
|
#
a75d1ddd |
| 17-Sep-2022 |
Mateusz Guzik <mjg@FreeBSD.org> |
vfs: introduce V_PCATCH to stop abusing PCATCH
|
#
5b5b7e2c |
| 17-Sep-2022 |
Mateusz Guzik <mjg@FreeBSD.org> |
vfs: always retain path buffer after lookup
This removes some of the complexity needed to maintain HASBUF and allows for removing injecting SAVENAME by filesystems.
Reviewed by: kib (previous versi
vfs: always retain path buffer after lookup
This removes some of the complexity needed to maintain HASBUF and allows for removing injecting SAVENAME by filesystems.
Reviewed by: kib (previous version) Differential Revision: https://reviews.freebsd.org/D36542
show more ...
|
Revision tags: release/13.1.0 |
|
#
0134bbe5 |
| 13-Mar-2022 |
Mateusz Guzik <mjg@FreeBSD.org> |
vfs: prefix lookup and relookup with vfs_
Reviewed by: imp, mckusick Differential Revision: https://reviews.freebsd.org/D34530
|
#
974efbb3 |
| 10-Feb-2022 |
Jason A. Harmening <jah@FreeBSD.org> |
unionfs: fix typo in comment
I deleted the wrong word when writing up a comment in a prior change; the covered vnode may be recursed during any unmount, not just forced unmount.
|
#
6ff167aa |
| 30-Jan-2022 |
Jason A. Harmening <jah@FreeBSD.org> |
unionfs: allow lock recursion when reclaiming the root vnode
The unionfs root vnode will always share a lock with its lower vnode. If unionfs was mounted with the 'below' option, this will also be t
unionfs: allow lock recursion when reclaiming the root vnode
The unionfs root vnode will always share a lock with its lower vnode. If unionfs was mounted with the 'below' option, this will also be the vnode covered by the unionfs mount. During unmount, the covered vnode will be locked by dounmount() while the unionfs root vnode will be locked by vgone(). This effectively requires recursion on the same underlying like, albeit through two different vnodes.
Reported by: pho Reviewed by: kib, markj, pho Differential Revision: https://reviews.freebsd.org/D34109
show more ...
|
#
66c5fbca |
| 28-Jan-2022 |
Konstantin Belousov <kib@FreeBSD.org> |
insmntque1(): remove useless arguments
Also remove once-used functions to clean up after failed insmntque1(), which were destructor callbacks in previous life.
Reviewed by: markj Tested by: pho Spo
insmntque1(): remove useless arguments
Also remove once-used functions to clean up after failed insmntque1(), which were destructor callbacks in previous life.
Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D34071
show more ...
|
#
a01ca46b |
| 17-Jan-2022 |
Jason A. Harmening <jah@FreeBSD.org> |
unionfs: use VV_ROOT to check for root vnode in unionfs_lock()
This avoids a potentially wild reference to the mount object. Additionally, simplify some of the checks around VV_ROOT in unionfs_nodeg
unionfs: use VV_ROOT to check for root vnode in unionfs_lock()
This avoids a potentially wild reference to the mount object. Additionally, simplify some of the checks around VV_ROOT in unionfs_nodeget().
Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D33914
show more ...
|
#
2a7e4cf8 |
| 27-Jan-2022 |
Mateusz Guzik <mjg@FreeBSD.org> |
Revert b58ca5df0bb7 ("vfs: remove the now unused insmntque1")
I was somehow convinced that insmntque calls insmntque1 with a NULL destructor. Unfortunately this worked well enough to not immediately
Revert b58ca5df0bb7 ("vfs: remove the now unused insmntque1")
I was somehow convinced that insmntque calls insmntque1 with a NULL destructor. Unfortunately this worked well enough to not immediately blow up in simple testing.
Keep not using the destructor in previously patched filesystems though as it avoids unnecessary casts.
Noted by: kib Reported by: pho
show more ...
|
#
3150cf0c |
| 27-Jan-2022 |
Mateusz Guzik <mjg@FreeBSD.org> |
unionfs: stop using insmntque1
It adds nothing of value over insmntque.
|
#
39a2dc44 |
| 03-Jan-2022 |
Jason A. Harmening <jah@FreeBSD.org> |
unionfs: allow vnode lock to be held shared during VOP_OPEN
do_execve() will hold the vnode lock shared when it calls VOP_OPEN(), but unionfs_open() requires the lock to be held exclusive to correct
unionfs: allow vnode lock to be held shared during VOP_OPEN
do_execve() will hold the vnode lock shared when it calls VOP_OPEN(), but unionfs_open() requires the lock to be held exclusive to correctly synchronize node status updates. This requirement is asserted in unionfs_get_node_status().
Change unionfs_open() to temporarily upgrade the lock as is already done in unionfs_close(). Related to this, fix various cases throughout unionfs in which vnodes are not checked for reclamation following lock upgrades that may have temporarily dropped the lock. Also fix another related issue in which unionfs_lock() can incorrectly add LK_NOWAIT during a downgrade operation, which trips a lockmgr assertion.
Reviewed by: kib (prior version), markj, pho Reported by: pho Differential Revision: https://reviews.freebsd.org/D33729
show more ...
|
#
d877dd57 |
| 22-Dec-2021 |
Jason A. Harmening <jah@FreeBSD.org> |
unionfs: simplify writecount management
Use atomics to track the writecount granted to the underlying FS, and avoid holding the vnode interlock while calling the underling FS' VOP_ADD_WRITECOUNT().
unionfs: simplify writecount management
Use atomics to track the writecount granted to the underlying FS, and avoid holding the vnode interlock while calling the underling FS' VOP_ADD_WRITECOUNT(). This also fixes a WITNESS warning about nesting the same lock type. Also add comments explaining why we need to track the writecount on the unionfs vnode in the first place. Finally, simplify writecount management to only use the upper vnode and assert that we shouldn't have an active writecount on the lower vnode through unionfs.
Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D33611
show more ...
|