All of lore.kernel.org
 help / color / mirror / Atom feed
* error: ‘target’ may be used uninitialized in arch/mips/net/ebpf_jit.c
@ 2017-09-26 15:13 Matt Redfearn
  2017-09-26 16:08 ` David Daney
  2017-09-27  8:14   ` Matt Redfearn
  0 siblings, 2 replies; 4+ messages in thread
From: Matt Redfearn @ 2017-09-26 15:13 UTC (permalink / raw)
  To: David Daney; +Cc: Linux MIPS Mailing List

Hi David,

I see the following compiler error when I turn on CONFIG_MIPS_EBPF_JIT 
with v4.13 and v4.14-rc1 (cavium_octeon_defconfig based)

This is with gcc:

gcc version 4.9.2 (Codescape GNU Tools 2016.05-03 for MIPS MTI Linux)


arch/mips/net/ebpf_jit.c: In function ‘build_one_insn’:
arch/mips/net/ebpf_jit.c:1119:80: error: ‘target’ may be used 
uninitialized in this function [-Werror=maybe-uninitialized]
     emit_instr(ctx, j, target);
^
cc1: all warnings being treated as errors


This appears to have been the case since the ebpf_jit was merged in 
b6bd53f9c4e825fca82fe1392157c78443c814ab.

Thanks,

Matt

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: error: ‘target’ may be used uninitialized in arch/mips/net/ebpf_jit.c
  2017-09-26 15:13 error: ‘target’ may be used uninitialized in arch/mips/net/ebpf_jit.c Matt Redfearn
@ 2017-09-26 16:08 ` David Daney
  2017-09-27  8:14   ` Matt Redfearn
  1 sibling, 0 replies; 4+ messages in thread
From: David Daney @ 2017-09-26 16:08 UTC (permalink / raw)
  To: Matt Redfearn, David Daney; +Cc: Linux MIPS Mailing List

On 09/26/2017 08:13 AM, Matt Redfearn wrote:
> Hi David,
> 
> I see the following compiler error when I turn on CONFIG_MIPS_EBPF_JIT 
> with v4.13 and v4.14-rc1 (cavium_octeon_defconfig based)
> 
> This is with gcc:
> 
> gcc version 4.9.2 (Codescape GNU Tools 2016.05-03 for MIPS MTI Linux)
> 
> 

I am using a 4.7 based toolchain, and don't see this.

I think it really is initialized, but if you like you could add an 
initializer at the top of the function to quiet the compiler.


> arch/mips/net/ebpf_jit.c: In function ‘build_one_insn’:
> arch/mips/net/ebpf_jit.c:1119:80: error: ‘target’ may be used 
> uninitialized in this function [-Werror=maybe-uninitialized]
>      emit_instr(ctx, j, target);
> ^
> cc1: all warnings being treated as errors
> 
> 
> This appears to have been the case since the ebpf_jit was merged in 
> b6bd53f9c4e825fca82fe1392157c78443c814ab.
> 
> Thanks,
> 
> Matt
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] MIPS: bpf: Fix uninitialised target compiler error
@ 2017-09-27  8:14   ` Matt Redfearn
  0 siblings, 0 replies; 4+ messages in thread
From: Matt Redfearn @ 2017-09-27  8:14 UTC (permalink / raw)
  To: Ralf Baechle, James Hogan
  Cc: linux-mips, David Daney, Matt Redfearn, # v4 . 13+,
	linux-kernel, David S. Miller, Colin Ian King, Daniel Borkmann

Compiling ebpf_jit.c with gcc 4.9 results in a (likely spurious)
compiler warning, as gcc has detected that the variable "target" may be
used uninitialised. Since -Werror is active, this is treated as an error
and causes a kernel build failure whenever CONFIG_MIPS_EBPF_JIT is
enabled.

arch/mips/net/ebpf_jit.c: In function 'build_one_insn':
arch/mips/net/ebpf_jit.c:1118:80: error: 'target' may be used
uninitialized in this function [-Werror=maybe-uninitialized]
    emit_instr(ctx, j, target);
                                                                                ^
cc1: all warnings being treated as errors

Fix this by initialising "target" to 0. If it really is used
uninitialised this would result in a jump to 0 and a detectable run time
failure.

Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>
Fixes: b6bd53f9c4e8 ("MIPS: Add missing file for eBPF JIT.")
Cc: <stable@vger.kernel.org> # v4.13+
---

 arch/mips/net/ebpf_jit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/net/ebpf_jit.c b/arch/mips/net/ebpf_jit.c
index 7646891c4e9b..01b7a87ea678 100644
--- a/arch/mips/net/ebpf_jit.c
+++ b/arch/mips/net/ebpf_jit.c
@@ -667,7 +667,7 @@ static int build_one_insn(const struct bpf_insn *insn, struct jit_ctx *ctx,
 {
 	int src, dst, r, td, ts, mem_off, b_off;
 	bool need_swap, did_move, cmp_eq;
-	unsigned int target;
+	unsigned int target = 0;
 	u64 t64;
 	s64 t64s;
 	int bpf_op = BPF_OP(insn->code);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] MIPS: bpf: Fix uninitialised target compiler error
@ 2017-09-27  8:14   ` Matt Redfearn
  0 siblings, 0 replies; 4+ messages in thread
From: Matt Redfearn @ 2017-09-27  8:14 UTC (permalink / raw)
  To: Ralf Baechle, James Hogan
  Cc: linux-mips, David Daney, Matt Redfearn, # v4 . 13+,
	linux-kernel, David S. Miller, Colin Ian King, Daniel Borkmann

Compiling ebpf_jit.c with gcc 4.9 results in a (likely spurious)
compiler warning, as gcc has detected that the variable "target" may be
used uninitialised. Since -Werror is active, this is treated as an error
and causes a kernel build failure whenever CONFIG_MIPS_EBPF_JIT is
enabled.

arch/mips/net/ebpf_jit.c: In function 'build_one_insn':
arch/mips/net/ebpf_jit.c:1118:80: error: 'target' may be used
uninitialized in this function [-Werror=maybe-uninitialized]
    emit_instr(ctx, j, target);
                                                                                ^
cc1: all warnings being treated as errors

Fix this by initialising "target" to 0. If it really is used
uninitialised this would result in a jump to 0 and a detectable run time
failure.

Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>
Fixes: b6bd53f9c4e8 ("MIPS: Add missing file for eBPF JIT.")
Cc: <stable@vger.kernel.org> # v4.13+
---

 arch/mips/net/ebpf_jit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/net/ebpf_jit.c b/arch/mips/net/ebpf_jit.c
index 7646891c4e9b..01b7a87ea678 100644
--- a/arch/mips/net/ebpf_jit.c
+++ b/arch/mips/net/ebpf_jit.c
@@ -667,7 +667,7 @@ static int build_one_insn(const struct bpf_insn *insn, struct jit_ctx *ctx,
 {
 	int src, dst, r, td, ts, mem_off, b_off;
 	bool need_swap, did_move, cmp_eq;
-	unsigned int target;
+	unsigned int target = 0;
 	u64 t64;
 	s64 t64s;
 	int bpf_op = BPF_OP(insn->code);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-09-27  8:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-26 15:13 error: ‘target’ may be used uninitialized in arch/mips/net/ebpf_jit.c Matt Redfearn
2017-09-26 16:08 ` David Daney
2017-09-27  8:14 ` [PATCH] MIPS: bpf: Fix uninitialised target compiler error Matt Redfearn
2017-09-27  8:14   ` Matt Redfearn

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.