aboutsummaryrefslogtreecommitdiffstats
path: root/ipc/mqueue.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-10-02 23:25:04 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-10-02 23:25:04 -0400
commitaab174f0df5d72d31caccf281af5f614fa254578 (patch)
tree2a172c5009c4ac8755e858593154c258ce7709a0 /ipc/mqueue.c
parentca41cc96b2813221b05af57d0355157924de5a07 (diff)
parent2bd2c1941f141ad780135ccc1cd08ca71a24f10a (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs update from Al Viro: - big one - consolidation of descriptor-related logics; almost all of that is moved to fs/file.c (BTW, I'm seriously tempted to rename the result to fd.c. As it is, we have a situation when file_table.c is about handling of struct file and file.c is about handling of descriptor tables; the reasons are historical - file_table.c used to be about a static array of struct file we used to have way back). A lot of stray ends got cleaned up and converted to saner primitives, disgusting mess in android/binder.c is still disgusting, but at least doesn't poke so much in descriptor table guts anymore. A bunch of relatively minor races got fixed in process, plus an ext4 struct file leak. - related thing - fget_light() partially unuglified; see fdget() in there (and yes, it generates the code as good as we used to have). - also related - bits of Cyrill's procfs stuff that got entangled into that work; _not_ all of it, just the initial move to fs/proc/fd.c and switch of fdinfo to seq_file. - Alex's fs/coredump.c spiltoff - the same story, had been easier to take that commit than mess with conflicts. The rest is a separate pile, this was just a mechanical code movement. - a few misc patches all over the place. Not all for this cycle, there'll be more (and quite a few currently sit in akpm's tree)." Fix up trivial conflicts in the android binder driver, and some fairly simple conflicts due to two different changes to the sock_alloc_file() interface ("take descriptor handling from sock_alloc_file() to callers" vs "net: Providing protocol type via system.sockprotoname xattr of /proc/PID/fd entries" adding a dentry name to the socket) * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (72 commits) MAX_LFS_FILESIZE should be a loff_t compat: fs: Generic compat_sys_sendfile implementation fs: push rcu_barrier() from deactivate_locked_super() to filesystems btrfs: reada_extent doesn't need kref for refcount coredump: move core dump functionality into its own file coredump: prevent double-free on an error path in core dumper usb/gadget: fix misannotations fcntl: fix misannotations ceph: don't abuse d_delete() on failure exits hypfs: ->d_parent is never NULL or negative vfs: delete surplus inode NULL check switch simple cases of fget_light to fdget new helpers: fdget()/fdput() switch o2hb_region_dev_write() to fget_light() proc_map_files_readdir(): don't bother with grabbing files make get_file() return its argument vhost_set_vring(): turn pollstart/pollstop into bool switch prctl_set_mm_exe_file() to fget_light() switch xfs_find_handle() to fget_light() switch xfs_swapext() to fget_light() ...
Diffstat (limited to 'ipc/mqueue.c')
-rw-r--r--ipc/mqueue.c78
1 files changed, 39 insertions, 39 deletions
diff --git a/ipc/mqueue.c b/ipc/mqueue.c
index 9a08acc9e649..6d255e535d03 100644
--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -944,7 +944,7 @@ SYSCALL_DEFINE5(mq_timedsend, mqd_t, mqdes, const char __user *, u_msg_ptr,
944 size_t, msg_len, unsigned int, msg_prio, 944 size_t, msg_len, unsigned int, msg_prio,
945 const struct timespec __user *, u_abs_timeout) 945 const struct timespec __user *, u_abs_timeout)
946{ 946{
947 struct file *filp; 947 struct fd f;
948 struct inode *inode; 948 struct inode *inode;
949 struct ext_wait_queue wait; 949 struct ext_wait_queue wait;
950 struct ext_wait_queue *receiver; 950 struct ext_wait_queue *receiver;
@@ -967,21 +967,21 @@ SYSCALL_DEFINE5(mq_timedsend, mqd_t, mqdes, const char __user *, u_msg_ptr,
967 967
968 audit_mq_sendrecv(mqdes, msg_len, msg_prio, timeout ? &ts : NULL); 968 audit_mq_sendrecv(mqdes, msg_len, msg_prio, timeout ? &ts : NULL);
969 969
970 filp = fget(mqdes); 970 f = fdget(mqdes);
971 if (unlikely(!filp)) { 971 if (unlikely(!f.file)) {
972 ret = -EBADF; 972 ret = -EBADF;
973 goto out; 973 goto out;
974 } 974 }
975 975
976 inode = filp->f_path.dentry->d_inode; 976 inode = f.file->f_path.dentry->d_inode;
977 if (unlikely(filp->f_op != &mqueue_file_operations)) { 977 if (unlikely(f.file->f_op != &mqueue_file_operations)) {
978 ret = -EBADF; 978 ret = -EBADF;
979 goto out_fput; 979 goto out_fput;
980 } 980 }
981 info = MQUEUE_I(inode); 981 info = MQUEUE_I(inode);
982 audit_inode(NULL, filp->f_path.dentry); 982 audit_inode(NULL, f.file->f_path.dentry);
983 983
984 if (unlikely(!(filp->f_mode & FMODE_WRITE))) { 984 if (unlikely(!(f.file->f_mode & FMODE_WRITE))) {
985 ret = -EBADF; 985 ret = -EBADF;
986 goto out_fput; 986 goto out_fput;
987 } 987 }
@@ -1023,7 +1023,7 @@ SYSCALL_DEFINE5(mq_timedsend, mqd_t, mqdes, const char __user *, u_msg_ptr,
1023 } 1023 }
1024 1024
1025 if (info->attr.mq_curmsgs == info->attr.mq_maxmsg) { 1025 if (info->attr.mq_curmsgs == info->attr.mq_maxmsg) {
1026 if (filp->f_flags & O_NONBLOCK) { 1026 if (f.file->f_flags & O_NONBLOCK) {
1027 ret = -EAGAIN; 1027 ret = -EAGAIN;
1028 } else { 1028 } else {
1029 wait.task = current; 1029 wait.task = current;
@@ -1056,7 +1056,7 @@ out_free:
1056 if (ret) 1056 if (ret)
1057 free_msg(msg_ptr); 1057 free_msg(msg_ptr);
1058out_fput: 1058out_fput:
1059 fput(filp); 1059 fdput(f);
1060out: 1060out:
1061 return ret; 1061 return ret;
1062} 1062}
@@ -1067,7 +1067,7 @@ SYSCALL_DEFINE5(mq_timedreceive, mqd_t, mqdes, char __user *, u_msg_ptr,
1067{ 1067{
1068 ssize_t ret; 1068 ssize_t ret;
1069 struct msg_msg *msg_ptr; 1069 struct msg_msg *msg_ptr;
1070 struct file *filp; 1070 struct fd f;
1071 struct inode *inode; 1071 struct inode *inode;
1072 struct mqueue_inode_info *info; 1072 struct mqueue_inode_info *info;
1073 struct ext_wait_queue wait; 1073 struct ext_wait_queue wait;
@@ -1084,21 +1084,21 @@ SYSCALL_DEFINE5(mq_timedreceive, mqd_t, mqdes, char __user *, u_msg_ptr,
1084 1084
1085 audit_mq_sendrecv(mqdes, msg_len, 0, timeout ? &ts : NULL); 1085 audit_mq_sendrecv(mqdes, msg_len, 0, timeout ? &ts : NULL);
1086 1086
1087 filp = fget(mqdes); 1087 f = fdget(mqdes);
1088 if (unlikely(!filp)) { 1088 if (unlikely(!f.file)) {
1089 ret = -EBADF; 1089 ret = -EBADF;
1090 goto out; 1090 goto out;
1091 } 1091 }
1092 1092
1093 inode = filp->f_path.dentry->d_inode; 1093 inode = f.file->f_path.dentry->d_inode;
1094 if (unlikely(filp->f_op != &mqueue_file_operations)) { 1094 if (unlikely(f.file->f_op != &mqueue_file_operations)) {
1095 ret = -EBADF; 1095 ret = -EBADF;
1096 goto out_fput; 1096 goto out_fput;
1097 } 1097 }
1098 info = MQUEUE_I(inode); 1098 info = MQUEUE_I(inode);
1099 audit_inode(NULL, filp->f_path.dentry); 1099 audit_inode(NULL, f.file->f_path.dentry);
1100 1100
1101 if (unlikely(!(filp->f_mode & FMODE_READ))) { 1101 if (unlikely(!(f.file->f_mode & FMODE_READ))) {
1102 ret = -EBADF; 1102 ret = -EBADF;
1103 goto out_fput; 1103 goto out_fput;
1104 } 1104 }
@@ -1130,7 +1130,7 @@ SYSCALL_DEFINE5(mq_timedreceive, mqd_t, mqdes, char __user *, u_msg_ptr,
1130 } 1130 }
1131 1131
1132 if (info->attr.mq_curmsgs == 0) { 1132 if (info->attr.mq_curmsgs == 0) {
1133 if (filp->f_flags & O_NONBLOCK) { 1133 if (f.file->f_flags & O_NONBLOCK) {
1134 spin_unlock(&info->lock); 1134 spin_unlock(&info->lock);
1135 ret = -EAGAIN; 1135 ret = -EAGAIN;
1136 } else { 1136 } else {
@@ -1160,7 +1160,7 @@ SYSCALL_DEFINE5(mq_timedreceive, mqd_t, mqdes, char __user *, u_msg_ptr,
1160 free_msg(msg_ptr); 1160 free_msg(msg_ptr);
1161 } 1161 }
1162out_fput: 1162out_fput:
1163 fput(filp); 1163 fdput(f);
1164out: 1164out:
1165 return ret; 1165 return ret;
1166} 1166}
@@ -1174,7 +1174,7 @@ SYSCALL_DEFINE2(mq_notify, mqd_t, mqdes,
1174 const struct sigevent __user *, u_notification) 1174 const struct sigevent __user *, u_notification)
1175{ 1175{
1176 int ret; 1176 int ret;
1177 struct file *filp; 1177 struct fd f;
1178 struct sock *sock; 1178 struct sock *sock;
1179 struct inode *inode; 1179 struct inode *inode;
1180 struct sigevent notification; 1180 struct sigevent notification;
@@ -1220,13 +1220,13 @@ SYSCALL_DEFINE2(mq_notify, mqd_t, mqdes,
1220 skb_put(nc, NOTIFY_COOKIE_LEN); 1220 skb_put(nc, NOTIFY_COOKIE_LEN);
1221 /* and attach it to the socket */ 1221 /* and attach it to the socket */
1222retry: 1222retry:
1223 filp = fget(notification.sigev_signo); 1223 f = fdget(notification.sigev_signo);
1224 if (!filp) { 1224 if (!f.file) {
1225 ret = -EBADF; 1225 ret = -EBADF;
1226 goto out; 1226 goto out;
1227 } 1227 }
1228 sock = netlink_getsockbyfilp(filp); 1228 sock = netlink_getsockbyfilp(f.file);
1229 fput(filp); 1229 fdput(f);
1230 if (IS_ERR(sock)) { 1230 if (IS_ERR(sock)) {
1231 ret = PTR_ERR(sock); 1231 ret = PTR_ERR(sock);
1232 sock = NULL; 1232 sock = NULL;
@@ -1245,14 +1245,14 @@ retry:
1245 } 1245 }
1246 } 1246 }
1247 1247
1248 filp = fget(mqdes); 1248 f = fdget(mqdes);
1249 if (!filp) { 1249 if (!f.file) {
1250 ret = -EBADF; 1250 ret = -EBADF;
1251 goto out; 1251 goto out;
1252 } 1252 }
1253 1253
1254 inode = filp->f_path.dentry->d_inode; 1254 inode = f.file->f_path.dentry->d_inode;
1255 if (unlikely(filp->f_op != &mqueue_file_operations)) { 1255 if (unlikely(f.file->f_op != &mqueue_file_operations)) {
1256 ret = -EBADF; 1256 ret = -EBADF;
1257 goto out_fput; 1257 goto out_fput;
1258 } 1258 }
@@ -1292,7 +1292,7 @@ retry:
1292 } 1292 }
1293 spin_unlock(&info->lock); 1293 spin_unlock(&info->lock);
1294out_fput: 1294out_fput:
1295 fput(filp); 1295 fdput(f);
1296out: 1296out:
1297 if (sock) { 1297 if (sock) {
1298 netlink_detachskb(sock, nc); 1298 netlink_detachskb(sock, nc);
@@ -1308,7 +1308,7 @@ SYSCALL_DEFINE3(mq_getsetattr, mqd_t, mqdes,
1308{ 1308{
1309 int ret; 1309 int ret;
1310 struct mq_attr mqstat, omqstat; 1310 struct mq_attr mqstat, omqstat;
1311 struct file *filp; 1311 struct fd f;
1312 struct inode *inode; 1312 struct inode *inode;
1313 struct mqueue_inode_info *info; 1313 struct mqueue_inode_info *info;
1314 1314
@@ -1319,14 +1319,14 @@ SYSCALL_DEFINE3(mq_getsetattr, mqd_t, mqdes,
1319 return -EINVAL; 1319 return -EINVAL;
1320 } 1320 }
1321 1321
1322 filp = fget(mqdes); 1322 f = fdget(mqdes);
1323 if (!filp) { 1323 if (!f.file) {
1324 ret = -EBADF; 1324 ret = -EBADF;
1325 goto out; 1325 goto out;
1326 } 1326 }
1327 1327
1328 inode = filp->f_path.dentry->d_inode; 1328 inode = f.file->f_path.dentry->d_inode;
1329 if (unlikely(filp->f_op != &mqueue_file_operations)) { 1329 if (unlikely(f.file->f_op != &mqueue_file_operations)) {
1330 ret = -EBADF; 1330 ret = -EBADF;
1331 goto out_fput; 1331 goto out_fput;
1332 } 1332 }
@@ -1335,15 +1335,15 @@ SYSCALL_DEFINE3(mq_getsetattr, mqd_t, mqdes,
1335 spin_lock(&info->lock); 1335 spin_lock(&info->lock);
1336 1336
1337 omqstat = info->attr; 1337 omqstat = info->attr;
1338 omqstat.mq_flags = filp->f_flags & O_NONBLOCK; 1338 omqstat.mq_flags = f.file->f_flags & O_NONBLOCK;
1339 if (u_mqstat) { 1339 if (u_mqstat) {
1340 audit_mq_getsetattr(mqdes, &mqstat); 1340 audit_mq_getsetattr(mqdes, &mqstat);
1341 spin_lock(&filp->f_lock); 1341 spin_lock(&f.file->f_lock);
1342 if (mqstat.mq_flags & O_NONBLOCK) 1342 if (mqstat.mq_flags & O_NONBLOCK)
1343 filp->f_flags |= O_NONBLOCK; 1343 f.file->f_flags |= O_NONBLOCK;
1344 else 1344 else
1345 filp->f_flags &= ~O_NONBLOCK; 1345 f.file->f_flags &= ~O_NONBLOCK;
1346 spin_unlock(&filp->f_lock); 1346 spin_unlock(&f.file->f_lock);
1347 1347
1348 inode->i_atime = inode->i_ctime = CURRENT_TIME; 1348 inode->i_atime = inode->i_ctime = CURRENT_TIME;
1349 } 1349 }
@@ -1356,7 +1356,7 @@ SYSCALL_DEFINE3(mq_getsetattr, mqd_t, mqdes,
1356 ret = -EFAULT; 1356 ret = -EFAULT;
1357 1357
1358out_fput: 1358out_fput:
1359 fput(filp); 1359 fdput(f);
1360out: 1360out:
1361 return ret; 1361 return ret;
1362} 1362}