Date: Wed, 7 Feb 2007 18:28:29 GMT From: Roman Divacky <rdivacky@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 114193 for review Message-ID: <200702071828.l17ISTsb036227@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=114193 Change 114193 by rdivacky@rdivacky_witten on 2007/02/07 18:27:32 Dont "return" in linux_clone() after we forked the new process in a case of problems. Affected files ... .. //depot/projects/linuxolator/src/sys/amd64/linux32/linux32_machdep.c#34 edit .. //depot/projects/linuxolator/src/sys/i386/linux/linux_machdep.c#28 edit Differences ... ==== //depot/projects/linuxolator/src/sys/amd64/linux32/linux32_machdep.c#34 (text+ko) ==== @@ -610,6 +610,10 @@ if ((args->flags & 0xffffff00) == THREADING_FLAGS) ff |= RFTHREAD; + if (args->flags & CLONE_PARENT_SETTID) + if (args->parent_tidptr == NULL) + return (EINVAL); + error = fork1(td, ff, 0, &p2); if (error) return (error); @@ -629,15 +633,9 @@ KASSERT(em != NULL, ("clone: emuldata not found.\n")); /* and adjust it */ if (args->flags & CLONE_PARENT_SETTID) { - if (args->parent_tidptr == NULL) { - EMUL_UNLOCK(&emul_lock); - return (EINVAL); - } error = copyout(&p2->p_pid, args->parent_tidptr, sizeof(p2->p_pid)); - if (error) { - EMUL_UNLOCK(&emul_lock); - return (error); - } + if (error) + printf(LMSG("copyout failed!")); } if (args->flags & CLONE_THREAD) { @@ -679,52 +677,56 @@ int idx; error = copyin((void *)td->td_frame->tf_rsi, &info, sizeof(struct l_user_desc)); - if (error) - return (error); + if (error) { + printf(LMSG("copyin failed!")); + } else { - idx = info.entry_number; + idx = info.entry_number; - /* - * looks like we're getting the idx we returned - * in the set_thread_area() syscall - */ - if (idx != 6 && idx != GUGS32_SEL) - return (EINVAL); + /* + * looks like we're getting the idx we returned + * in the set_thread_area() syscall + */ + if (idx != 6 && idx != GUGS32_SEL) { + printf(LMSG("resetting idx!")); + idx = 6; /* or GUGS32_SEL? */ + } - /* this doesnt happen in practice */ - if (idx == 6) { - /* we might copy out the entry_number as GUGS32_SEL */ - info.entry_number = GUGS32_SEL; - error = copyout(&info, (void *) td->td_frame->tf_rsi, sizeof(struct l_user_desc)); - if (error) - return (error); - } + /* this doesnt happen in practice */ + if (idx == 6) { + /* we might copy out the entry_number as GUGS32_SEL */ + info.entry_number = GUGS32_SEL; + error = copyout(&info, (void *) td->td_frame->tf_rsi, sizeof(struct l_user_desc)); + if (error) + printf(LMSG("copyout failed!")); + } - a[0] = LDT_entry_a(&info); - a[1] = LDT_entry_b(&info); + a[0] = LDT_entry_a(&info); + a[1] = LDT_entry_b(&info); - memcpy(&sd, &a, sizeof(a)); + memcpy(&sd, &a, sizeof(a)); #ifdef DEBUG - if (ldebug(clone)) - printf("Segment created in clone with CLONE_SETTLS: " - "lobase: %x, hibase: %x, lolimit: %x, hilimit: %x, " - "type: %i, dpl: %i, p: %i, xx: %i, long: %i, " - "def32: %i, gran: %i\n", - sd.sd_lobase, - sd.sd_hibase, - sd.sd_lolimit, - sd.sd_hilimit, - sd.sd_type, - sd.sd_dpl, - sd.sd_p, - sd.sd_xx, - sd.sd_long, - sd.sd_def32, - sd.sd_gran); + if (ldebug(clone)) + printf("Segment created in clone with CLONE_SETTLS: " + "lobase: %x, hibase: %x, lolimit: %x, hilimit: %x, " + "type: %i, dpl: %i, p: %i, xx: %i, long: %i, " + "def32: %i, gran: %i\n", + sd.sd_lobase, + sd.sd_hibase, + sd.sd_lolimit, + sd.sd_hilimit, + sd.sd_type, + sd.sd_dpl, + sd.sd_p, + sd.sd_xx, + sd.sd_long, + sd.sd_def32, + sd.sd_gran); #endif - td2->td_pcb->pcb_gsbase = (register_t)info.base_addr; - td2->td_pcb->pcb_gs32p = (caddr_t)&gdt[GUGS32_SEL]; - memcpy(&td2->td_pcb->pcb_gs32sd, &sd, sizeof(sd)); + td2->td_pcb->pcb_gsbase = (register_t)info.base_addr; + td2->td_pcb->pcb_gs32p = (caddr_t)&gdt[GUGS32_SEL]; + memcpy(&td2->td_pcb->pcb_gs32sd, &sd, sizeof(sd)); + } } #ifdef DEBUG ==== //depot/projects/linuxolator/src/sys/i386/linux/linux_machdep.c#28 (text+ko) ==== @@ -423,6 +423,10 @@ if ((args->flags & 0xffffff00) == THREADING_FLAGS) ff |= RFTHREAD; + if (args->flags & CLONE_PARENT_SETTID) + if (args->parent_tidptr == NULL) + return (EINVAL); + error = fork1(td, ff, 0, &p2); if (error) return (error); @@ -442,15 +446,9 @@ KASSERT(em != NULL, ("clone: emuldata not found.\n")); /* and adjust it */ if (args->flags & CLONE_PARENT_SETTID) { - if (args->parent_tidptr == NULL) { - EMUL_UNLOCK(&emul_lock); - return (EINVAL); - } error = copyout(&p2->p_pid, args->parent_tidptr, sizeof(p2->p_pid)); - if (error) { - EMUL_UNLOCK(&emul_lock); - return (error); - } + if (error) + printf(LMSG("copyout failed!")); } if (args->flags & CLONE_THREAD) { @@ -492,34 +490,37 @@ struct segment_descriptor sd; error = copyin((void *)td->td_frame->tf_esi, &info, sizeof(struct l_user_desc)); - if (error) - return (error); + if (error) { + printf(LMSG("copyin failed!")); + } else { - idx = info.entry_number; + idx = info.entry_number; - /* - * looks like we're getting the idx we returned - * in the set_thread_area() syscall - */ - if (idx != 6 && idx != 3) - return (EINVAL); + /* + * looks like we're getting the idx we returned + * in the set_thread_area() syscall + */ + if (idx != 6 && idx != 3) { + printf(LMSG("resetting idx!")); + idx = 3; + } - /* this doesnt happen in practice */ - if (idx == 6) { - /* we might copy out the entry_number as 3 */ - info.entry_number = 3; - error = copyout(&info, (void *) td->td_frame->tf_esi, sizeof(struct l_user_desc)); - if (error) - return (error); - } + /* this doesnt happen in practice */ + if (idx == 6) { + /* we might copy out the entry_number as 3 */ + info.entry_number = 3; + error = copyout(&info, (void *) td->td_frame->tf_esi, sizeof(struct l_user_desc)); + if (error) + printf(LMSG("copyout failed!")); + } - a[0] = LDT_entry_a(&info); - a[1] = LDT_entry_b(&info); + a[0] = LDT_entry_a(&info); + a[1] = LDT_entry_b(&info); - memcpy(&sd, &a, sizeof(a)); + memcpy(&sd, &a, sizeof(a)); #ifdef DEBUG - if (ldebug(clone)) - printf("Segment created in clone with CLONE_SETTLS: lobase: %x, hibase: %x, lolimit: %x, hilimit: %x, type: %i, dpl: %i, p: %i, xx: %i, def32: %i, gran: %i\n", sd.sd_lobase, + if (ldebug(clone)) + printf("Segment created in clone with CLONE_SETTLS: lobase: %x, hibase: %x, lolimit: %x, hilimit: %x, type: %i, dpl: %i, p: %i, xx: %i, def32: %i, gran: %i\n", sd.sd_lobase, sd.sd_hibase, sd.sd_lolimit, sd.sd_hilimit, @@ -531,9 +532,10 @@ sd.sd_gran); #endif - /* set %gs */ - td2->td_pcb->pcb_gsd = sd; - td2->td_pcb->pcb_gs = GSEL(GUGS_SEL, SEL_UPL); + /* set %gs */ + td2->td_pcb->pcb_gsd = sd; + td2->td_pcb->pcb_gs = GSEL(GUGS_SEL, SEL_UPL); + } } #ifdef DEBUG
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200702071828.l17ISTsb036227>