authorgravatar for george@feyor.shGeorge Huebner <george@feyor.sh> 2025-08-25 08:26:12-05:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-09-15 15:24:30+02:00
log496313a1bd4e8a4663ea99942d179a52b57e04e6
treecc4624ad0d31a0202ec20db018764dfedf88e567
parent87448654256d334e1d5877736a9747de67b7eedf

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.

1 files changed, 2 insertions(+), 2 deletions(-)

lib/std/os/linux/bpf.zig+2-2
......@@ -642,7 +642,7 @@ pub const Insn = packed struct {
642642 .dst = @intFromEnum(dst),
643643 .src = @intFromEnum(src),
644644 .off = 0,
645 .imm = @as(i32, @intCast(@as(u32, @truncate(imm)))),
645 .imm = @as(i32, @bitCast(@as(u32, @truncate(imm)))),
646646 };
647647 }
648648
......@@ -652,7 +652,7 @@ pub const Insn = packed struct {
652652 .dst = 0,
653653 .src = 0,
654654 .off = 0,
655 .imm = @as(i32, @intCast(@as(u32, @truncate(imm >> 32)))),
655 .imm = @as(i32, @bitCast(@as(u32, @truncate(imm >> 32)))),
656656 };
657657 }
658658