All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH, net-next 1/2] bpf: btf: avoid -Wreturn-type warning
@ 2018-05-25 21:33 Arnd Bergmann
  2018-05-25 21:33 ` [PATCH, net-next 2/2] bpf: avoid -Wmaybe-uninitialized warning Arnd Bergmann
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Arnd Bergmann @ 2018-05-25 21:33 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann
  Cc: Arnd Bergmann, Martin KaFai Lau, Song Liu, netdev, linux-kernel

gcc warns about a noreturn function possibly returning in
some configurations:

kernel/bpf/btf.c: In function 'env_type_is_resolve_sink':
kernel/bpf/btf.c:729:1: error: control reaches end of non-void function [-Werror=return-type]

Using BUG() instead of BUG_ON() avoids that warning and otherwise
does the exact same thing.

Fixes: eb3f595dab40 ("bpf: btf: Validate type reference")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 kernel/bpf/btf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
index 9cbeabb5aca3..2822a0cf4f48 100644
--- a/kernel/bpf/btf.c
+++ b/kernel/bpf/btf.c
@@ -749,7 +749,7 @@ static bool env_type_is_resolve_sink(const struct btf_verifier_env *env,
 			!btf_type_is_array(next_type) &&
 			!btf_type_is_struct(next_type);
 	default:
-		BUG_ON(1);
+		BUG();
 	}
 }
 
-- 
2.9.0

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

* [PATCH, net-next 2/2] bpf: avoid -Wmaybe-uninitialized warning
  2018-05-25 21:33 [PATCH, net-next 1/2] bpf: btf: avoid -Wreturn-type warning Arnd Bergmann
@ 2018-05-25 21:33 ` Arnd Bergmann
  2018-05-25 21:54   ` Song Liu
  2018-05-27 22:37   ` Daniel Borkmann
  2018-05-25 21:53 ` [PATCH, net-next 1/2] bpf: btf: avoid -Wreturn-type warning Song Liu
  2018-05-27 22:36 ` Daniel Borkmann
  2 siblings, 2 replies; 6+ messages in thread
From: Arnd Bergmann @ 2018-05-25 21:33 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann
  Cc: Arnd Bergmann, Yonghong Song, David S. Miller, Song Liu,
	Martin KaFai Lau, Chenbo Feng, Jakub Kicinski, netdev,
	linux-kernel

The stack_map_get_build_id_offset() function is too long for gcc to track
whether 'work' may or may not be initialized at the end of it, leading
to a false-positive warning:

kernel/bpf/stackmap.c: In function 'stack_map_get_build_id_offset':
kernel/bpf/stackmap.c:334:13: error: 'work' may be used uninitialized in this function [-Werror=maybe-uninitialized]

This removes the 'in_nmi_ctx' flag and uses the state of that variable
itself to see if it got initialized.

Fixes: bae77c5eb5b2 ("bpf: enable stackmap with build_id in nmi context")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 kernel/bpf/stackmap.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/kernel/bpf/stackmap.c b/kernel/bpf/stackmap.c
index b59ace0f0f09..b675a3f3d141 100644
--- a/kernel/bpf/stackmap.c
+++ b/kernel/bpf/stackmap.c
@@ -285,11 +285,10 @@ static void stack_map_get_build_id_offset(struct bpf_stack_build_id *id_offs,
 {
 	int i;
 	struct vm_area_struct *vma;
-	bool in_nmi_ctx = in_nmi();
 	bool irq_work_busy = false;
-	struct stack_map_irq_work *work;
+	struct stack_map_irq_work *work = NULL;
 
-	if (in_nmi_ctx) {
+	if (in_nmi()) {
 		work = this_cpu_ptr(&up_read_work);
 		if (work->irq_work.flags & IRQ_WORK_BUSY)
 			/* cannot queue more up_read, fallback */
@@ -328,7 +327,7 @@ static void stack_map_get_build_id_offset(struct bpf_stack_build_id *id_offs,
 		id_offs[i].status = BPF_STACK_BUILD_ID_VALID;
 	}
 
-	if (!in_nmi_ctx) {
+	if (!work) {
 		up_read(&current->mm->mmap_sem);
 	} else {
 		work->sem = &current->mm->mmap_sem;
-- 
2.9.0

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

* Re: [PATCH, net-next 1/2] bpf: btf: avoid -Wreturn-type warning
  2018-05-25 21:33 [PATCH, net-next 1/2] bpf: btf: avoid -Wreturn-type warning Arnd Bergmann
  2018-05-25 21:33 ` [PATCH, net-next 2/2] bpf: avoid -Wmaybe-uninitialized warning Arnd Bergmann
@ 2018-05-25 21:53 ` Song Liu
  2018-05-27 22:36 ` Daniel Borkmann
  2 siblings, 0 replies; 6+ messages in thread
From: Song Liu @ 2018-05-25 21:53 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Alexei Starovoitov, Daniel Borkmann, Martin Lau, netdev, linux-kernel



> On May 25, 2018, at 2:33 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> 
> gcc warns about a noreturn function possibly returning in
> some configurations:
> 
> kernel/bpf/btf.c: In function 'env_type_is_resolve_sink':
> kernel/bpf/btf.c:729:1: error: control reaches end of non-void function [-Werror=return-type]
> 
> Using BUG() instead of BUG_ON() avoids that warning and otherwise
> does the exact same thing.
> 
> Fixes: eb3f595dab40 ("bpf: btf: Validate type reference")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> kernel/bpf/btf.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
> index 9cbeabb5aca3..2822a0cf4f48 100644
> --- a/kernel/bpf/btf.c
> +++ b/kernel/bpf/btf.c
> @@ -749,7 +749,7 @@ static bool env_type_is_resolve_sink(const struct btf_verifier_env *env,
> 			!btf_type_is_array(next_type) &&
> 			!btf_type_is_struct(next_type);
> 	default:
> -		BUG_ON(1);
> +		BUG();
> 	}
> }
> 
> -- 
> 2.9.0
> 

Acked-by: Song Liu <songliubraving@fb.com>

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

* Re: [PATCH, net-next 2/2] bpf: avoid -Wmaybe-uninitialized warning
  2018-05-25 21:33 ` [PATCH, net-next 2/2] bpf: avoid -Wmaybe-uninitialized warning Arnd Bergmann
@ 2018-05-25 21:54   ` Song Liu
  2018-05-27 22:37   ` Daniel Borkmann
  1 sibling, 0 replies; 6+ messages in thread
From: Song Liu @ 2018-05-25 21:54 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Alexei Starovoitov, Daniel Borkmann, Yonghong Song,
	David S. Miller, Martin Lau, Chenbo Feng, Jakub Kicinski, netdev,
	linux-kernel


> On May 25, 2018, at 2:33 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> 
> The stack_map_get_build_id_offset() function is too long for gcc to track
> whether 'work' may or may not be initialized at the end of it, leading
> to a false-positive warning:
> 
> kernel/bpf/stackmap.c: In function 'stack_map_get_build_id_offset':
> kernel/bpf/stackmap.c:334:13: error: 'work' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> 
> This removes the 'in_nmi_ctx' flag and uses the state of that variable
> itself to see if it got initialized.
> 
> Fixes: bae77c5eb5b2 ("bpf: enable stackmap with build_id in nmi context")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> kernel/bpf/stackmap.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/kernel/bpf/stackmap.c b/kernel/bpf/stackmap.c
> index b59ace0f0f09..b675a3f3d141 100644
> --- a/kernel/bpf/stackmap.c
> +++ b/kernel/bpf/stackmap.c
> @@ -285,11 +285,10 @@ static void stack_map_get_build_id_offset(struct bpf_stack_build_id *id_offs,
> {
> 	int i;
> 	struct vm_area_struct *vma;
> -	bool in_nmi_ctx = in_nmi();
> 	bool irq_work_busy = false;
> -	struct stack_map_irq_work *work;
> +	struct stack_map_irq_work *work = NULL;
> 
> -	if (in_nmi_ctx) {
> +	if (in_nmi()) {
> 		work = this_cpu_ptr(&up_read_work);
> 		if (work->irq_work.flags & IRQ_WORK_BUSY)
> 			/* cannot queue more up_read, fallback */
> @@ -328,7 +327,7 @@ static void stack_map_get_build_id_offset(struct bpf_stack_build_id *id_offs,
> 		id_offs[i].status = BPF_STACK_BUILD_ID_VALID;
> 	}
> 
> -	if (!in_nmi_ctx) {
> +	if (!work) {
> 		up_read(&current->mm->mmap_sem);
> 	} else {
> 		work->sem = &current->mm->mmap_sem;
> -- 
> 2.9.0
> 

Acked-by: Song Liu <songliubraving@fb.com>

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

* Re: [PATCH, net-next 1/2] bpf: btf: avoid -Wreturn-type warning
  2018-05-25 21:33 [PATCH, net-next 1/2] bpf: btf: avoid -Wreturn-type warning Arnd Bergmann
  2018-05-25 21:33 ` [PATCH, net-next 2/2] bpf: avoid -Wmaybe-uninitialized warning Arnd Bergmann
  2018-05-25 21:53 ` [PATCH, net-next 1/2] bpf: btf: avoid -Wreturn-type warning Song Liu
@ 2018-05-27 22:36 ` Daniel Borkmann
  2 siblings, 0 replies; 6+ messages in thread
From: Daniel Borkmann @ 2018-05-27 22:36 UTC (permalink / raw)
  To: Arnd Bergmann, Alexei Starovoitov
  Cc: Martin KaFai Lau, Song Liu, netdev, linux-kernel

On 05/25/2018 11:33 PM, Arnd Bergmann wrote:
> gcc warns about a noreturn function possibly returning in
> some configurations:
> 
> kernel/bpf/btf.c: In function 'env_type_is_resolve_sink':
> kernel/bpf/btf.c:729:1: error: control reaches end of non-void function [-Werror=return-type]
> 
> Using BUG() instead of BUG_ON() avoids that warning and otherwise
> does the exact same thing.
> 
> Fixes: eb3f595dab40 ("bpf: btf: Validate type reference")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Applied to bpf-next, thanks Arnd!

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

* Re: [PATCH, net-next 2/2] bpf: avoid -Wmaybe-uninitialized warning
  2018-05-25 21:33 ` [PATCH, net-next 2/2] bpf: avoid -Wmaybe-uninitialized warning Arnd Bergmann
  2018-05-25 21:54   ` Song Liu
@ 2018-05-27 22:37   ` Daniel Borkmann
  1 sibling, 0 replies; 6+ messages in thread
From: Daniel Borkmann @ 2018-05-27 22:37 UTC (permalink / raw)
  To: Arnd Bergmann, Alexei Starovoitov
  Cc: Yonghong Song, David S. Miller, Song Liu, Martin KaFai Lau,
	Chenbo Feng, Jakub Kicinski, netdev, linux-kernel

On 05/25/2018 11:33 PM, Arnd Bergmann wrote:
> The stack_map_get_build_id_offset() function is too long for gcc to track
> whether 'work' may or may not be initialized at the end of it, leading
> to a false-positive warning:
> 
> kernel/bpf/stackmap.c: In function 'stack_map_get_build_id_offset':
> kernel/bpf/stackmap.c:334:13: error: 'work' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> 
> This removes the 'in_nmi_ctx' flag and uses the state of that variable
> itself to see if it got initialized.
> 
> Fixes: bae77c5eb5b2 ("bpf: enable stackmap with build_id in nmi context")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Applied to bpf-next, thanks Arnd!

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

end of thread, other threads:[~2018-05-27 22:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-25 21:33 [PATCH, net-next 1/2] bpf: btf: avoid -Wreturn-type warning Arnd Bergmann
2018-05-25 21:33 ` [PATCH, net-next 2/2] bpf: avoid -Wmaybe-uninitialized warning Arnd Bergmann
2018-05-25 21:54   ` Song Liu
2018-05-27 22:37   ` Daniel Borkmann
2018-05-25 21:53 ` [PATCH, net-next 1/2] bpf: btf: avoid -Wreturn-type warning Song Liu
2018-05-27 22:36 ` Daniel Borkmann

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.