linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [perf] Fix null pointer deference in nest_epollfd
@ 2020-06-18  0:38 Gaurav Singh
  2020-06-18 14:48 ` Namhyung Kim
  0 siblings, 1 reply; 3+ messages in thread
From: Gaurav Singh @ 2020-06-18  0:38 UTC (permalink / raw)
  To: gaurav1086, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Tommi Rantala, Thomas Gleixner,
	open list:PERFORMANCE EVENTS SUBSYSTEM

Add a NULL check for worker before dereferencing.

Signed-off-by: Gaurav Singh <gaurav1086@gmail.com>
---
 tools/perf/bench/epoll-wait.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/perf/bench/epoll-wait.c b/tools/perf/bench/epoll-wait.c
index 75dca9773186..42983eb7f82e 100644
--- a/tools/perf/bench/epoll-wait.c
+++ b/tools/perf/bench/epoll-wait.c
@@ -239,6 +239,9 @@ static void *workerfn(void *arg)
 
 static void nest_epollfd(struct worker *w)
 {
+	if (!w)
+		return;
+
 	unsigned int i;
 	struct epoll_event ev;
 	int efd = multiq ? w->epollfd : epollfd;
-- 
2.17.1


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

* Re: [PATCH] [perf] Fix null pointer deference in nest_epollfd
  2020-06-18  0:38 [PATCH] [perf] Fix null pointer deference in nest_epollfd Gaurav Singh
@ 2020-06-18 14:48 ` Namhyung Kim
       [not found]   ` <CAFAFadA3rRQxw9nyGnhn7kshRfQ_2AN+d-eCwHF-HJ_bYfYVog@mail.gmail.com>
  0 siblings, 1 reply; 3+ messages in thread
From: Namhyung Kim @ 2020-06-18 14:48 UTC (permalink / raw)
  To: Gaurav Singh
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Tommi Rantala,
	Thomas Gleixner, open list:PERFORMANCE EVENTS SUBSYSTEM

Hello,

On Thu, Jun 18, 2020 at 9:39 AM Gaurav Singh <gaurav1086@gmail.com> wrote:
>
> Add a NULL check for worker before dereferencing.

Did you actually see a segfault due to this?
It seems it's called with NULL only if multiq is false
so there should not be a NULL dereference.

>
> Signed-off-by: Gaurav Singh <gaurav1086@gmail.com>
> ---
>  tools/perf/bench/epoll-wait.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/tools/perf/bench/epoll-wait.c b/tools/perf/bench/epoll-wait.c
> index 75dca9773186..42983eb7f82e 100644
> --- a/tools/perf/bench/epoll-wait.c
> +++ b/tools/perf/bench/epoll-wait.c
> @@ -239,6 +239,9 @@ static void *workerfn(void *arg)
>
>  static void nest_epollfd(struct worker *w)
>  {
> +       if (!w)
> +               return;
> +
>         unsigned int i;
>         struct epoll_event ev;
>         int efd = multiq ? w->epollfd : epollfd;

Maybe it's more intuitive to check w instead of multiq here.

Thanks
Namhyung


> --
> 2.17.1
>

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

* Re: [PATCH] [perf] Fix null pointer deference in nest_epollfd
       [not found]   ` <CAFAFadA3rRQxw9nyGnhn7kshRfQ_2AN+d-eCwHF-HJ_bYfYVog@mail.gmail.com>
@ 2020-06-19 13:12     ` Namhyung Kim
  0 siblings, 0 replies; 3+ messages in thread
From: Namhyung Kim @ 2020-06-19 13:12 UTC (permalink / raw)
  To: gaurav singh
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Tommi Rantala,
	Thomas Gleixner, open list:PERFORMANCE EVENTS SUBSYSTEM

On Fri, Jun 19, 2020 at 6:28 AM gaurav singh <gaurav1086@gmail.com> wrote:
>
> multiqu is a static bool which is never assigned and nested is a static int (=0)

It's set by command line option (-m).

Thanks
Namhyung


> and only assigned in nest_epollfd(). Hence,
>
>         if (nested)
>             nest_epollfd(NULL);
>
> probably never gets executed.

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

end of thread, other threads:[~2020-06-19 13:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-18  0:38 [PATCH] [perf] Fix null pointer deference in nest_epollfd Gaurav Singh
2020-06-18 14:48 ` Namhyung Kim
     [not found]   ` <CAFAFadA3rRQxw9nyGnhn7kshRfQ_2AN+d-eCwHF-HJ_bYfYVog@mail.gmail.com>
2020-06-19 13:12     ` Namhyung Kim

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).