Skip to content

Commit

Permalink
When reading a task's task_struct.flags field, check for its size,
Browse files Browse the repository at this point in the history
which was changed from an unsigned long to an unsigned int.
([email protected])
  • Loading branch information
Dave Anderson committed Apr 25, 2016
1 parent aad859e commit 5690022
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -2093,6 +2093,7 @@ struct size_table { /* stash of commonly-used sizes */
long hrtimer_base;
long tnt;
long trace_print_flags;
long task_struct_flags;
};

struct array_table {
Expand Down
1 change: 1 addition & 0 deletions symbols.c
Original file line number Diff line number Diff line change
Expand Up @@ -10088,6 +10088,7 @@ dump_offset_table(char *spec, ulong makestruct)
SIZE(page_cache_bucket));
fprintf(fp, " pt_regs: %ld\n", SIZE(pt_regs));
fprintf(fp, " task_struct: %ld\n", SIZE(task_struct));
fprintf(fp, " task_struct_flags: %ld\n", SIZE(task_struct_flags));
fprintf(fp, " thread_info: %ld\n", SIZE(thread_info));
fprintf(fp, " softirq_state: %ld\n",
SIZE(softirq_state));
Expand Down
12 changes: 10 additions & 2 deletions task.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ task_init(void)
MEMBER_OFFSET_INIT(task_struct_active_mm, "task_struct", "active_mm");
MEMBER_OFFSET_INIT(task_struct_next_run, "task_struct", "next_run");
MEMBER_OFFSET_INIT(task_struct_flags, "task_struct", "flags");
MEMBER_SIZE_INIT(task_struct_flags, "task_struct", "flags");
MEMBER_OFFSET_INIT(task_struct_pidhash_next,
"task_struct", "pidhash_next");
MEMBER_OFFSET_INIT(task_struct_pgrp, "task_struct", "pgrp");
Expand Down Expand Up @@ -5266,8 +5267,15 @@ task_flags(ulong task)

fill_task_struct(task);

flags = tt->last_task_read ?
ULONG(tt->task_struct + OFFSET(task_struct_flags)) : 0;
if (tt->last_task_read) {
if (SIZE(task_struct_flags) == sizeof(unsigned int))
flags = UINT(tt->task_struct +
OFFSET(task_struct_flags));
else
flags = ULONG(tt->task_struct +
OFFSET(task_struct_flags));
} else
flags = 0;

return flags;
}
Expand Down

0 comments on commit 5690022

Please sign in to comment.