Skip to content

Commit f487426

Browse files
committed
tracing: Break out of tracing_wait_pipe() before wait_pipe() is called
When reading from trace_pipe, if tracing is off but nothing was read it should block. If something is read and tracing is off, then EOF is returned. If tracing is on and there's nothing to read, it will block. But because the check of whether tracing is off and something was read is done after the block on the pipe, it is hit or miss if the EOF is returned or not leading to inconsistent behavior. Signed-off-by: Steven Rostedt <[email protected]>
1 parent 8d1b065 commit f487426

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

kernel/trace/trace.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4237,15 +4237,6 @@ static int tracing_wait_pipe(struct file *filp)
42374237
return -EAGAIN;
42384238
}
42394239

4240-
mutex_unlock(&iter->mutex);
4241-
4242-
iter->trace->wait_pipe(iter);
4243-
4244-
mutex_lock(&iter->mutex);
4245-
4246-
if (signal_pending(current))
4247-
return -EINTR;
4248-
42494240
/*
42504241
* We block until we read something and tracing is disabled.
42514242
* We still block if tracing is disabled, but we have never
@@ -4257,6 +4248,15 @@ static int tracing_wait_pipe(struct file *filp)
42574248
*/
42584249
if (!tracing_is_on() && iter->pos)
42594250
break;
4251+
4252+
mutex_unlock(&iter->mutex);
4253+
4254+
iter->trace->wait_pipe(iter);
4255+
4256+
mutex_lock(&iter->mutex);
4257+
4258+
if (signal_pending(current))
4259+
return -EINTR;
42604260
}
42614261

42624262
return 1;

0 commit comments

Comments
 (0)