setpgid return -EACCES when the child process had already performed an execve (LTP setpgid03)
This commit is contained in:
@ -328,6 +328,7 @@ struct process {
|
|||||||
|
|
||||||
volatile int sigevent;
|
volatile int sigevent;
|
||||||
int nohost;
|
int nohost;
|
||||||
|
int execed;
|
||||||
sigset_t sigmask;
|
sigset_t sigmask;
|
||||||
stack_t sigstack;
|
stack_t sigstack;
|
||||||
ihk_spinlock_t sigpendinglock;
|
ihk_spinlock_t sigpendinglock;
|
||||||
|
|||||||
@ -1350,7 +1350,9 @@ SYSCALL_DECLARE(getpid)
|
|||||||
|
|
||||||
SYSCALL_DECLARE(getppid)
|
SYSCALL_DECLARE(getppid)
|
||||||
{
|
{
|
||||||
return cpu_local_var(current)->ftn->parent->pid;
|
if (cpu_local_var(current)->ftn->parent)
|
||||||
|
return cpu_local_var(current)->ftn->parent->pid;
|
||||||
|
return 1; // fake init
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1489,7 +1491,8 @@ SYSCALL_DECLARE(execve)
|
|||||||
|
|
||||||
struct syscall_request request IHK_DMA_ALIGN;
|
struct syscall_request request IHK_DMA_ALIGN;
|
||||||
struct program_load_desc *desc;
|
struct program_load_desc *desc;
|
||||||
struct process_vm *vm = cpu_local_var(current)->vm;
|
struct process *proc = cpu_local_var(current);
|
||||||
|
struct process_vm *vm = proc->vm;
|
||||||
struct vm_range *range;
|
struct vm_range *range;
|
||||||
|
|
||||||
ihk_mc_spinlock_lock_noirq(&vm->memory_range_lock);
|
ihk_mc_spinlock_lock_noirq(&vm->memory_range_lock);
|
||||||
@ -1596,6 +1599,7 @@ SYSCALL_DECLARE(execve)
|
|||||||
|
|
||||||
/* Switch to new execution context */
|
/* Switch to new execution context */
|
||||||
dkprintf("execve(): switching to new process\n");
|
dkprintf("execve(): switching to new process\n");
|
||||||
|
proc->execed = 1;
|
||||||
|
|
||||||
ihk_mc_switch_context(NULL, &cpu_local_var(current)->ctx,
|
ihk_mc_switch_context(NULL, &cpu_local_var(current)->ctx,
|
||||||
cpu_local_var(current));
|
cpu_local_var(current));
|
||||||
@ -1795,6 +1799,23 @@ SYSCALL_DECLARE(setpgid)
|
|||||||
int pid = ihk_mc_syscall_arg0(ctx);
|
int pid = ihk_mc_syscall_arg0(ctx);
|
||||||
int pgid = ihk_mc_syscall_arg1(ctx);
|
int pgid = ihk_mc_syscall_arg1(ctx);
|
||||||
long rc;
|
long rc;
|
||||||
|
struct process *proc = cpu_local_var(current);
|
||||||
|
ihk_spinlock_t *lock;
|
||||||
|
unsigned long irqstate = 0;
|
||||||
|
struct process *tproc;
|
||||||
|
|
||||||
|
if(proc->ftn->pid != pid){
|
||||||
|
tproc = findthread_and_lock(pid, pid, &lock, &irqstate);
|
||||||
|
if(tproc){
|
||||||
|
if(tproc->execed){
|
||||||
|
process_unlock(lock, irqstate);
|
||||||
|
return -EACCES;
|
||||||
|
}
|
||||||
|
process_unlock(lock, irqstate);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return -ESRCH;
|
||||||
|
}
|
||||||
|
|
||||||
rc = syscall_generic_forwarding(__NR_setpgid, ctx);
|
rc = syscall_generic_forwarding(__NR_setpgid, ctx);
|
||||||
if(rc == 0){
|
if(rc == 0){
|
||||||
|
|||||||
Reference in New Issue
Block a user