2019-04-22 08:08:22

by Bo YU

[permalink] [raw]
Subject: [PATCH] perf bpf: return value with unlocking in perf_env__find_btf()

In perf_env__find_btf(), returning without unlocking
"env->bpf_progs.lock". There may be cause lockdep issue.

DEtected by CoversityScan, CID# 1444762:(program hangs(LOCK))

Fixes: 2db7b1e0bd49d: (perf bpf: Return NULL when RB tree lookup fails in perf_env__find_btf())
Signed-off-by: Bo YU <[email protected]>
---
tools/perf/util/env.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/env.c b/tools/perf/util/env.c
index 9494f9dc61ec..6a3eaf7d9353 100644
--- a/tools/perf/util/env.c
+++ b/tools/perf/util/env.c
@@ -115,8 +115,8 @@ struct btf_node *perf_env__find_btf(struct perf_env *env, __u32 btf_id)
}
node = NULL;

- up_read(&env->bpf_progs.lock);
out:
+ up_read(&env->bpf_progs.lock);
return node;
}

--
2.11.0


2019-04-22 09:38:50

by Jiri Olsa

[permalink] [raw]
Subject: Re: [PATCH] perf bpf: return value with unlocking in perf_env__find_btf()

On Mon, Apr 22, 2019 at 04:01:38AM -0400, Bo YU wrote:
> In perf_env__find_btf(), returning without unlocking
> "env->bpf_progs.lock". There may be cause lockdep issue.
>
> DEtected by CoversityScan, CID# 1444762:(program hangs(LOCK))
>
> Fixes: 2db7b1e0bd49d: (perf bpf: Return NULL when RB tree lookup fails in perf_env__find_btf())

ugh, sry about that

Acked-by: Jiri Olsa <[email protected]>

thanks,
jirka

> Signed-off-by: Bo YU <[email protected]>
> ---
> tools/perf/util/env.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/env.c b/tools/perf/util/env.c
> index 9494f9dc61ec..6a3eaf7d9353 100644
> --- a/tools/perf/util/env.c
> +++ b/tools/perf/util/env.c
> @@ -115,8 +115,8 @@ struct btf_node *perf_env__find_btf(struct perf_env *env, __u32 btf_id)
> }
> node = NULL;
>
> - up_read(&env->bpf_progs.lock);
> out:
> + up_read(&env->bpf_progs.lock);
> return node;
> }
>
> --
> 2.11.0
>

2019-04-22 14:53:19

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [PATCH] perf bpf: return value with unlocking in perf_env__find_btf()

Em Mon, Apr 22, 2019 at 11:36:29AM +0200, Jiri Olsa escreveu:
> On Mon, Apr 22, 2019 at 04:01:38AM -0400, Bo YU wrote:
> > In perf_env__find_btf(), returning without unlocking
> > "env->bpf_progs.lock". There may be cause lockdep issue.
> >
> > DEtected by CoversityScan, CID# 1444762:(program hangs(LOCK))
> >
> > Fixes: 2db7b1e0bd49d: (perf bpf: Return NULL when RB tree lookup fails in perf_env__find_btf())
>
> ugh, sry about that

Brown paper bag on the part of everybody involved indeed :-\

> Acked-by: Jiri Olsa <[email protected]>

Applied.

Thanks,

- Arnaldo

> thanks,
> jirka
>
> > Signed-off-by: Bo YU <[email protected]>
> > ---
> > tools/perf/util/env.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/tools/perf/util/env.c b/tools/perf/util/env.c
> > index 9494f9dc61ec..6a3eaf7d9353 100644
> > --- a/tools/perf/util/env.c
> > +++ b/tools/perf/util/env.c
> > @@ -115,8 +115,8 @@ struct btf_node *perf_env__find_btf(struct perf_env *env, __u32 btf_id)
> > }
> > node = NULL;
> >
> > - up_read(&env->bpf_progs.lock);
> > out:
> > + up_read(&env->bpf_progs.lock);
> > return node;
> > }
> >
> > --
> > 2.11.0
> >

--

- Arnaldo

Subject: [tip:perf/urgent] perf bpf: Return value with unlocking in perf_env__find_btf()

Commit-ID: 2e712675ffd1331bb527dfc851b0e98cd684c2f1
Gitweb: https://git.kernel.org/tip/2e712675ffd1331bb527dfc851b0e98cd684c2f1
Author: Bo YU <[email protected]>
AuthorDate: Mon, 22 Apr 2019 04:01:38 -0400
Committer: Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 2 May 2019 16:00:19 -0400

perf bpf: Return value with unlocking in perf_env__find_btf()

In perf_env__find_btf(), we're returning without unlocking
"env->bpf_progs.lock". There may be cause lockdep issue.

Detected by CoversityScan, CID# 1444762:(program hangs(LOCK))

Signed-off-by: Bo YU <[email protected]>
Acked-by: Jiri Olsa <[email protected]>
Cc: Adrian Hunter <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Alexei Starovoitov <[email protected]>
Cc: Daniel Borkmann <[email protected]>
Cc: Martin KaFai Lau <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Song Liu <[email protected]>
Cc: Yonghong Song <[email protected]>
Cc: [email protected]
Cc: [email protected]
Fixes: 2db7b1e0bd49d: (perf bpf: Return NULL when RB tree lookup fails in perf_env__find_btf())
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/util/env.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/env.c b/tools/perf/util/env.c
index 9494f9dc61ec..6a3eaf7d9353 100644
--- a/tools/perf/util/env.c
+++ b/tools/perf/util/env.c
@@ -115,8 +115,8 @@ struct btf_node *perf_env__find_btf(struct perf_env *env, __u32 btf_id)
}
node = NULL;

- up_read(&env->bpf_progs.lock);
out:
+ up_read(&env->bpf_progs.lock);
return node;
}