Skip to content

Commit

Permalink
tools/capable: Set data to zero before setting fields.
Browse files Browse the repository at this point in the history
This commit ensures data contains all 0 before setting its fields.
So, even if some fields are not set, there should be no problem with unaligned
access.

Signed-off-by: Francis Laniel <[email protected]>
  • Loading branch information
Francis Laniel authored and yonghong-song committed Oct 12, 2021
1 parent 0659577 commit 46a2afd
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tools/capable.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,15 @@ def __getattr__(self, name):
}
u32 uid = bpf_get_current_uid_gid();
struct data_t data = {.tgid = tgid, .pid = pid, .uid = uid, .cap = cap, .audit = audit, .insetid = insetid};
struct data_t data = {};
data.tgid = tgid;
data.pid = pid;
data.uid = uid;
data.cap = cap;
data.audit = audit;
data.insetid = insetid;
#ifdef KERNEL_STACKS
data.kernel_stack_id = stacks.get_stackid(ctx, 0);
#endif
Expand Down

0 comments on commit 46a2afd

Please sign in to comment.