* [PATCH bpf-next v2] bpf: fix a (false) compiler warning
@ 2019-01-16 18:43 Peter Oskolkov
2019-01-16 21:17 ` Martin Lau
2019-01-17 9:41 ` Daniel Borkmann
0 siblings, 2 replies; 3+ messages in thread
From: Peter Oskolkov @ 2019-01-16 18:43 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, netdev
Cc: Peter Oskolkov, Martin KaFai Lau, Peter Oskolkov
An older GCC compiler complains:
kernel/bpf/verifier.c: In function 'bpf_check':
kernel/bpf/verifier.c:4***:13: error: 'prev_offset' may be used uninitialized
in this function [-Werror=maybe-uninitialized]
} else if (krecord[i].insn_offset <= prev_offset) {
^
kernel/bpf/verifier.c:4***:38: note: 'prev_offset' was declared here
u32 i, nfuncs, urec_size, min_size, prev_offset;
Although the compiler is wrong here, the patch makes sure
that prev_offset is always initialized, just to silence the warning.
v2: fix a spelling error in the commit message.
Signed-off-by: Peter Oskolkov <posk@google.com>
---
kernel/bpf/verifier.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 56674a7c3778..ce87198ecd01 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -4997,13 +4997,14 @@ static int check_btf_func(struct bpf_verifier_env *env,
const union bpf_attr *attr,
union bpf_attr __user *uattr)
{
- u32 i, nfuncs, urec_size, min_size, prev_offset;
+ u32 i, nfuncs, urec_size, min_size;
u32 krec_size = sizeof(struct bpf_func_info);
struct bpf_func_info *krecord;
const struct btf_type *type;
struct bpf_prog *prog;
const struct btf *btf;
void __user *urecord;
+ u32 prev_offset = 0;
int ret = 0;
nfuncs = attr->func_info_cnt;
--
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH bpf-next v2] bpf: fix a (false) compiler warning
2019-01-16 18:43 [PATCH bpf-next v2] bpf: fix a (false) compiler warning Peter Oskolkov
@ 2019-01-16 21:17 ` Martin Lau
2019-01-17 9:41 ` Daniel Borkmann
1 sibling, 0 replies; 3+ messages in thread
From: Martin Lau @ 2019-01-16 21:17 UTC (permalink / raw)
To: Peter Oskolkov
Cc: Alexei Starovoitov, Daniel Borkmann, netdev@vger.kernel.org,
Peter Oskolkov
On Wed, Jan 16, 2019 at 10:43:01AM -0800, Peter Oskolkov wrote:
> An older GCC compiler complains:
>
> kernel/bpf/verifier.c: In function 'bpf_check':
> kernel/bpf/verifier.c:4***:13: error: 'prev_offset' may be used uninitialized
> in this function [-Werror=maybe-uninitialized]
> } else if (krecord[i].insn_offset <= prev_offset) {
> ^
> kernel/bpf/verifier.c:4***:38: note: 'prev_offset' was declared here
> u32 i, nfuncs, urec_size, min_size, prev_offset;
>
> Although the compiler is wrong here, the patch makes sure
> that prev_offset is always initialized, just to silence the warning.
>
> v2: fix a spelling error in the commit message.
>
> Signed-off-by: Peter Oskolkov <posk@google.com>
Acked-by: Martin KaFai Lau <kafai@fb.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH bpf-next v2] bpf: fix a (false) compiler warning
2019-01-16 18:43 [PATCH bpf-next v2] bpf: fix a (false) compiler warning Peter Oskolkov
2019-01-16 21:17 ` Martin Lau
@ 2019-01-17 9:41 ` Daniel Borkmann
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Borkmann @ 2019-01-17 9:41 UTC (permalink / raw)
To: Peter Oskolkov, Alexei Starovoitov, netdev
Cc: Peter Oskolkov, Martin KaFai Lau
On 01/16/2019 07:43 PM, Peter Oskolkov wrote:
> An older GCC compiler complains:
>
> kernel/bpf/verifier.c: In function 'bpf_check':
> kernel/bpf/verifier.c:4***:13: error: 'prev_offset' may be used uninitialized
> in this function [-Werror=maybe-uninitialized]
> } else if (krecord[i].insn_offset <= prev_offset) {
> ^
> kernel/bpf/verifier.c:4***:38: note: 'prev_offset' was declared here
> u32 i, nfuncs, urec_size, min_size, prev_offset;
>
> Although the compiler is wrong here, the patch makes sure
> that prev_offset is always initialized, just to silence the warning.
>
> v2: fix a spelling error in the commit message.
>
> Signed-off-by: Peter Oskolkov <posk@google.com>
Applied, thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-01-17 9:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-16 18:43 [PATCH bpf-next v2] bpf: fix a (false) compiler warning Peter Oskolkov
2019-01-16 21:17 ` Martin Lau
2019-01-17 9:41 ` Daniel Borkmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).