Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cmds] Enhance ps to better recognize task struct size mismatches #1695

Merged
merged 1 commit into from
Sep 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions elkscmd/sys_utils/ps.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,20 +188,12 @@ int main(int argc, char **argv)
printf(" ");
if (f_listall) printf("CSEG DSEG ");
printf(" HEAP FREE SIZE COMMAND\n");
for (j = 1; j <= MAX_TASKS; j++) {
for (j = 1; j < MAX_TASKS; j++) {
if (!memread(fd, off + j*sizeof(struct task_struct), ds, &task_table, sizeof(task_table))) {
printf("ps: memread\n");
return 1;
}

if (task_table.kstack_magic != KSTACK_MAGIC) {
if (task_table.kstack_magic == 0) continue;
printf("Recompile ps, mismatched task structure\n");
return 1;
}
if (task_table.t_regs.ss == 0)
continue;

switch (task_table.state) {
case TASK_UNUSED: continue;
case TASK_RUNNING: c = 'R'; break;
Expand All @@ -212,6 +204,12 @@ int main(int argc, char **argv)
case TASK_EXITING: c = 'E'; break;
default: c = '?'; break;
}

if (task_table.kstack_magic != KSTACK_MAGIC) {
printf("Recompile ps, mismatched task structure\n");
return 1;
}

pwent = getpwuid(task_table.uid);

/* pid grp tty user stat*/
Expand Down
Loading