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 {...@@ -642,7 +642,7 @@ pub const Insn = packed struct {
642 .dst = @intFromEnum(dst),642 .dst = @intFromEnum(dst),
643 .src = @intFromEnum(src),643 .src = @intFromEnum(src),
644 .off = 0,644 .off = 0,
645 .imm = @as(i32, @intCast(@as(u32, @truncate(imm)))),645 .imm = @as(i32, @bitCast(@as(u32, @truncate(imm)))),
646 };646 };
647 }647 }
648648
...@@ -652,7 +652,7 @@ pub const Insn = packed struct {...@@ -652,7 +652,7 @@ pub const Insn = packed struct {
652 .dst = 0,652 .dst = 0,
653 .src = 0,653 .src = 0,
654 .off = 0,654 .off = 0,
655 .imm = @as(i32, @intCast(@as(u32, @truncate(imm >> 32)))),655 .imm = @as(i32, @bitCast(@as(u32, @truncate(imm >> 32)))),
656 };656 };
657 }657 }
658658