]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Fix an issue with executing tmpfs binary.
authorkib <kib@FreeBSD.org>
Sun, 18 Aug 2019 20:36:11 +0000 (20:36 +0000)
committerkib <kib@FreeBSD.org>
Sun, 18 Aug 2019 20:36:11 +0000 (20:36 +0000)
commita5bfcc2aae7220e79e9e0a04fe7f4f7cd5a55ebb
treed6801e9b8680aa58034800ef2657dc4404b83427
parent90c17c9d31fa70bd20b9240e0833019c14cab26c
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
sys/fs/tmpfs/tmpfs_vfsops.c
sys/kern/vfs_default.c
sys/sys/mount.h
sys/sys/vnode.h