mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2025-01-10 00:13:04 +01:00
Make the sigprocmask() and geteuid() system calls MP SAFE. Expand
commentary for copyin/copyout to indicate that they are MP SAFE as well. Reviewed by: msmith
This commit is contained in:
parent
b5cf22188d
commit
7c8fdcbd19
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=58941
@ -663,7 +663,9 @@ ENTRY(memcpy)
|
||||
* returns to *curpcb->onfault instead of the function.
|
||||
*/
|
||||
|
||||
/* copyout(from_kernel, to_user, len) */
|
||||
/*
|
||||
* copyout(from_kernel, to_user, len) - MP SAFE (if not I386_CPU)
|
||||
*/
|
||||
ENTRY(copyout)
|
||||
MEXITCOUNT
|
||||
jmp *_copyout_vector
|
||||
@ -704,6 +706,10 @@ ENTRY(generic_copyout)
|
||||
|
||||
#if defined(I386_CPU)
|
||||
|
||||
#if defined(SMP)
|
||||
#error I386_CPU option not supported if SMP
|
||||
#endif
|
||||
|
||||
#if defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU)
|
||||
cmpl $CPUCLASS_386,_cpu_class
|
||||
jne 3f
|
||||
@ -849,9 +855,7 @@ ENTRY(i586_copyout)
|
||||
#endif /* I586_CPU && NNPX > 0 */
|
||||
|
||||
/*
|
||||
* copyin(from_user, to_kernel, len)
|
||||
*
|
||||
* MPSAFE
|
||||
* copyin(from_user, to_kernel, len) - MP SAFE
|
||||
*/
|
||||
ENTRY(copyin)
|
||||
MEXITCOUNT
|
||||
@ -1133,9 +1137,9 @@ fastmove_tail_fault:
|
||||
#endif /* I586_CPU && NNPX > 0 */
|
||||
|
||||
/*
|
||||
* fu{byte,sword,word} : fetch a byte (sword, word) from user memory
|
||||
* fu{byte,sword,word} - MP SAFE
|
||||
*
|
||||
* MP SAFE
|
||||
* Fetch a byte (sword, word) from user memory
|
||||
*/
|
||||
ENTRY(fuword)
|
||||
movl _curpcb,%ecx
|
||||
@ -1161,7 +1165,7 @@ ENTRY(fuswintr)
|
||||
ret
|
||||
|
||||
/*
|
||||
* MP SAFE
|
||||
* fusword - MP SAFE
|
||||
*/
|
||||
ENTRY(fusword)
|
||||
movl _curpcb,%ecx
|
||||
@ -1176,7 +1180,7 @@ ENTRY(fusword)
|
||||
ret
|
||||
|
||||
/*
|
||||
* MP SAFE
|
||||
* fubyte - MP SAFE
|
||||
*/
|
||||
ENTRY(fubyte)
|
||||
movl _curpcb,%ecx
|
||||
@ -1199,7 +1203,9 @@ fusufault:
|
||||
ret
|
||||
|
||||
/*
|
||||
* su{byte,sword,word}: write a byte (word, longword) to user memory
|
||||
* su{byte,sword,word} - MP SAFE (if not I386_CPU)
|
||||
*
|
||||
* Write a byte (word, longword) to user memory
|
||||
*/
|
||||
ENTRY(suword)
|
||||
movl _curpcb,%ecx
|
||||
@ -1208,6 +1214,10 @@ ENTRY(suword)
|
||||
|
||||
#if defined(I386_CPU)
|
||||
|
||||
#if defined(SMP)
|
||||
#error I386_CPU option not supported if SMP
|
||||
#endif
|
||||
|
||||
#if defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU)
|
||||
cmpl $CPUCLASS_386,_cpu_class
|
||||
jne 2f /* we only have to set the right segment selector */
|
||||
@ -1250,6 +1260,9 @@ ENTRY(suword)
|
||||
movl %eax,PCB_ONFAULT(%ecx)
|
||||
ret
|
||||
|
||||
/*
|
||||
* susword - MP SAFE (if not I386_CPU)
|
||||
*/
|
||||
ENTRY(susword)
|
||||
movl _curpcb,%ecx
|
||||
movl $fusufault,PCB_ONFAULT(%ecx)
|
||||
@ -1257,6 +1270,10 @@ ENTRY(susword)
|
||||
|
||||
#if defined(I386_CPU)
|
||||
|
||||
#if defined(SMP)
|
||||
#error I386_CPU option not supported if SMP
|
||||
#endif
|
||||
|
||||
#if defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU)
|
||||
cmpl $CPUCLASS_386,_cpu_class
|
||||
jne 2f
|
||||
@ -1299,6 +1316,9 @@ ENTRY(susword)
|
||||
movl %eax,PCB_ONFAULT(%ecx)
|
||||
ret
|
||||
|
||||
/*
|
||||
* su[i]byte - MP SAFE (if not I386_CPU)
|
||||
*/
|
||||
ALTENTRY(suibyte)
|
||||
ENTRY(subyte)
|
||||
movl _curpcb,%ecx
|
||||
@ -1307,6 +1327,10 @@ ENTRY(subyte)
|
||||
|
||||
#if defined(I386_CPU)
|
||||
|
||||
#if defined(SMP)
|
||||
#error I386_CPU option not supported if SMP
|
||||
#endif
|
||||
|
||||
#if defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU)
|
||||
cmpl $CPUCLASS_386,_cpu_class
|
||||
jne 2f
|
||||
@ -1349,7 +1373,8 @@ ENTRY(subyte)
|
||||
ret
|
||||
|
||||
/*
|
||||
* copyinstr(from, to, maxlen, int *lencopied)
|
||||
* copyinstr(from, to, maxlen, int *lencopied) - MP SAFE
|
||||
*
|
||||
* copy a string from from to to, stop when a 0 character is reached.
|
||||
* return ENAMETOOLONG if string is longer than maxlen, and
|
||||
* EFAULT on protection violations. If lencopied is non-zero,
|
||||
@ -1421,7 +1446,7 @@ cpystrflt_x:
|
||||
|
||||
|
||||
/*
|
||||
* copystr(from, to, maxlen, int *lencopied)
|
||||
* copystr(from, to, maxlen, int *lencopied) - MP SAFE
|
||||
*/
|
||||
ENTRY(copystr)
|
||||
pushl %esi
|
||||
|
@ -663,7 +663,9 @@ ENTRY(memcpy)
|
||||
* returns to *curpcb->onfault instead of the function.
|
||||
*/
|
||||
|
||||
/* copyout(from_kernel, to_user, len) */
|
||||
/*
|
||||
* copyout(from_kernel, to_user, len) - MP SAFE (if not I386_CPU)
|
||||
*/
|
||||
ENTRY(copyout)
|
||||
MEXITCOUNT
|
||||
jmp *_copyout_vector
|
||||
@ -704,6 +706,10 @@ ENTRY(generic_copyout)
|
||||
|
||||
#if defined(I386_CPU)
|
||||
|
||||
#if defined(SMP)
|
||||
#error I386_CPU option not supported if SMP
|
||||
#endif
|
||||
|
||||
#if defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU)
|
||||
cmpl $CPUCLASS_386,_cpu_class
|
||||
jne 3f
|
||||
@ -849,9 +855,7 @@ ENTRY(i586_copyout)
|
||||
#endif /* I586_CPU && NNPX > 0 */
|
||||
|
||||
/*
|
||||
* copyin(from_user, to_kernel, len)
|
||||
*
|
||||
* MPSAFE
|
||||
* copyin(from_user, to_kernel, len) - MP SAFE
|
||||
*/
|
||||
ENTRY(copyin)
|
||||
MEXITCOUNT
|
||||
@ -1133,9 +1137,9 @@ fastmove_tail_fault:
|
||||
#endif /* I586_CPU && NNPX > 0 */
|
||||
|
||||
/*
|
||||
* fu{byte,sword,word} : fetch a byte (sword, word) from user memory
|
||||
* fu{byte,sword,word} - MP SAFE
|
||||
*
|
||||
* MP SAFE
|
||||
* Fetch a byte (sword, word) from user memory
|
||||
*/
|
||||
ENTRY(fuword)
|
||||
movl _curpcb,%ecx
|
||||
@ -1161,7 +1165,7 @@ ENTRY(fuswintr)
|
||||
ret
|
||||
|
||||
/*
|
||||
* MP SAFE
|
||||
* fusword - MP SAFE
|
||||
*/
|
||||
ENTRY(fusword)
|
||||
movl _curpcb,%ecx
|
||||
@ -1176,7 +1180,7 @@ ENTRY(fusword)
|
||||
ret
|
||||
|
||||
/*
|
||||
* MP SAFE
|
||||
* fubyte - MP SAFE
|
||||
*/
|
||||
ENTRY(fubyte)
|
||||
movl _curpcb,%ecx
|
||||
@ -1199,7 +1203,9 @@ fusufault:
|
||||
ret
|
||||
|
||||
/*
|
||||
* su{byte,sword,word}: write a byte (word, longword) to user memory
|
||||
* su{byte,sword,word} - MP SAFE (if not I386_CPU)
|
||||
*
|
||||
* Write a byte (word, longword) to user memory
|
||||
*/
|
||||
ENTRY(suword)
|
||||
movl _curpcb,%ecx
|
||||
@ -1208,6 +1214,10 @@ ENTRY(suword)
|
||||
|
||||
#if defined(I386_CPU)
|
||||
|
||||
#if defined(SMP)
|
||||
#error I386_CPU option not supported if SMP
|
||||
#endif
|
||||
|
||||
#if defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU)
|
||||
cmpl $CPUCLASS_386,_cpu_class
|
||||
jne 2f /* we only have to set the right segment selector */
|
||||
@ -1250,6 +1260,9 @@ ENTRY(suword)
|
||||
movl %eax,PCB_ONFAULT(%ecx)
|
||||
ret
|
||||
|
||||
/*
|
||||
* susword - MP SAFE (if not I386_CPU)
|
||||
*/
|
||||
ENTRY(susword)
|
||||
movl _curpcb,%ecx
|
||||
movl $fusufault,PCB_ONFAULT(%ecx)
|
||||
@ -1257,6 +1270,10 @@ ENTRY(susword)
|
||||
|
||||
#if defined(I386_CPU)
|
||||
|
||||
#if defined(SMP)
|
||||
#error I386_CPU option not supported if SMP
|
||||
#endif
|
||||
|
||||
#if defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU)
|
||||
cmpl $CPUCLASS_386,_cpu_class
|
||||
jne 2f
|
||||
@ -1299,6 +1316,9 @@ ENTRY(susword)
|
||||
movl %eax,PCB_ONFAULT(%ecx)
|
||||
ret
|
||||
|
||||
/*
|
||||
* su[i]byte - MP SAFE (if not I386_CPU)
|
||||
*/
|
||||
ALTENTRY(suibyte)
|
||||
ENTRY(subyte)
|
||||
movl _curpcb,%ecx
|
||||
@ -1307,6 +1327,10 @@ ENTRY(subyte)
|
||||
|
||||
#if defined(I386_CPU)
|
||||
|
||||
#if defined(SMP)
|
||||
#error I386_CPU option not supported if SMP
|
||||
#endif
|
||||
|
||||
#if defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU)
|
||||
cmpl $CPUCLASS_386,_cpu_class
|
||||
jne 2f
|
||||
@ -1349,7 +1373,8 @@ ENTRY(subyte)
|
||||
ret
|
||||
|
||||
/*
|
||||
* copyinstr(from, to, maxlen, int *lencopied)
|
||||
* copyinstr(from, to, maxlen, int *lencopied) - MP SAFE
|
||||
*
|
||||
* copy a string from from to to, stop when a 0 character is reached.
|
||||
* return ENAMETOOLONG if string is longer than maxlen, and
|
||||
* EFAULT on protection violations. If lencopied is non-zero,
|
||||
@ -1421,7 +1446,7 @@ cpystrflt_x:
|
||||
|
||||
|
||||
/*
|
||||
* copystr(from, to, maxlen, int *lencopied)
|
||||
* copystr(from, to, maxlen, int *lencopied) - MP SAFE
|
||||
*/
|
||||
ENTRY(copystr)
|
||||
pushl %esi
|
||||
|
@ -663,7 +663,9 @@ ENTRY(memcpy)
|
||||
* returns to *curpcb->onfault instead of the function.
|
||||
*/
|
||||
|
||||
/* copyout(from_kernel, to_user, len) */
|
||||
/*
|
||||
* copyout(from_kernel, to_user, len) - MP SAFE (if not I386_CPU)
|
||||
*/
|
||||
ENTRY(copyout)
|
||||
MEXITCOUNT
|
||||
jmp *_copyout_vector
|
||||
@ -704,6 +706,10 @@ ENTRY(generic_copyout)
|
||||
|
||||
#if defined(I386_CPU)
|
||||
|
||||
#if defined(SMP)
|
||||
#error I386_CPU option not supported if SMP
|
||||
#endif
|
||||
|
||||
#if defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU)
|
||||
cmpl $CPUCLASS_386,_cpu_class
|
||||
jne 3f
|
||||
@ -849,9 +855,7 @@ ENTRY(i586_copyout)
|
||||
#endif /* I586_CPU && NNPX > 0 */
|
||||
|
||||
/*
|
||||
* copyin(from_user, to_kernel, len)
|
||||
*
|
||||
* MPSAFE
|
||||
* copyin(from_user, to_kernel, len) - MP SAFE
|
||||
*/
|
||||
ENTRY(copyin)
|
||||
MEXITCOUNT
|
||||
@ -1133,9 +1137,9 @@ fastmove_tail_fault:
|
||||
#endif /* I586_CPU && NNPX > 0 */
|
||||
|
||||
/*
|
||||
* fu{byte,sword,word} : fetch a byte (sword, word) from user memory
|
||||
* fu{byte,sword,word} - MP SAFE
|
||||
*
|
||||
* MP SAFE
|
||||
* Fetch a byte (sword, word) from user memory
|
||||
*/
|
||||
ENTRY(fuword)
|
||||
movl _curpcb,%ecx
|
||||
@ -1161,7 +1165,7 @@ ENTRY(fuswintr)
|
||||
ret
|
||||
|
||||
/*
|
||||
* MP SAFE
|
||||
* fusword - MP SAFE
|
||||
*/
|
||||
ENTRY(fusword)
|
||||
movl _curpcb,%ecx
|
||||
@ -1176,7 +1180,7 @@ ENTRY(fusword)
|
||||
ret
|
||||
|
||||
/*
|
||||
* MP SAFE
|
||||
* fubyte - MP SAFE
|
||||
*/
|
||||
ENTRY(fubyte)
|
||||
movl _curpcb,%ecx
|
||||
@ -1199,7 +1203,9 @@ fusufault:
|
||||
ret
|
||||
|
||||
/*
|
||||
* su{byte,sword,word}: write a byte (word, longword) to user memory
|
||||
* su{byte,sword,word} - MP SAFE (if not I386_CPU)
|
||||
*
|
||||
* Write a byte (word, longword) to user memory
|
||||
*/
|
||||
ENTRY(suword)
|
||||
movl _curpcb,%ecx
|
||||
@ -1208,6 +1214,10 @@ ENTRY(suword)
|
||||
|
||||
#if defined(I386_CPU)
|
||||
|
||||
#if defined(SMP)
|
||||
#error I386_CPU option not supported if SMP
|
||||
#endif
|
||||
|
||||
#if defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU)
|
||||
cmpl $CPUCLASS_386,_cpu_class
|
||||
jne 2f /* we only have to set the right segment selector */
|
||||
@ -1250,6 +1260,9 @@ ENTRY(suword)
|
||||
movl %eax,PCB_ONFAULT(%ecx)
|
||||
ret
|
||||
|
||||
/*
|
||||
* susword - MP SAFE (if not I386_CPU)
|
||||
*/
|
||||
ENTRY(susword)
|
||||
movl _curpcb,%ecx
|
||||
movl $fusufault,PCB_ONFAULT(%ecx)
|
||||
@ -1257,6 +1270,10 @@ ENTRY(susword)
|
||||
|
||||
#if defined(I386_CPU)
|
||||
|
||||
#if defined(SMP)
|
||||
#error I386_CPU option not supported if SMP
|
||||
#endif
|
||||
|
||||
#if defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU)
|
||||
cmpl $CPUCLASS_386,_cpu_class
|
||||
jne 2f
|
||||
@ -1299,6 +1316,9 @@ ENTRY(susword)
|
||||
movl %eax,PCB_ONFAULT(%ecx)
|
||||
ret
|
||||
|
||||
/*
|
||||
* su[i]byte - MP SAFE (if not I386_CPU)
|
||||
*/
|
||||
ALTENTRY(suibyte)
|
||||
ENTRY(subyte)
|
||||
movl _curpcb,%ecx
|
||||
@ -1307,6 +1327,10 @@ ENTRY(subyte)
|
||||
|
||||
#if defined(I386_CPU)
|
||||
|
||||
#if defined(SMP)
|
||||
#error I386_CPU option not supported if SMP
|
||||
#endif
|
||||
|
||||
#if defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU)
|
||||
cmpl $CPUCLASS_386,_cpu_class
|
||||
jne 2f
|
||||
@ -1349,7 +1373,8 @@ ENTRY(subyte)
|
||||
ret
|
||||
|
||||
/*
|
||||
* copyinstr(from, to, maxlen, int *lencopied)
|
||||
* copyinstr(from, to, maxlen, int *lencopied) - MP SAFE
|
||||
*
|
||||
* copy a string from from to to, stop when a 0 character is reached.
|
||||
* return ENAMETOOLONG if string is longer than maxlen, and
|
||||
* EFAULT on protection violations. If lencopied is non-zero,
|
||||
@ -1421,7 +1446,7 @@ cpystrflt_x:
|
||||
|
||||
|
||||
/*
|
||||
* copystr(from, to, maxlen, int *lencopied)
|
||||
* copystr(from, to, maxlen, int *lencopied) - MP SAFE
|
||||
*/
|
||||
ENTRY(copystr)
|
||||
pushl %esi
|
||||
|
@ -45,7 +45,7 @@ struct sysent sysent[] = {
|
||||
{ 2, (sy_call_t *)unmount }, /* 22 = unmount */
|
||||
{ 1, (sy_call_t *)setuid }, /* 23 = setuid */
|
||||
{ SYF_MPSAFE | 0, (sy_call_t *)getuid }, /* 24 = getuid */
|
||||
{ 0, (sy_call_t *)geteuid }, /* 25 = geteuid */
|
||||
{ SYF_MPSAFE | 0, (sy_call_t *)geteuid }, /* 25 = geteuid */
|
||||
{ 4, (sy_call_t *)ptrace }, /* 26 = ptrace */
|
||||
{ 3, (sy_call_t *)recvmsg }, /* 27 = recvmsg */
|
||||
{ 3, (sy_call_t *)sendmsg }, /* 28 = sendmsg */
|
||||
@ -68,7 +68,7 @@ struct sysent sysent[] = {
|
||||
{ 4, (sy_call_t *)ktrace }, /* 45 = ktrace */
|
||||
{ compat(3,sigaction) }, /* 46 = old sigaction */
|
||||
{ SYF_MPSAFE | 0, (sy_call_t *)getgid }, /* 47 = getgid */
|
||||
{ compat(2,sigprocmask) }, /* 48 = old sigprocmask */
|
||||
{ compat(SYF_MPSAFE | 2, sigprocmask) },/* 48 = old sigprocmask */
|
||||
{ 2, (sy_call_t *)getlogin }, /* 49 = getlogin */
|
||||
{ 1, (sy_call_t *)setlogin }, /* 50 = setlogin */
|
||||
{ 1, (sy_call_t *)acct }, /* 51 = acct */
|
||||
@ -360,7 +360,7 @@ struct sysent sysent[] = {
|
||||
{ 3, (sy_call_t *)kldsym }, /* 337 = kldsym */
|
||||
{ 1, (sy_call_t *)jail }, /* 338 = jail */
|
||||
{ 0, (sy_call_t *)nosys }, /* 339 = pioctl */
|
||||
{ 3, (sy_call_t *)sigprocmask }, /* 340 = sigprocmask */
|
||||
{ SYF_MPSAFE | 3, (sy_call_t *)sigprocmask }, /* 340 = sigprocmask */
|
||||
{ 1, (sy_call_t *)sigsuspend }, /* 341 = sigsuspend */
|
||||
{ 3, (sy_call_t *)sigaction }, /* 342 = sigaction */
|
||||
{ 1, (sy_call_t *)sigpending }, /* 343 = sigpending */
|
||||
|
@ -169,15 +169,15 @@ found:
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* getuid() - MP SAFE
|
||||
*/
|
||||
#ifndef _SYS_SYSPROTO_H_
|
||||
struct getuid_args {
|
||||
int dummy;
|
||||
};
|
||||
#endif
|
||||
|
||||
/*
|
||||
* MP SAFE
|
||||
*/
|
||||
/* ARGSUSED */
|
||||
int
|
||||
getuid(p, uap)
|
||||
@ -192,6 +192,9 @@ getuid(p, uap)
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* geteuid() - MP SAFE
|
||||
*/
|
||||
#ifndef _SYS_SYSPROTO_H_
|
||||
struct geteuid_args {
|
||||
int dummy;
|
||||
@ -209,15 +212,15 @@ geteuid(p, uap)
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* getgid() - MP SAFE
|
||||
*/
|
||||
#ifndef _SYS_SYSPROTO_H_
|
||||
struct getgid_args {
|
||||
int dummy;
|
||||
};
|
||||
#endif
|
||||
|
||||
/*
|
||||
* MP SAFE
|
||||
*/
|
||||
/* ARGSUSED */
|
||||
int
|
||||
getgid(p, uap)
|
||||
|
@ -433,10 +433,11 @@ execsigs(p)
|
||||
}
|
||||
|
||||
/*
|
||||
* Manipulate signal mask.
|
||||
* Note that we receive new mask, not pointer,
|
||||
* and return old mask as return value;
|
||||
* the library stub does the rest.
|
||||
* do_sigprocmask() - MP SAFE ONLY IF p == curproc
|
||||
*
|
||||
* Manipulate signal mask. This routine is MP SAFE *ONLY* if
|
||||
* p == curproc. Also remember that in order to remain MP SAFE
|
||||
* no spl*() calls may be made.
|
||||
*/
|
||||
static int
|
||||
do_sigprocmask(p, how, set, oset, old)
|
||||
@ -452,7 +453,6 @@ do_sigprocmask(p, how, set, oset, old)
|
||||
|
||||
error = 0;
|
||||
if (set != NULL) {
|
||||
(void) splhigh();
|
||||
switch (how) {
|
||||
case SIG_BLOCK:
|
||||
SIG_CANTMASK(*set);
|
||||
@ -472,11 +472,14 @@ do_sigprocmask(p, how, set, oset, old)
|
||||
error = EINVAL;
|
||||
break;
|
||||
}
|
||||
(void) spl0();
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* sigprocmask() - MP SAFE
|
||||
*/
|
||||
|
||||
#ifndef _SYS_SYSPROTO_H_
|
||||
struct sigprocmask_args {
|
||||
int how;
|
||||
@ -507,6 +510,10 @@ sigprocmask(p, uap)
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* osigprocmask() - MP SAFE
|
||||
*/
|
||||
|
||||
#ifndef _SYS_SYSPROTO_H_
|
||||
struct osigprocmask_args {
|
||||
int how;
|
||||
|
Loading…
Reference in New Issue
Block a user