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: <239193b7-7dab-45b0-ab13-06bfe3f96f22@huawei.com>
Date: Wed, 20 Aug 2025 18:10:07 +0800
From: Pu Lehui <pulehui@...wei.com>
To: Chenghao Duan <duanchenghao@...inos.cn>
CC: <ast@...nel.org>, <bjorn@...nel.org>, <puranjay@...nel.org>,
	<paul.walmsley@...ive.com>, <palmer@...belt.com>, <aou@...s.berkeley.edu>,
	<daniel@...earbox.net>, <andrii@...nel.org>, <martin.lau@...ux.dev>,
	<eddyz87@...il.com>, <song@...nel.org>, <yonghong.song@...ux.dev>,
	<john.fastabend@...il.com>, <kpsingh@...nel.org>, <sdf@...ichev.me>,
	<haoluo@...gle.com>, <jolsa@...nel.org>, <alex@...ti.fr>,
	<bpf@...r.kernel.org>, <linux-riscv@...ts.infradead.org>,
	<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] riscv: bpf: Fix uninitialized symbol 'retval_off'



On 2025/8/20 17:26, Chenghao Duan wrote:
> On Wed, Aug 20, 2025 at 02:52:01PM +0800, Pu Lehui wrote:
>>
>>
>> On 2025/8/20 14:25, Chenghao Duan wrote:
>>> In __arch_prepare_bpf_trampoline(), retval_off is only meaningful when
>>> save_ret is true, so the current logic is correct. However, in the
>>
>> lgtm, and same for `ip_off`, pls patch it together.
> 
> I also checked at the time that ip_off is only initialized and assigned
> when flags & BPF_TRAMP_F_IP_ARG is true. However, I noticed that the use
> of ip_off also requires this condition, so the compiler did not issue a
> warning.
> 
> Chenghao
> 
>>
>>> original logic, retval_off is only initialized under certain

Can you show how to replay this warning? I guess the warning path is as 
follow. Compiler didn't know fmod_ret prog need BPF_TRAMP_F_CALL_ORIG.

```
if (fmod_ret->nr_links) {
	...
	emit_sd(RV_REG_FP, -retval_off, RV_REG_ZERO, ctx);
}
```

>>> conditions, which may cause a build warning.
>>>
>>> So initialize retval_off unconditionally to fix it.
>>>
>>> Signed-off-by: Chenghao Duan <duanchenghao@...inos.cn>
>>> ---
>>>    arch/riscv/net/bpf_jit_comp64.c | 5 ++---
>>>    1 file changed, 2 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/arch/riscv/net/bpf_jit_comp64.c b/arch/riscv/net/bpf_jit_comp64.c
>>> index 10e01ff06312..49bbda8372b0 100644
>>> --- a/arch/riscv/net/bpf_jit_comp64.c
>>> +++ b/arch/riscv/net/bpf_jit_comp64.c
>>> @@ -1079,10 +1079,9 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im,
>>>    	stack_size += 16;
>>>    	save_ret = flags & (BPF_TRAMP_F_CALL_ORIG | BPF_TRAMP_F_RET_FENTRY_RET);
>>> -	if (save_ret) {
>>> +	if (save_ret)
>>>    		stack_size += 16; /* Save both A5 (BPF R0) and A0 */
>>> -		retval_off = stack_size;
>>> -	}
>>> +	retval_off = stack_size;
>>>    	stack_size += nr_arg_slots * 8;
>>>    	args_off = stack_size;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ