From: Piet/Pete D. <pi...@sg...> - 2002-04-28 09:26:17
|
On Fri, Apr 26, 2002 at 08:15:14PM +0530, Deepak Kumar Gupta, Noida wrote: Could you regenerate your patch, there are added new lines <NL> in the patch file and patch -p1 </tmp/patch is failing. I fixed one and just hit another here at line 53, and see another at line 55. Considering that late date and that it hasn't been tested on ia64 I suggest we don't add it unless I can verify that it's ok. I just check lkcdutils and as of now ia64 appears to be fine. If you send another patch I can try it tomarrow (Sunday) and if it checks out then it's ok with me. Since it's a fix for when the user makes a mistake I don't think it's that important to get it in without testing it on ia64 first. -piet 45 +/* Function Name: task_validate 46 + * 47 + * Description: The function compares the given address with addresses of 48 + * available active tasks. 49 + * 50 + * Input : Address of task to be validated. 51 + * 52 + * Output : 1 if the input address matches with address of any of 53 active task. 54 + * : 0 if input address doesn't match with address of any of 55 active task 56 + * OR any error occurred. 57 + */ > Hello List > > First of all thanks to Steve for precious feedback on previous patch. > > I am using lkcdutils-4.1-pre2 with lkcd-4.1-pre2.patch for kernel 2.4.17 and > using it for i386 architecture. I have observed another problem with lcrash > command task. The problem is as follows:- > > PROBLEM DESCRIPTION > ==================== > ___snip____ > > >> task > ADDR UID PID PPID STATE FLAGS CPU NAME > ============================================================================ > === > 0xc0302000 0 0 0 0 0x100 0 swapper > 0xc2406000 0 1124 1 1 0x40 - kdeinit > . . . . . . . > . . . . . . . > . . . . . . . > 0xc2434000 0 1125 1124 1 0x100 - cat > 0xc254c000 0 1127 1 1 0x40 - alarmd > 0xc2f82000 0 1128 1110 1 0x140 - kdeinit > 0xc1f1a000 0 1129 1128 1 0x100 - bash > 0xc1a98000 0 2229 1128 1 0x100 - bash > 0xc7a84000 0 2292 933 1 0x100 - bash > ============================================================================ > === > 48 active task structs found > >> > >> task c2f82000 c1f1a300 c1f1a045 c7a84000 /* (__HERE ADDRESSES c1f1a300 > AND c1f1a045 ARE NOT ACTUAL TASK ADDRESS__) */ > ADDR UID PID PPID STATE FLAGS CPU NAME > ============================================================================ > === > 0xc2f82000 0 1128 1110 1 0x140 - kdeinit > 0xc1f1a300 0 0 4294967295 4294967295 0 - > 0xc1f1a045 0 3233935776 4294967295 697 0xc1a980 16777216 > 0xc7a84000 0 2292 933 1 0x100 - bash > ============================================================================ > === > 4 active task structs found > >> > ___snip____ > > That is if task command is executed for addresses which are not actually > start address of tasks then also it prints the values of parameters like > PID, PPID, STATE, FLAGS, CPU and NAME and consider them as active tasks. The > values printed by command are meaningless. > > In my opinion this is bug, but if experts think that this is OK then please > ignore rest of mail and update me. > > PROBLEM ANALYSIS > ================= > After looking at task_cmd function of lkcdutils-4.1/lcrash/cmds/cmd_task.c > it is observed that the addresses ( either given by user or obtained by > kl_pid_to_task ) are passed to print_task_struct without checking that > whether the address is actually a task OR not. > > PROBLEM SOLUTION > ================= > The address passed to print_task_struct should be compare with actual task > addresses. > > PATCH > ====== > For solving the problem, I have borrowed part of code from function > print_active_tasks(). > > Initially I have thought to include the part of code in cmd_task function > itself. But later I decided to have a separate function. > > This patch is also removing one unused variable from function > ldcmds_complete(command_t *cmd) of lcrash/cmds/cmd_ldcmds.c > > Following is the patch: > > > diff -Naur lkcdutils-4.1/lcrash/cmds/cmd_ldcmds.c > lkcdutils-4.1_mod/lcrash/cmds/cmd_ldcmds.c > --- lkcdutils-4.1/lcrash/cmds/cmd_ldcmds.c Wed Mar 20 16:57:27 2002 > +++ lkcdutils-4.1_mod/lcrash/cmds/cmd_ldcmds.c Fri Apr 26 19:28:15 2002 > @@ -68,8 +68,6 @@ > char * > ldcmds_complete(command_t *cmd) > { > - char *ret; > - > /* complete standard options (for example, -w option) arguments > */ > if ((cmd->nargs == 1)) { > diff -Naur lkcdutils-4.1/lcrash/cmds/cmd_task.c > lkcdutils-4.1_mod/lcrash/cmds/cmd_task.c > --- lkcdutils-4.1/lcrash/cmds/cmd_task.c Wed Mar 20 16:57:27 2002 > +++ lkcdutils-4.1_mod/lcrash/cmds/cmd_task.c Fri Apr 26 19:44:51 2002 > @@ -3,6 +3,7 @@ > */ > #include <lcrash.h> > > +int task_validate(kaddr_t); > /* > * task_cmd() -- Run the 'task' command. > */ > @@ -42,9 +43,11 @@ > if (mode == 1) { > task = kl_pid_to_task(task); > } > - print_task_struct(task, tsp, > + if (task_validate(task)) { > + print_task_struct(task, tsp, > cmd->flags, cmd->ofp); > - task_cnt++; > + task_cnt++; > + } > } else { > fprintf(KL_ERRORFP, "Invalid task : " > "0x%lx\n", (long unsigned int > )task); > @@ -112,3 +115,63 @@ > task_usage(cmd); > return(DRAW_NEW_ENTIRE_LINE); > } > + > +/* Function Name: task_validate > + * > + * Description: The function compares the given address with addresses of > + * available active tasks. > + * > + * Input : Address of task to be validated. > + * > + * Output : 1 if the input address matches with address of any of > active task. > + * : 0 if input address doesn't match with address of any of > active task > + * OR any error occurred. > + */ > + > +int > +task_validate(kaddr_t task) > +{ > + kaddr_t addr, first_task; > + syment_t *sp; > +#if (ARCH == ia64) > + kaddr_t p1, p2; > +#endif > + void *tsp; > + if (LINUX_2_2_X(KL_LINUX_RELEASE)) { > + if (!(sp = kl_lkup_symname("init_task_union"))) { > + return(0); > + } > + first_task = sp->s_addr; > + } else { > + if (!(sp = kl_lkup_symname("init_tasks"))) { > + return(0); > + } > + GET_BLOCK(sp->s_addr, sizeof(kaddr_t), &first_task); > + } > + addr = first_task; > + if (!(tsp = kl_alloc_block(TASK_STRUCT_SZ, K_TEMP))) { > + return(0); > + } > + do { > + if (kl_get_task_struct(addr, 2, tsp)) { > + return(0); > + } > + if (addr == task) { > + return(1); > + } > + addr = kl_kaddr(tsp, "task_struct", "next_task"); > + > +#if (ARCH == ia64) > + if (kl_virtop(addr, NULL, &p1)) { > + break; > + } > + if (kl_virtop(first_task, NULL, &p2)) { > + break; > + } > + } while (p1 != p2); > +#else > + } while (addr != first_task); > +#endif > + kl_free_block(tsp); > + return(0); > +} > > AFTER APPLYING THE PATCH > ========================= > >> task c2f82000 c1f1a300 c1f1a045 c7a84000 > ADDR UID PID PPID STATE FLAGS CPU NAME > ============================================================================ > === > 0xc2f82000 0 1128 1110 1 0x140 - kdeinit > 0xc7a84000 0 2292 933 1 0x100 - bash > ============================================================================ > === > 2 active task structs found > >> > > TESTING > ========= > I have tested it only for i386 platform. For ia64 platform I have not > tested, but hope it should work. > > I request the experts to have a look at patch. Please provide feedback and > cc the reply to me also. > > Looking for precious comments > Thanks > Deepak. > > > > _______________________________________________ > lkcd-devel mailing list > lkc...@li... > https://lists.sourceforge.net/lists/listinfo/lkcd-devel |