Commit 515e0d66 authored by Al Viro's avatar Al Viro

switch mqueue syscalls to fget_light()

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent bdbf6943
...@@ -953,7 +953,7 @@ SYSCALL_DEFINE5(mq_timedsend, mqd_t, mqdes, const char __user *, u_msg_ptr, ...@@ -953,7 +953,7 @@ SYSCALL_DEFINE5(mq_timedsend, mqd_t, mqdes, const char __user *, u_msg_ptr,
ktime_t expires, *timeout = NULL; ktime_t expires, *timeout = NULL;
struct timespec ts; struct timespec ts;
struct posix_msg_tree_node *new_leaf = NULL; struct posix_msg_tree_node *new_leaf = NULL;
int ret = 0; int ret = 0, fput_needed;
if (u_abs_timeout) { if (u_abs_timeout) {
int res = prepare_timeout(u_abs_timeout, &expires, &ts); int res = prepare_timeout(u_abs_timeout, &expires, &ts);
...@@ -967,7 +967,7 @@ SYSCALL_DEFINE5(mq_timedsend, mqd_t, mqdes, const char __user *, u_msg_ptr, ...@@ -967,7 +967,7 @@ SYSCALL_DEFINE5(mq_timedsend, mqd_t, mqdes, const char __user *, u_msg_ptr,
audit_mq_sendrecv(mqdes, msg_len, msg_prio, timeout ? &ts : NULL); audit_mq_sendrecv(mqdes, msg_len, msg_prio, timeout ? &ts : NULL);
filp = fget(mqdes); filp = fget_light(mqdes, &fput_needed);
if (unlikely(!filp)) { if (unlikely(!filp)) {
ret = -EBADF; ret = -EBADF;
goto out; goto out;
...@@ -1056,7 +1056,7 @@ SYSCALL_DEFINE5(mq_timedsend, mqd_t, mqdes, const char __user *, u_msg_ptr, ...@@ -1056,7 +1056,7 @@ SYSCALL_DEFINE5(mq_timedsend, mqd_t, mqdes, const char __user *, u_msg_ptr,
if (ret) if (ret)
free_msg(msg_ptr); free_msg(msg_ptr);
out_fput: out_fput:
fput(filp); fput_light(filp, fput_needed);
out: out:
return ret; return ret;
} }
...@@ -1074,6 +1074,7 @@ SYSCALL_DEFINE5(mq_timedreceive, mqd_t, mqdes, char __user *, u_msg_ptr, ...@@ -1074,6 +1074,7 @@ SYSCALL_DEFINE5(mq_timedreceive, mqd_t, mqdes, char __user *, u_msg_ptr,
ktime_t expires, *timeout = NULL; ktime_t expires, *timeout = NULL;
struct timespec ts; struct timespec ts;
struct posix_msg_tree_node *new_leaf = NULL; struct posix_msg_tree_node *new_leaf = NULL;
int fput_needed;
if (u_abs_timeout) { if (u_abs_timeout) {
int res = prepare_timeout(u_abs_timeout, &expires, &ts); int res = prepare_timeout(u_abs_timeout, &expires, &ts);
...@@ -1084,7 +1085,7 @@ SYSCALL_DEFINE5(mq_timedreceive, mqd_t, mqdes, char __user *, u_msg_ptr, ...@@ -1084,7 +1085,7 @@ SYSCALL_DEFINE5(mq_timedreceive, mqd_t, mqdes, char __user *, u_msg_ptr,
audit_mq_sendrecv(mqdes, msg_len, 0, timeout ? &ts : NULL); audit_mq_sendrecv(mqdes, msg_len, 0, timeout ? &ts : NULL);
filp = fget(mqdes); filp = fget_light(mqdes, &fput_needed);
if (unlikely(!filp)) { if (unlikely(!filp)) {
ret = -EBADF; ret = -EBADF;
goto out; goto out;
...@@ -1160,7 +1161,7 @@ SYSCALL_DEFINE5(mq_timedreceive, mqd_t, mqdes, char __user *, u_msg_ptr, ...@@ -1160,7 +1161,7 @@ SYSCALL_DEFINE5(mq_timedreceive, mqd_t, mqdes, char __user *, u_msg_ptr,
free_msg(msg_ptr); free_msg(msg_ptr);
} }
out_fput: out_fput:
fput(filp); fput_light(filp, fput_needed);
out: out:
return ret; return ret;
} }
...@@ -1173,7 +1174,7 @@ SYSCALL_DEFINE5(mq_timedreceive, mqd_t, mqdes, char __user *, u_msg_ptr, ...@@ -1173,7 +1174,7 @@ SYSCALL_DEFINE5(mq_timedreceive, mqd_t, mqdes, char __user *, u_msg_ptr,
SYSCALL_DEFINE2(mq_notify, mqd_t, mqdes, SYSCALL_DEFINE2(mq_notify, mqd_t, mqdes,
const struct sigevent __user *, u_notification) const struct sigevent __user *, u_notification)
{ {
int ret; int ret, fput_needed;
struct file *filp; struct file *filp;
struct sock *sock; struct sock *sock;
struct inode *inode; struct inode *inode;
...@@ -1220,13 +1221,13 @@ SYSCALL_DEFINE2(mq_notify, mqd_t, mqdes, ...@@ -1220,13 +1221,13 @@ SYSCALL_DEFINE2(mq_notify, mqd_t, mqdes,
skb_put(nc, NOTIFY_COOKIE_LEN); skb_put(nc, NOTIFY_COOKIE_LEN);
/* and attach it to the socket */ /* and attach it to the socket */
retry: retry:
filp = fget(notification.sigev_signo); filp = fget_light(notification.sigev_signo, &fput_needed);
if (!filp) { if (!filp) {
ret = -EBADF; ret = -EBADF;
goto out; goto out;
} }
sock = netlink_getsockbyfilp(filp); sock = netlink_getsockbyfilp(filp);
fput(filp); fput_light(filp, fput_needed);
if (IS_ERR(sock)) { if (IS_ERR(sock)) {
ret = PTR_ERR(sock); ret = PTR_ERR(sock);
sock = NULL; sock = NULL;
...@@ -1245,7 +1246,7 @@ SYSCALL_DEFINE2(mq_notify, mqd_t, mqdes, ...@@ -1245,7 +1246,7 @@ SYSCALL_DEFINE2(mq_notify, mqd_t, mqdes,
} }
} }
filp = fget(mqdes); filp = fget_light(mqdes, &fput_needed);
if (!filp) { if (!filp) {
ret = -EBADF; ret = -EBADF;
goto out; goto out;
...@@ -1292,7 +1293,7 @@ SYSCALL_DEFINE2(mq_notify, mqd_t, mqdes, ...@@ -1292,7 +1293,7 @@ SYSCALL_DEFINE2(mq_notify, mqd_t, mqdes,
} }
spin_unlock(&info->lock); spin_unlock(&info->lock);
out_fput: out_fput:
fput(filp); fput_light(filp, fput_needed);
out: out:
if (sock) { if (sock) {
netlink_detachskb(sock, nc); netlink_detachskb(sock, nc);
...@@ -1308,6 +1309,7 @@ SYSCALL_DEFINE3(mq_getsetattr, mqd_t, mqdes, ...@@ -1308,6 +1309,7 @@ SYSCALL_DEFINE3(mq_getsetattr, mqd_t, mqdes,
{ {
int ret; int ret;
struct mq_attr mqstat, omqstat; struct mq_attr mqstat, omqstat;
int fput_needed;
struct file *filp; struct file *filp;
struct inode *inode; struct inode *inode;
struct mqueue_inode_info *info; struct mqueue_inode_info *info;
...@@ -1319,7 +1321,7 @@ SYSCALL_DEFINE3(mq_getsetattr, mqd_t, mqdes, ...@@ -1319,7 +1321,7 @@ SYSCALL_DEFINE3(mq_getsetattr, mqd_t, mqdes,
return -EINVAL; return -EINVAL;
} }
filp = fget(mqdes); filp = fget_light(mqdes, &fput_needed);
if (!filp) { if (!filp) {
ret = -EBADF; ret = -EBADF;
goto out; goto out;
...@@ -1356,7 +1358,7 @@ SYSCALL_DEFINE3(mq_getsetattr, mqd_t, mqdes, ...@@ -1356,7 +1358,7 @@ SYSCALL_DEFINE3(mq_getsetattr, mqd_t, mqdes,
ret = -EFAULT; ret = -EFAULT;
out_fput: out_fput:
fput(filp); fput_light(filp, fput_needed);
out: out:
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment