Skip to content

Commit

Permalink
samples/bpf: fix sockex2 example
Browse files Browse the repository at this point in the history
since llvm commit "Do not expand UNDEF SDNode during insn selection lowering"
llvm will generate code that uses uninitialized registers for cases
where C code is actually uses uninitialized data.
So this sockex2 example is technically broken.
Fix it by initializing on the stack variable fully.
Also increase verifier buffer limit, since verifier output
may not fit in 64k for this sockex2 code depending on llvm version.

Signed-off-by: Alexei Starovoitov <[email protected]>
Acked-by: Daniel Borkmann <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
4ast authored and davem330 committed Nov 24, 2016
1 parent e3f42f8 commit d2b024d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion samples/bpf/libbpf.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ int bpf_prog_load(enum bpf_prog_type prog_type,
int bpf_obj_pin(int fd, const char *pathname);
int bpf_obj_get(const char *pathname);

#define LOG_BUF_SIZE 65536
#define LOG_BUF_SIZE (256 * 1024)
extern char bpf_log_buf[LOG_BUF_SIZE];

/* ALU ops on registers, bpf_add|sub|...: dst_reg += src_reg */
Expand Down
2 changes: 1 addition & 1 deletion samples/bpf/sockex2_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ struct bpf_map_def SEC("maps") hash_map = {
SEC("socket2")
int bpf_prog2(struct __sk_buff *skb)
{
struct bpf_flow_keys flow;
struct bpf_flow_keys flow = {};
struct pair *value;
u32 key;

Expand Down

0 comments on commit d2b024d

Please sign in to comment.