summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authornetchild <netchild@FreeBSD.org>2006-08-17 21:21:30 +0000
committernetchild <netchild@FreeBSD.org>2006-08-17 21:21:30 +0000
commitb2940209423ca0e1df97c5205435876ea4eda09e (patch)
tree7fd42ec0682e1c3a6d92dfa1c05531a142eafbbd /sys
parent5d552cdc476cb4806602f1d9689bce0a0b5d34ae (diff)
downloadFreeBSD-src-b2940209423ca0e1df97c5205435876ea4eda09e.zip
FreeBSD-src-b2940209423ca0e1df97c5205435876ea4eda09e.tar.gz
- disable some more code when osrelease=2.4.2
- protect td->td_proc->p_pid with the proc lock in linux_getpid in the amd64 (= non i386) case [1] Sponsored by: Google SoC 2006 Submitted by: rdivacky Noticed by: netchild [1]
Diffstat (limited to 'sys')
-rw-r--r--sys/compat/linux/linux_misc.c68
1 files changed, 46 insertions, 22 deletions
diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c
index 068c6e9..d8be75a 100644
--- a/sys/compat/linux/linux_misc.c
+++ b/sys/compat/linux/linux_misc.c
@@ -1333,15 +1333,23 @@ linux_getpid(struct thread *td, struct linux_getpid_args *args)
{
#ifdef __i386__
struct linux_emuldata *em;
-
- em = em_find(td->td_proc, EMUL_UNLOCKED);
-
- KASSERT(em != NULL, ("getpid: emuldata not found.\n"));
-
- td->td_retval[0] = em->shared->group_pid;
- EMUL_UNLOCK(&emul_lock);
+ char osrel[LINUX_MAX_UTSNAME];
+
+ linux_get_osrelease(td, osrel);
+ if (strlen(osrel) >= 3 && osrel[2] == '6') {
+ em = em_find(td->td_proc, EMUL_UNLOCKED);
+ KASSERT(em != NULL, ("getpid: emuldata not found.\n"));
+ td->td_retval[0] = em->shared->group_pid;
+ EMUL_UNLOCK(&emul_lock);
+ } else {
+ PROC_LOCK(td->td_proc);
+ td->td_retval[0] = td->td_proc->p_pid;
+ PROC_UNLOCK(td->td_proc);
+ }
#else
+ PROC_LOCK(td->td_proc);
td->td_retval[0] = td->td_proc->p_pid;
+ PROC_UNLOCK(td->td_proc);
#endif
return (0);
}
@@ -1362,9 +1370,18 @@ linux_gettid(struct thread *td, struct linux_gettid_args *args)
int
linux_getppid(struct thread *td, struct linux_getppid_args *args)
{
-#ifdef __i386__
+#ifdef __i386__
struct linux_emuldata *em;
struct proc *p, *pp;
+ char osrel[LINUX_MAX_UTSNAME];
+
+ linux_get_osrelease(td, osrel);
+ if (strlen(osrel) >= 3 && osrel[2] != '6') {
+ PROC_LOCK(td->td_proc);
+ td->td_retval[0] = td->td_proc->p_pptr->p_pid;
+ PROC_UNLOCK(td->td_proc);
+ return (0);
+ }
em = em_find(td->td_proc, EMUL_UNLOCKED);
@@ -1389,7 +1406,7 @@ linux_getppid(struct thread *td, struct linux_getppid_args *args)
em = em_find(pp, EMUL_LOCKED);
KASSERT(em != NULL, ("getppid: parent emuldata not found.\n"));
- td->td_retval[0] = em->shared->group_pid;
+ td->td_retval[0] = em->shared->group_pid;
} else
td->td_retval[0] = pp->p_pid;
@@ -1398,6 +1415,7 @@ linux_getppid(struct thread *td, struct linux_getppid_args *args)
#else
return getppid(td, (struct getppid_args *) args);
#endif
+
return (0);
}
@@ -1463,33 +1481,39 @@ linux_sethostname(struct thread *td, struct linux_sethostname_args *args)
int
linux_exit_group(struct thread *td, struct linux_exit_group_args *args)
{
+#ifdef __i386__
struct linux_emuldata *em, *td_em, *tmp_em;
struct proc *sp;
+ char osrel[LINUX_MAX_UTSNAME];
#ifdef DEBUG
if (ldebug(exit_group))
printf(ARGS(exit_group, "%i"), args->error_code);
#endif
- td_em = em_find(td->td_proc, EMUL_UNLOCKED);
+ linux_get_osrelease(td, osrel);
+ if (strlen(osrel) >= 3 && osrel[2] == '6') {
+ td_em = em_find(td->td_proc, EMUL_UNLOCKED);
- KASSERT(td_em != NULL, ("exit_group: emuldata not found.\n"));
+ KASSERT(td_em != NULL, ("exit_group: emuldata not found.\n"));
- EMUL_SHARED_RLOCK(&emul_shared_lock);
- LIST_FOREACH_SAFE(em, &td_em->shared->threads, threads, tmp_em) {
- if (em->pid == td_em->pid)
- continue;
+ EMUL_SHARED_RLOCK(&emul_shared_lock);
+ LIST_FOREACH_SAFE(em, &td_em->shared->threads, threads, tmp_em) {
+ if (em->pid == td_em->pid)
+ continue;
- sp = pfind(em->pid);
- psignal(sp, SIGKILL);
- PROC_UNLOCK(sp);
+ sp = pfind(em->pid);
+ psignal(sp, SIGKILL);
+ PROC_UNLOCK(sp);
#ifdef DEBUG
- printf(LMSG("linux_sys_exit_group: kill PID %d\n"), em->pid);
+ printf(LMSG("linux_sys_exit_group: kill PID %d\n"), em->pid);
#endif
- }
+ }
- EMUL_SHARED_RUNLOCK(&emul_shared_lock);
- EMUL_UNLOCK(&emul_lock);
+ EMUL_SHARED_RUNLOCK(&emul_shared_lock);
+ EMUL_UNLOCK(&emul_lock);
+ }
+#endif
exit1(td, W_EXITCODE(args->error_code,0));
OpenPOWER on IntegriCloud