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-16 13:50:08+02:00
log05b7ca6356e4f394c084de8e806c1c93440e0b6b
treeef44d3e774d40a44f658e2f3fb13ec0574e1a3b2
parent4cfb58342ab40adc1a179bfde9fcb116f47bb9d7
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

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