bpf: use bitCast instead of intCast in ld_imm_impl

Any 32 bit immediate is allowed in a BPF instruction, including those
greater than the largest positive i32 value.
This commit is contained in:
George Huebner 2025-08-25 08:26:12 -05:00 committed by Alex Rønne Petersen
parent 8744865425
commit 496313a1bd

View file

@ -642,7 +642,7 @@ pub const Insn = packed struct {
.dst = @intFromEnum(dst),
.src = @intFromEnum(src),
.off = 0,
.imm = @as(i32, @intCast(@as(u32, @truncate(imm)))),
.imm = @as(i32, @bitCast(@as(u32, @truncate(imm)))),
};
}
@ -652,7 +652,7 @@ pub const Insn = packed struct {
.dst = 0,
.src = 0,
.off = 0,
.imm = @as(i32, @intCast(@as(u32, @truncate(imm >> 32)))),
.imm = @as(i32, @bitCast(@as(u32, @truncate(imm >> 32)))),
};
}