mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2025-07-08 10:25:20 +02:00
bpftool: Fix undefined behavior caused by shifting into the sign bit
[ Upstream commit 4cdc0e4ce5
]
Replace shifts of '1' with '1U' in bitwise operations within
__show_dev_tc_bpf() to prevent undefined behavior caused by shifting
into the sign bit of a signed integer. By using '1U', the operations
are explicitly performed on unsigned integers, avoiding potential
integer overflow or sign-related issues.
Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Quentin Monnet <qmo@kernel.org>
Link: https://lore.kernel.org/bpf/20240908140009.3149781-1-visitorckw@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
d43776b907
commit
ad762c5204
|
@ -480,9 +480,9 @@ static void __show_dev_tc_bpf(const struct ip_devname_ifindex *dev,
|
|||
if (prog_flags[i] || json_output) {
|
||||
NET_START_ARRAY("prog_flags", "%s ");
|
||||
for (j = 0; prog_flags[i] && j < 32; j++) {
|
||||
if (!(prog_flags[i] & (1 << j)))
|
||||
if (!(prog_flags[i] & (1U << j)))
|
||||
continue;
|
||||
NET_DUMP_UINT_ONLY(1 << j);
|
||||
NET_DUMP_UINT_ONLY(1U << j);
|
||||
}
|
||||
NET_END_ARRAY("");
|
||||
}
|
||||
|
@ -491,9 +491,9 @@ static void __show_dev_tc_bpf(const struct ip_devname_ifindex *dev,
|
|||
if (link_flags[i] || json_output) {
|
||||
NET_START_ARRAY("link_flags", "%s ");
|
||||
for (j = 0; link_flags[i] && j < 32; j++) {
|
||||
if (!(link_flags[i] & (1 << j)))
|
||||
if (!(link_flags[i] & (1U << j)))
|
||||
continue;
|
||||
NET_DUMP_UINT_ONLY(1 << j);
|
||||
NET_DUMP_UINT_ONLY(1U << j);
|
||||
}
|
||||
NET_END_ARRAY("");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user