Wrap mprotect(2) so that we can add execute permissions when read

permissions are requested. This is needed on amd64 and ia64 for
JDK 1.4.x
This commit is contained in:
Marcel Moolenaar 2011-10-13 18:25:10 +00:00
parent eb8afcd36a
commit f8244106ab
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=226349
6 changed files with 32 additions and 10 deletions

View File

@ -436,6 +436,21 @@ freebsd32_mmap_partial(struct thread *td, vm_offset_t start, vm_offset_t end,
}
#endif
int
freebsd32_mprotect(struct thread *td, struct freebsd32_mprotect_args *uap)
{
struct mprotect_args ap;
ap.addr = (void *)(uintptr_t)uap->addr;
ap.len = uap->len;
ap.prot = uap->prot;
#if defined(__amd64__) || defined(__ia64__)
if (ap.prot & PROT_READ)
ap.prot |= PROT_EXEC;
#endif
return (sys_mprotect(td, &ap));
}
int
freebsd32_mmap(struct thread *td, struct freebsd32_mmap_args *uap)
{

View File

@ -3,7 +3,7 @@
*
* DO NOT EDIT-- this file is automatically generated.
* $FreeBSD$
* created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 224066 2011-07-15 18:26:19Z jonathan
* created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 226348 2011-10-13 18:21:11Z marcel
*/
#ifndef _FREEBSD32_SYSPROTO_H_
@ -76,6 +76,11 @@ struct freebsd32_execve_args {
char argv_l_[PADL_(u_int32_t *)]; u_int32_t * argv; char argv_r_[PADR_(u_int32_t *)];
char envv_l_[PADL_(u_int32_t *)]; u_int32_t * envv; char envv_r_[PADR_(u_int32_t *)];
};
struct freebsd32_mprotect_args {
char addr_l_[PADL_(const void *)]; const void * addr; char addr_r_[PADR_(const void *)];
char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)];
char prot_l_[PADL_(int)]; int prot; char prot_r_[PADR_(int)];
};
struct freebsd32_setitimer_args {
char which_l_[PADL_(u_int)]; u_int which; char which_r_[PADR_(u_int)];
char itv_l_[PADL_(struct itimerval32 *)]; struct itimerval32 * itv; char itv_r_[PADR_(struct itimerval32 *)];
@ -585,6 +590,7 @@ int freebsd32_recvfrom(struct thread *, struct freebsd32_recvfrom_args *);
int freebsd32_sigaltstack(struct thread *, struct freebsd32_sigaltstack_args *);
int freebsd32_ioctl(struct thread *, struct freebsd32_ioctl_args *);
int freebsd32_execve(struct thread *, struct freebsd32_execve_args *);
int freebsd32_mprotect(struct thread *, struct freebsd32_mprotect_args *);
int freebsd32_setitimer(struct thread *, struct freebsd32_setitimer_args *);
int freebsd32_getitimer(struct thread *, struct freebsd32_getitimer_args *);
int freebsd32_select(struct thread *, struct freebsd32_select_args *);
@ -943,6 +949,7 @@ int freebsd7_freebsd32_shmctl(struct thread *, struct freebsd7_freebsd32_shmctl_
#define FREEBSD32_SYS_AUE_freebsd32_execve AUE_EXECVE
#define FREEBSD32_SYS_AUE_ofreebsd32_fstat AUE_FSTAT
#define FREEBSD32_SYS_AUE_ofreebsd32_getpagesize AUE_NULL
#define FREEBSD32_SYS_AUE_freebsd32_mprotect AUE_MPROTECT
#define FREEBSD32_SYS_AUE_freebsd32_setitimer AUE_SETITIMER
#define FREEBSD32_SYS_AUE_freebsd32_getitimer AUE_GETITIMER
#define FREEBSD32_SYS_AUE_freebsd32_select AUE_SELECT

View File

@ -3,7 +3,7 @@
*
* DO NOT EDIT-- this file is automatically generated.
* $FreeBSD$
* created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 224066 2011-07-15 18:26:19Z jonathan
* created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 226348 2011-10-13 18:21:11Z marcel
*/
#define FREEBSD32_SYS_syscall 0
@ -80,7 +80,7 @@
/* 71 is obsolete ommap */
#define FREEBSD32_SYS_vadvise 72
#define FREEBSD32_SYS_munmap 73
#define FREEBSD32_SYS_mprotect 74
#define FREEBSD32_SYS_freebsd32_mprotect 74
#define FREEBSD32_SYS_madvise 75
/* 76 is obsolete vhangup */
/* 77 is obsolete vlimit */

View File

@ -3,7 +3,7 @@
*
* DO NOT EDIT-- this file is automatically generated.
* $FreeBSD$
* created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 224066 2011-07-15 18:26:19Z jonathan
* created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 226348 2011-10-13 18:21:11Z marcel
*/
const char *freebsd32_syscallnames[] = {
@ -84,7 +84,7 @@ const char *freebsd32_syscallnames[] = {
"obs_ommap", /* 71 = obsolete ommap */
"vadvise", /* 72 = vadvise */
"munmap", /* 73 = munmap */
"mprotect", /* 74 = mprotect */
"freebsd32_mprotect", /* 74 = freebsd32_mprotect */
"madvise", /* 75 = madvise */
"obs_vhangup", /* 76 = obsolete vhangup */
"obs_vlimit", /* 77 = obsolete vlimit */

View File

@ -3,7 +3,7 @@
*
* DO NOT EDIT-- this file is automatically generated.
* $FreeBSD$
* created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 224066 2011-07-15 18:26:19Z jonathan
* created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 226348 2011-10-13 18:21:11Z marcel
*/
#include "opt_compat.h"
@ -121,7 +121,7 @@ struct sysent freebsd32_sysent[] = {
{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 71 = obsolete ommap */
{ AS(ovadvise_args), (sy_call_t *)sys_ovadvise, AUE_O_VADVISE, NULL, 0, 0, 0, SY_THR_STATIC }, /* 72 = vadvise */
{ AS(munmap_args), (sy_call_t *)sys_munmap, AUE_MUNMAP, NULL, 0, 0, 0, SY_THR_STATIC }, /* 73 = munmap */
{ AS(mprotect_args), (sy_call_t *)sys_mprotect, AUE_MPROTECT, NULL, 0, 0, 0, SY_THR_STATIC }, /* 74 = mprotect */
{ AS(freebsd32_mprotect_args), (sy_call_t *)freebsd32_mprotect, AUE_MPROTECT, NULL, 0, 0, 0, SY_THR_STATIC }, /* 74 = freebsd32_mprotect */
{ AS(madvise_args), (sy_call_t *)sys_madvise, AUE_MADVISE, NULL, 0, 0, 0, SY_THR_STATIC }, /* 75 = madvise */
{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 76 = obsolete vhangup */
{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 77 = obsolete vlimit */

View File

@ -464,9 +464,9 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args)
*n_args = 2;
break;
}
/* mprotect */
/* freebsd32_mprotect */
case 74: {
struct mprotect_args *p = params;
struct freebsd32_mprotect_args *p = params;
uarg[0] = (intptr_t) p->addr; /* const void * */
uarg[1] = p->len; /* size_t */
iarg[2] = p->prot; /* int */
@ -3737,7 +3737,7 @@ systrace_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
break;
};
break;
/* mprotect */
/* freebsd32_mprotect */
case 74:
switch(ndx) {
case 0: