HBSD SEGVGUARD: Check if SEGVGUARD is active before doing any work

Simply move the check if SEGVGUARD is active to the top of the functions
that utilize the check. No need to waste CPU cycles if SEGVGUARD isn't
active.

Signed-off-by:	Shawn Webb <shawn.webb@hardenedbsd.org>
MFC-to:		10-STABLE
MFC-to:		11-STABLE
(cherry picked from commit 94ec671827b6e75e180324424847c6210c3ffaca)
This commit is contained in:
Shawn Webb 2016-12-20 19:15:40 -05:00 committed by Shawn Webb
parent 21077f2f71
commit 5abb3d76c5
No known key found for this signature in database
GPG key ID: 411DCD7D5C3BFCB6

View file

@ -444,15 +444,15 @@ pax_segvguard_segfault(struct thread *td, const char *name)
struct vnode *v;
sbintime_t sbt;
if (pax_segvguard_active(td->td_proc) == false)
return (0);
v = td->td_proc->p_textvp;
if (v == NULL)
return (EFAULT);
pr = pax_get_prison_td(td);
if (pax_segvguard_active(td->td_proc) == false)
return (0);
sbt = sbinuptime();
se = pax_segvguard_lookup(td, v);
@ -495,12 +495,12 @@ pax_segvguard_check(struct thread *td, struct vnode *v, const char *name)
struct pax_segvguard_entry *se;
sbintime_t sbt;
if (v == NULL)
return (EFAULT);
if (pax_segvguard_active(td->td_proc) == false)
return (0);
if (v == NULL)
return (EFAULT);
sbt = sbinuptime();
se = pax_segvguard_lookup(td, v);