lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <03DE7252-51BD-4393-9F84-2B6C69ADA048@fb.com>
Date:   Thu, 14 Oct 2021 16:44:21 +0000
From:   Song Liu <songliubraving@...com>
To:     Kumar Kartikeya Dwivedi <memxor@...il.com>
CC:     bpf <bpf@...r.kernel.org>, Alexei Starovoitov <ast@...nel.org>,
        "Daniel Borkmann" <daniel@...earbox.net>,
        Andrii Nakryiko <andrii@...nel.org>,
        "Martin Lau" <kafai@...com>, Yonghong Song <yhs@...com>,
        Jesper Dangaard Brouer <brouer@...hat.com>,
        Toke Høiland-Jørgensen <toke@...hat.com>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: Re: [PATCH bpf-next v2 3/8] libbpf: Add weak ksym support to
 gen_loader



> On Oct 13, 2021, at 12:33 AM, Kumar Kartikeya Dwivedi <memxor@...il.com> wrote:
> 
> This extends existing ksym relocation code to also support relocating
> weak ksyms. Care needs to be taken to zero out the src_reg (currently
> BPF_PSEUOD_BTF_ID, always set for gen_loader by bpf_object__relocate_data)
> when the BTF ID lookup fails at runtime.  This is not a problem for
> libbpf as it only sets ext->is_set when BTF ID lookup succeeds (and only
> proceeds in case of failure if ext->is_weak, leading to src_reg
> remaining as 0 for weak unresolved ksym).

[...]

> 	emit(gen, BPF_ALU64_IMM(BPF_RSH, BPF_REG_7, 32));
> 	emit(gen, BPF_STX_MEM(BPF_W, BPF_REG_8, BPF_REG_7,
> 			      sizeof(struct bpf_insn) + offsetof(struct bpf_insn, imm)));
> -log:
> +	emit(gen, BPF_JMP_IMM(BPF_JSGE, BPF_REG_7, 0, 3));
> +clear_src_reg:
> +	/* clear bpf_object__relocate_data's src_reg assignment, otherwise we get a verifier failure */
> +#if defined(__LITTLE_ENDIAN_BITFIELD)
> +	reg_mask = 0x0f; /* src_reg,dst_reg,... */
> +#elif defined(__BIG_ENDIAN_BITFIELD)
> +	reg_mask = 0xf0; /* dst_reg,src_reg,... */
> +#else
> +#error "Unsupported bit endianness, cannot proceed"
> +#endif

nit: Please put the "if defined" block in an inline helper. 

> +	emit(gen, BPF_LDX_MEM(BPF_B, BPF_REG_9, BPF_REG_8, offsetofend(struct bpf_insn, code)));
> +	emit(gen, BPF_ALU32_IMM(BPF_AND, BPF_REG_9, reg_mask));
> +	emit(gen, BPF_STX_MEM(BPF_B, BPF_REG_8, BPF_REG_9, offsetofend(struct bpf_insn, code)));
> +
> 	if (!gen->log_level)
> 		return;
> 	emit(gen, BPF_LDX_MEM(BPF_W, BPF_REG_7, BPF_REG_8,

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ