> Am 15.08.2019 um 22:35 schrieb Andrey Ignatov <rdna@xxxxxx>: > >> @@ -1344,20 +1379,26 @@ static size_t probe_prog_length(const struct bpf_insn *fp) >> static int fixup_sysctl_value(const char *buf, size_t buf_len, >> struct bpf_insn *prog, size_t insn_num) >> { >> - uint32_t value_num = 0; >> + uint64_t value_num = 0; >> uint8_t c, i; >> >> if (buf_len > sizeof(value_num)) { >> log_err("Value is too big (%zd) to use in fixup", buf_len); >> return -1; >> } >> + if (prog[insn_num].code != (BPF_LD | BPF_DW | BPF_IMM)) { >> + log_err("Can fixup only BPF_LD_IMM64 insns"); >> + return -1; >> + } >> >> for (i = 0; i < buf_len; ++i) { >> c = buf[i]; >> value_num |= (c << i * 8); >> } >> + value_num = __bpf_le64_to_cpu(value_num); >> >> - prog[insn_num].imm = value_num; >> + prog[insn_num].imm = (__u32)value_num; >> + prog[insn_num + 1].imm = (__u32)(value_num >> 32); >> >> return 0; >> } >> @@ -1499,6 +1540,7 @@ static int run_test_case(int cgfd, struct sysctl_test *test) >> goto err; >> } >> >> + errno = 0; > > Yeah, access_sysctl() can return -1 w/o affecting errno, did it cause a > problem, or you set it just in case? It's actually for another use case: if access_sysctl() unexpectedly returns 0, log_err() will misleadingly print a "random" errno. With this change, it would print "Unexpected success: errno: None", which makes sense to me.