Jann Horn
2af926fd52
splice: don't merge into linked buffers
...
commit a0ce2f0aa6 upstream.
Before this patch, it was possible for two pipes to affect each other after
data had been transferred between them with tee():
============
$ cat tee_test.c
int main(void) {
int pipe_a[2];
if (pipe(pipe_a)) err(1, "pipe");
int pipe_b[2];
if (pipe(pipe_b)) err(1, "pipe");
if (write(pipe_a[1], "abcd", 4) != 4) err(1, "write");
if (tee(pipe_a[0], pipe_b[1], 2, 0) != 2) err(1, "tee");
if (write(pipe_b[1], "xx", 2) != 2) err(1, "write");
char buf[5];
if (read(pipe_a[0], buf, 4) != 4) err(1, "read");
buf[4] = 0;
printf("got back: '%s'\n", buf);
}
$ gcc -o tee_test tee_test.c
$ ./tee_test
got back: 'abxx'
$
============
As suggested by Al Viro, fix it by creating a separate type for
non-mergeable pipe buffers, then changing the types of buffers in
splice_pipe_to_pipe() and link_pipe().
Cc: <stable@vger.kernel.org >
Fixes: 7c77f0b3f9 ("splice: implement pipe to pipe splicing")
Fixes: 70524490ee ("[PATCH] splice: add support for sys_tee()")
Suggested-by: Al Viro <viro@zeniv.linux.org.uk >
Signed-off-by: Jann Horn <jannh@google.com >
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk >
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2019-03-23 20:09:59 +01:00
..
2019-01-22 21:40:33 +01:00
2018-12-01 09:37:29 +01:00
2018-11-21 09:19:16 +01:00
2018-08-18 15:55:59 -07:00
2018-09-30 08:49:55 -07:00
2019-02-12 19:46:57 +01:00
2019-03-13 14:02:35 -07:00
2018-09-10 16:58:36 +01:00
2019-02-12 19:47:01 +01:00
2019-02-20 10:25:46 +01:00
2018-11-27 16:13:05 +01:00
2019-01-13 09:50:57 +01:00
2018-10-12 15:25:17 +01:00
2018-08-26 17:45:25 -07:00
2019-02-27 10:08:52 +01:00
2018-09-03 16:10:40 +01:00
2019-02-06 17:30:14 +01:00
2018-08-23 13:44:43 -07:00
2018-09-28 18:04:06 -07:00
2019-02-15 08:10:13 +01:00
2019-01-26 09:32:34 +01:00
2018-08-22 08:08:27 -07:00
2018-08-30 14:18:03 +01:00
2019-03-05 17:58:50 +01:00
2018-08-22 10:52:46 -07:00
2018-08-22 10:52:48 -07:00
2018-08-31 14:48:56 -06:00
2018-09-11 10:59:53 -06:00
2019-01-31 08:14:41 +01:00
2018-10-04 13:28:08 -07:00
2018-11-13 11:08:25 -08:00
2018-09-20 15:23:58 +02:00
2019-02-27 10:08:53 +01:00
2019-02-27 10:08:53 +01:00
2019-02-27 10:08:53 +01:00
2019-02-27 10:08:53 +01:00
2019-02-12 19:47:25 +01:00
2019-03-10 07:17:15 +01:00
2018-08-23 13:44:43 -07:00
2018-08-22 10:52:46 -07:00
2018-08-22 10:52:48 -07:00
2018-08-21 18:19:09 -07:00
2018-08-18 11:44:53 -07:00
2018-08-25 13:40:38 -07:00
2019-01-31 08:14:40 +01:00
2018-11-13 11:08:50 -08:00
2018-12-17 09:24:38 +01:00
2018-12-01 09:37:31 +01:00
2018-12-05 19:32:10 +01:00
2019-01-22 21:40:35 +01:00
2019-02-12 19:47:14 +01:00
2018-08-23 18:48:43 -07:00
2018-11-13 11:08:54 -08:00
2019-02-12 19:47:24 +01:00
2018-12-05 19:32:13 +01:00
2018-09-04 21:31:43 +02:00
2019-01-13 09:51:04 +01:00
2018-10-18 11:30:52 +02:00
2018-10-05 16:32:04 -07:00
2019-01-31 08:14:36 +01:00
2018-08-30 23:13:15 +02:00
2018-11-21 09:19:20 +01:00
2018-08-26 11:48:42 -07:00
2019-03-05 17:58:51 +01:00
2018-08-22 10:52:47 -07:00
2018-08-22 10:52:52 -07:00
2019-03-05 17:58:45 +01:00
2018-08-26 11:25:21 -07:00
2018-08-22 10:52:46 -07:00
2019-03-23 20:09:48 +01:00
2018-08-18 11:44:53 -07:00
2019-02-12 19:47:16 +01:00
2018-08-24 13:20:33 -07:00
2018-12-29 13:37:59 +01:00
2018-08-22 10:52:45 -07:00
2018-08-22 10:52:45 -07:00
2019-01-13 09:51:04 +01:00
2018-09-13 15:18:04 -10:00
2018-09-13 15:18:04 -10:00
2018-12-29 13:37:57 +01:00
2018-08-22 10:52:44 -07:00
2018-10-09 08:30:51 +02:00
2018-09-05 14:36:53 +02:00
2019-01-16 22:04:29 +01:00
2019-01-09 17:38:42 +01:00
2018-12-05 19:31:59 +01:00
2019-02-23 09:07:25 +01:00
2019-02-06 17:30:06 +01:00
2018-09-28 14:47:40 +02:00
2018-09-23 21:55:24 -07:00
2018-08-23 16:03:58 -07:00
2018-11-21 09:19:20 +01:00
2018-08-22 10:52:45 -07:00
2018-11-13 11:08:24 -08:00
2019-02-06 17:30:15 +01:00
2018-08-23 18:48:44 -07:00
2018-08-23 18:48:43 -07:00
2018-09-03 19:05:13 -07:00
2018-09-11 21:44:52 -05:00
2018-08-22 10:52:45 -07:00
2019-02-20 10:25:45 +01:00
2018-12-01 09:37:34 +01:00
2019-03-23 20:09:59 +01:00
2018-08-22 10:52:46 -07:00
2018-12-17 09:24:39 +01:00
2019-01-09 17:38:33 +01:00
2018-12-05 19:32:03 +01:00
2018-08-22 18:17:29 +02:00
2018-12-05 19:32:10 +01:00
2018-10-02 14:38:02 -07:00
2018-08-20 09:22:45 -07:00
2018-08-22 10:52:43 -07:00
2018-11-13 11:08:45 -08:00
2019-03-23 20:09:48 +01:00
2019-03-13 14:02:35 -07:00
2018-10-12 12:35:02 +02:00
2019-01-26 09:32:43 +01:00
2018-08-23 18:48:44 -07:00
2018-08-18 11:44:53 -07:00
2018-12-29 13:37:55 +01:00
2018-11-13 11:08:51 -08:00
2018-12-05 19:32:00 +01:00
2018-08-22 15:11:35 +02:00
2018-09-03 13:26:44 +02:00
2018-10-17 15:35:29 -04:00
2018-12-08 12:59:07 +01:00
2018-12-13 09:16:15 +01:00
2018-09-12 14:58:47 -07:00
2018-12-13 09:16:15 +01:00
2018-08-23 18:48:44 -07:00
2018-09-13 17:58:30 +02:00
2019-02-27 10:09:01 +01:00
2018-09-13 15:18:04 -10:00
2018-09-13 15:18:04 -10:00
2018-11-13 11:08:42 -08:00