From: Francis Laniel Date: Mon, 11 Oct 2021 15:35:12 +0000 (+0200) Subject: tools/capable: Set data to zero before setting fields. X-Git-Tag: v0.23.0~22 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=46a2afdc82b995cc19272cdd9d781dadfc0d3b1f;p=platform%2Fupstream%2Fbcc.git tools/capable: Set data to zero before setting fields. 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 --- diff --git a/tools/capable.py b/tools/capable.py index b89f2af9..acaa43c3 100755 --- a/tools/capable.py +++ b/tools/capable.py @@ -182,7 +182,15 @@ int kprobe__cap_capable(struct pt_regs *ctx, const struct cred *cred, } 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