libbpf: Fix for the potential undefined behavior due to shifting

When compiling libbpf with sanitation, ubsan will report the following:
```
left shift of 1 by 31 places cannot be represented in type 'int'
```
This may lead to undefined behavior according to the compiler implementation,
let's fix it by casting to unsigned counterpart before shifting.

Signed-off-by: Tan Wei <tw19881113@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20260828003448.1684064-1-tw19881113@gmail.com
This commit is contained in:
Tw authored and Andrii Nakryiko committed 2026-10-02 05:41:50 -07:00
1 parent 1aab5a98be
commit 6598dcb3bf
2 files changed
+3 -3

No files matched your search

+1 -1
View File
@@ -11738,7 +11738,7 @@ static int perf_event_open_probe(bool uprobe, bool retprobe, const char *name,
errstr(bit));
return bit;
}
attr.config |= 1 << bit;
attr.config |= 1ULL << bit;
}
attr.size = attr_sz;
attr.type = type;