Skip to content

Commit 7d71f59

Browse files
borkmannAlexei Starovoitov
authored andcommitted
bpf: Remove truncation test in bpf_strtol and bpf_strtoul helpers
Both bpf_strtol() and bpf_strtoul() helpers passed a temporary "long long" respectively "unsigned long long" to __bpf_strtoll() / __bpf_strtoull(). Later, the result was checked for truncation via _res != ({unsigned,} long)_res as the destination buffer for the BPF helpers was of type {unsigned,} long which is 32bit on 32bit architectures. Given the latter was a bug in the helper signatures where the destination buffer got adjusted to {s,u}64, the truncation check can now be removed. Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent cfe69c5 commit 7d71f59

File tree

1 file changed

+0
-4
lines changed

1 file changed

+0
-4
lines changed

kernel/bpf/helpers.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -526,8 +526,6 @@ BPF_CALL_4(bpf_strtol, const char *, buf, size_t, buf_len, u64, flags,
526526
err = __bpf_strtoll(buf, buf_len, flags, &_res);
527527
if (err < 0)
528528
return err;
529-
if (_res != (long)_res)
530-
return -ERANGE;
531529
*res = _res;
532530
return err;
533531
}
@@ -554,8 +552,6 @@ BPF_CALL_4(bpf_strtoul, const char *, buf, size_t, buf_len, u64, flags,
554552
return err;
555553
if (is_negative)
556554
return -EINVAL;
557-
if (_res != (unsigned long)_res)
558-
return -ERANGE;
559555
*res = _res;
560556
return err;
561557
}

0 commit comments

Comments
 (0)