freebsd-skq/sys/fs
Konstantin Belousov de4e1aeb21 Fix an issue with executing tmpfs binary.
Suppose that a binary was executed from tmpfs mount, and the text
vnode was reclaimed while the binary was still running.  It is
possible during even the normal operations since tmpfs vnode'
vm_object has swap type, and no references on the vnode is held.  Also
assume that the text vnode was revived for some reason.  Then, on the
process exit or exec, unmapping of the text mapping tries to remove
the text reference from the vnode, but since it went from
recycle/instantiation cycle, there is no reference kept, and assertion
in VOP_UNSET_TEXT_CHECKED() triggers.

Fix this by keeping a use reference on the tmpfs vnode for each exec
reference.  This prevents the vnode reclamation while executable map
entry is active.

Do it by adding per-mount flag MNTK_TEXT_REFS that directs
vop_stdset_text() to add use ref on first vnode text use, and
per-vnode VI_TEXT_REF flag, to record the need on unref in
vop_stdunset_text() on last vnode text use going away.  Set
MNTK_TEXT_REFS for tmpfs mounts.

Reported by:	bdrewery
Tested by:	sbruno, pho (previous version)
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2019-08-18 20:36:11 +00:00
..
autofs Ensure that directory entry padding bytes are zeroed. 2018-11-23 22:24:59 +00:00
cd9660 Ensure that directory entry padding bytes are zeroed. 2018-11-23 22:24:59 +00:00
cuse Free all allocated unit IDs in cuse(3) after the client character 2019-06-25 11:46:01 +00:00
deadfs Switch to use shared vnode locks for text files during image activation. 2019-05-05 11:20:43 +00:00
devfs Avoid relying on header pollution from sys/refcount.h. 2019-07-29 20:26:01 +00:00
ext2fs Avoid relying on header pollution from sys/refcount.h. 2019-07-29 20:26:01 +00:00
fdescfs Ensure that directory entry padding bytes are zeroed. 2018-11-23 22:24:59 +00:00
fifofs fcntl: fix overflow when setting F_READAHEAD 2019-06-20 23:07:20 +00:00
fuse fusefs: don't send the namespace during listextattr 2019-08-16 05:06:54 +00:00
msdosfs Remove "struct ucred*" argument from vtruncbuf 2019-05-24 20:27:50 +00:00
nfs Add #ifdef INET as requested by bz@. 2019-04-21 22:53:51 +00:00
nfsclient Get rid of extraneous initialization. 2019-05-31 03:13:09 +00:00
nfsserver Add support for the ModeSetMasked attribute to the NFSv4.1 server. 2019-04-19 23:35:08 +00:00
nullfs Manually clear text references on reclaim for nullfs and tmpfs. 2019-06-05 20:16:25 +00:00
procfs Plug memory disclosures via ptrace(2). 2018-12-03 20:54:17 +00:00
pseudofs pseudofs: Ignore unsupported commands in vop_setattr. 2019-05-28 20:54:59 +00:00
smbfs Replay r349334 by markj accidentally reverted by r349352 2019-06-25 06:14:00 +00:00
tmpfs Fix an issue with executing tmpfs binary. 2019-08-18 20:36:11 +00:00
udf Ensure that directory entry padding bytes are zeroed. 2018-11-23 22:24:59 +00:00
unionfs Try to decrease the number of bugs in unionfs after the VV_TEXT flag removal. 2019-08-01 14:40:37 +00:00