diff options
Diffstat (limited to 'fs/pipe.c')
-rw-r--r-- | fs/pipe.c | 23 |
1 files changed, 18 insertions, 5 deletions
@@ -1027,12 +1027,15 @@ struct file *create_read_pipe(struct file *wrf) | |||
1027 | return f; | 1027 | return f; |
1028 | } | 1028 | } |
1029 | 1029 | ||
1030 | int do_pipe(int *fd) | 1030 | int do_pipe_flags(int *fd, int flags) |
1031 | { | 1031 | { |
1032 | struct file *fw, *fr; | 1032 | struct file *fw, *fr; |
1033 | int error; | 1033 | int error; |
1034 | int fdw, fdr; | 1034 | int fdw, fdr; |
1035 | 1035 | ||
1036 | if (flags & ~O_CLOEXEC) | ||
1037 | return -EINVAL; | ||
1038 | |||
1036 | fw = create_write_pipe(); | 1039 | fw = create_write_pipe(); |
1037 | if (IS_ERR(fw)) | 1040 | if (IS_ERR(fw)) |
1038 | return PTR_ERR(fw); | 1041 | return PTR_ERR(fw); |
@@ -1041,12 +1044,12 @@ int do_pipe(int *fd) | |||
1041 | if (IS_ERR(fr)) | 1044 | if (IS_ERR(fr)) |
1042 | goto err_write_pipe; | 1045 | goto err_write_pipe; |
1043 | 1046 | ||
1044 | error = get_unused_fd(); | 1047 | error = get_unused_fd_flags(flags); |
1045 | if (error < 0) | 1048 | if (error < 0) |
1046 | goto err_read_pipe; | 1049 | goto err_read_pipe; |
1047 | fdr = error; | 1050 | fdr = error; |
1048 | 1051 | ||
1049 | error = get_unused_fd(); | 1052 | error = get_unused_fd_flags(flags); |
1050 | if (error < 0) | 1053 | if (error < 0) |
1051 | goto err_fdr; | 1054 | goto err_fdr; |
1052 | fdw = error; | 1055 | fdw = error; |
@@ -1074,16 +1077,21 @@ int do_pipe(int *fd) | |||
1074 | return error; | 1077 | return error; |
1075 | } | 1078 | } |
1076 | 1079 | ||
1080 | int do_pipe(int *fd) | ||
1081 | { | ||
1082 | return do_pipe_flags(fd, 0); | ||
1083 | } | ||
1084 | |||
1077 | /* | 1085 | /* |
1078 | * sys_pipe() is the normal C calling standard for creating | 1086 | * sys_pipe() is the normal C calling standard for creating |
1079 | * a pipe. It's not the way Unix traditionally does this, though. | 1087 | * a pipe. It's not the way Unix traditionally does this, though. |
1080 | */ | 1088 | */ |
1081 | asmlinkage long __weak sys_pipe(int __user *fildes) | 1089 | asmlinkage long __weak sys_pipe2(int __user *fildes, int flags) |
1082 | { | 1090 | { |
1083 | int fd[2]; | 1091 | int fd[2]; |
1084 | int error; | 1092 | int error; |
1085 | 1093 | ||
1086 | error = do_pipe(fd); | 1094 | error = do_pipe_flags(fd, flags); |
1087 | if (!error) { | 1095 | if (!error) { |
1088 | if (copy_to_user(fildes, fd, sizeof(fd))) { | 1096 | if (copy_to_user(fildes, fd, sizeof(fd))) { |
1089 | sys_close(fd[0]); | 1097 | sys_close(fd[0]); |
@@ -1094,6 +1102,11 @@ asmlinkage long __weak sys_pipe(int __user *fildes) | |||
1094 | return error; | 1102 | return error; |
1095 | } | 1103 | } |
1096 | 1104 | ||
1105 | asmlinkage long __weak sys_pipe(int __user *fildes) | ||
1106 | { | ||
1107 | return sys_pipe2(fildes, 0); | ||
1108 | } | ||
1109 | |||
1097 | /* | 1110 | /* |
1098 | * pipefs should _never_ be mounted by userland - too much of security hassle, | 1111 | * pipefs should _never_ be mounted by userland - too much of security hassle, |
1099 | * no real gain from having the whole whorehouse mounted. So we don't need | 1112 | * no real gain from having the whole whorehouse mounted. So we don't need |