Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

splice/tee/vmsplice: validate flags

Long overdue...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Al Viro 3d6ea290 f81dc7d7

+10
+8
fs/splice.c
··· 1351 1351 struct fd f; 1352 1352 long error; 1353 1353 1354 + if (unlikely(flags & ~SPLICE_F_ALL)) 1355 + return -EINVAL; 1354 1356 if (unlikely(nr_segs > UIO_MAXIOV)) 1355 1357 return -EINVAL; 1356 1358 else if (unlikely(!nr_segs)) ··· 1402 1400 1403 1401 if (unlikely(!len)) 1404 1402 return 0; 1403 + 1404 + if (unlikely(flags & ~SPLICE_F_ALL)) 1405 + return -EINVAL; 1405 1406 1406 1407 error = -EBADF; 1407 1408 in = fdget(fd_in); ··· 1733 1728 { 1734 1729 struct fd in; 1735 1730 int error; 1731 + 1732 + if (unlikely(flags & ~SPLICE_F_ALL)) 1733 + return -EINVAL; 1736 1734 1737 1735 if (unlikely(!len)) 1738 1736 return 0;
+2
include/linux/splice.h
··· 20 20 #define SPLICE_F_MORE (0x04) /* expect more data */ 21 21 #define SPLICE_F_GIFT (0x08) /* pages passed in are a gift */ 22 22 23 + #define SPLICE_F_ALL (SPLICE_F_MOVE|SPLICE_F_NONBLOCK|SPLICE_F_MORE|SPLICE_F_GIFT) 24 + 23 25 /* 24 26 * Passed to the actors 25 27 */