Skip to content

Commit

Permalink
splice/tee/vmsplice: validate flags
Browse files Browse the repository at this point in the history
Long overdue...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Al Viro committed Dec 27, 2016
1 parent f81dc7d commit 3d6ea29
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions fs/splice.c
Original file line number Diff line number Diff line change
Expand Up @@ -1351,6 +1351,8 @@ SYSCALL_DEFINE4(vmsplice, int, fd, const struct iovec __user *, iov,
struct fd f;
long error;

if (unlikely(flags & ~SPLICE_F_ALL))
return -EINVAL;
if (unlikely(nr_segs > UIO_MAXIOV))
return -EINVAL;
else if (unlikely(!nr_segs))
Expand Down Expand Up @@ -1401,6 +1403,9 @@ SYSCALL_DEFINE6(splice, int, fd_in, loff_t __user *, off_in,
if (unlikely(!len))
return 0;

if (unlikely(flags & ~SPLICE_F_ALL))
return -EINVAL;

error = -EBADF;
in = fdget(fd_in);
if (in.file) {
Expand Down Expand Up @@ -1729,6 +1734,9 @@ SYSCALL_DEFINE4(tee, int, fdin, int, fdout, size_t, len, unsigned int, flags)
struct fd in;
int error;

if (unlikely(flags & ~SPLICE_F_ALL))
return -EINVAL;

if (unlikely(!len))
return 0;

Expand Down
2 changes: 2 additions & 0 deletions include/linux/splice.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#define SPLICE_F_MORE (0x04) /* expect more data */
#define SPLICE_F_GIFT (0x08) /* pages passed in are a gift */

#define SPLICE_F_ALL (SPLICE_F_MOVE|SPLICE_F_NONBLOCK|SPLICE_F_MORE|SPLICE_F_GIFT)

/*
* Passed to the actors
*/
Expand Down

0 comments on commit 3d6ea29

Please sign in to comment.