The following issues were found
tools/testing/selftests/bpf/progs/bpf_flow.c
1 issues
Line: 320
Column: 2
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
return export_flow_keys(keys, BPF_DROP);
keys->addr_proto = ETH_P_IPV6;
memcpy(&keys->ipv6_src, &ip6h->saddr, 2*sizeof(ip6h->saddr));
keys->thoff += sizeof(struct ipv6hdr);
keys->ip_proto = ip6h->nexthdr;
keys->flow_label = ip6_flowlabel(ip6h);
Reported by FlawFinder.
tools/testing/selftests/bpf/progs/bpf_iter_task_vma.c
1 issues
Line: 21
Column: 1
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
#define MINOR(dev) ((unsigned int) ((dev) & MINORMASK))
#define D_PATH_BUF_SIZE 1024
char d_path_buf[D_PATH_BUF_SIZE] = {};
__u32 pid = 0;
SEC("iter/task_vma") int proc_maps(struct bpf_iter__task_vma *ctx)
{
struct vm_area_struct *vma = ctx->vma;
Reported by FlawFinder.
tools/testing/selftests/bpf/progs/btf_dump_test_case_packing.c
1 issues
Line: 54
Column: 2
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
};
union jump_code_union {
char code[5];
struct {
char jump;
int offset;
} __attribute__((packed));
};
Reported by FlawFinder.
tools/testing/selftests/bpf/progs/btf_dump_test_case_padding.c
1 issues
Line: 96
Column: 2
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
/* ------ END-EXPECTED-OUTPUT ------ */
struct zone_padding {
char x[0];
} __attribute__((__aligned__(8)));
struct zone {
int a;
short b;
Reported by FlawFinder.
tools/testing/selftests/bpf/progs/freplace_connect4.c
1 issues
Line: 9
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_endian.h>
SEC("freplace/do_bind")
int new_do_bind(struct bpf_sock_addr *ctx)
{
struct sockaddr_in sa = {};
bpf_bind(ctx, (struct sockaddr *)&sa, sizeof(sa));
Reported by Cppcheck.
tools/testing/selftests/bpf/progs/freplace_connect_v4_prog.c
1 issues
Line: 12
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_endian.h>
SEC("freplace/connect_v4_prog")
int new_connect_v4_prog(struct bpf_sock_addr *ctx)
{
// return value thats in invalid range
return 255;
}
Reported by Cppcheck.
tools/testing/selftests/bpf/progs/lsm.c
1 issues
Line: 112
Column: 2
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
{
__u32 pid = bpf_get_current_pid_tgid() >> 32;
struct inner_map *inner_map;
char args[64];
__u32 key = 0;
__u64 *value;
if (monitored_pid == pid)
bprm_count++;
Reported by FlawFinder.
tools/testing/selftests/bpf/progs/recvmsg4_prog.c
1 issues
Line: 16
#define SERV4_IP 0xc0a801feU /* 192.168.1.254 */
#define SERV4_PORT 4040
SEC("cgroup/recvmsg4")
int recvmsg4_prog(struct bpf_sock_addr *ctx)
{
struct bpf_sock *sk;
__u32 user_ip4;
__u16 user_port;
Reported by Cppcheck.
tools/testing/selftests/bpf/progs/recvmsg6_prog.c
1 issues
Line: 19
#define SERV6_IP_3 0x0000abcd
#define SERV6_PORT 6060
SEC("cgroup/recvmsg6")
int recvmsg6_prog(struct bpf_sock_addr *ctx)
{
struct bpf_sock *sk;
__u32 user_ip4;
__u16 user_port;
Reported by Cppcheck.
tools/testing/selftests/bpf/progs/sockopt_sk.c
1 issues
Line: 153
Column: 3
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
if (optval + 5 > optval_end)
return 0; /* EPERM, bounds check */
memcpy(optval, "cubic", 5);
ctx->optlen = 5;
return 1;
}
Reported by FlawFinder.