mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-24 09:20:50 +07:00
Al Viro has been looking at the tracefs code, and has pointed out
some issues. This contains one fix by me and one by Al. I'm sure that he'll come up with more but for now I tested these patches and they don't appear to have any negative impact on tracing. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAABAgAGBQJX6FvrAAoJEKKk/i67LK/8EuIH/Arf6vJidYsmbe57WQp8PU3I bldem6ePj6zgZ2ZqPlSGCs1J2DcK4Bh3lPVxdx7rRKVWSd/Zoj+i83hvObusR8M7 Qs1G92bJTvvVO3aPfiN0GvKGdKfGn45L+j0BcBauiTRKqnj3PkhOhIP2/ks0ewSk qeq7R3xxo/FDs26AHS69Hm0PIIw7btyhXNX4GB3Il7IIA5/nUknw3C+bjVj86tYX R4iElcHEhplgoSjKuLgNIRZGUnEFtsm/fnohYXpHacLTUKNXnTDY230x/OKc1yyB 1vOfHS/y5s3XSJ1lcgSjYeNc51lK8NiDASaptZSUnOookKSAooUTFELNzpbc0sg= =+Fr3 -----END PGP SIGNATURE----- Merge tag 'trace-v4.8-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace Pull tracefs fixes from Steven Rostedt: "Al Viro has been looking at the tracefs code, and has pointed out some issues. This contains one fix by me and one by Al. I'm sure that he'll come up with more but for now I tested these patches and they don't appear to have any negative impact on tracing" * tag 'trace-v4.8-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: fix memory leaks in tracing_buffers_splice_read() tracing: Move mutex to protect against resetting of seq data
This commit is contained in:
commit
4c04b4b534
@ -5124,19 +5124,20 @@ tracing_read_pipe(struct file *filp, char __user *ubuf,
|
||||
struct trace_iterator *iter = filp->private_data;
|
||||
ssize_t sret;
|
||||
|
||||
/* return any leftover data */
|
||||
sret = trace_seq_to_user(&iter->seq, ubuf, cnt);
|
||||
if (sret != -EBUSY)
|
||||
return sret;
|
||||
|
||||
trace_seq_init(&iter->seq);
|
||||
|
||||
/*
|
||||
* Avoid more than one consumer on a single file descriptor
|
||||
* This is just a matter of traces coherency, the ring buffer itself
|
||||
* is protected.
|
||||
*/
|
||||
mutex_lock(&iter->mutex);
|
||||
|
||||
/* return any leftover data */
|
||||
sret = trace_seq_to_user(&iter->seq, ubuf, cnt);
|
||||
if (sret != -EBUSY)
|
||||
goto out;
|
||||
|
||||
trace_seq_init(&iter->seq);
|
||||
|
||||
if (iter->trace->read) {
|
||||
sret = iter->trace->read(iter, filp, ubuf, cnt, ppos);
|
||||
if (sret)
|
||||
@ -6163,9 +6164,6 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos,
|
||||
return -EBUSY;
|
||||
#endif
|
||||
|
||||
if (splice_grow_spd(pipe, &spd))
|
||||
return -ENOMEM;
|
||||
|
||||
if (*ppos & (PAGE_SIZE - 1))
|
||||
return -EINVAL;
|
||||
|
||||
@ -6175,6 +6173,9 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos,
|
||||
len &= PAGE_MASK;
|
||||
}
|
||||
|
||||
if (splice_grow_spd(pipe, &spd))
|
||||
return -ENOMEM;
|
||||
|
||||
again:
|
||||
trace_access_lock(iter->cpu_file);
|
||||
entries = ring_buffer_entries_cpu(iter->trace_buffer->buffer, iter->cpu_file);
|
||||
@ -6232,19 +6233,21 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos,
|
||||
/* did we read anything? */
|
||||
if (!spd.nr_pages) {
|
||||
if (ret)
|
||||
return ret;
|
||||
goto out;
|
||||
|
||||
ret = -EAGAIN;
|
||||
if ((file->f_flags & O_NONBLOCK) || (flags & SPLICE_F_NONBLOCK))
|
||||
return -EAGAIN;
|
||||
goto out;
|
||||
|
||||
ret = wait_on_pipe(iter, true);
|
||||
if (ret)
|
||||
return ret;
|
||||
goto out;
|
||||
|
||||
goto again;
|
||||
}
|
||||
|
||||
ret = splice_to_pipe(pipe, &spd);
|
||||
out:
|
||||
splice_shrink_spd(&spd);
|
||||
|
||||
return ret;
|
||||
|
Loading…
Reference in New Issue
Block a user