Commit 056fb9ae authored by David S. Miller's avatar David S. Miller

[ia64/ppc64/s390x/sparc64/x86_64]: Update for sock->ops->recvmsg AIO changes.

parent a16c20c7
...@@ -1763,7 +1763,6 @@ sys32_recvmsg (int fd, struct msghdr32 *msg, unsigned int flags) ...@@ -1763,7 +1763,6 @@ sys32_recvmsg (int fd, struct msghdr32 *msg, unsigned int flags)
struct msghdr msg_sys; struct msghdr msg_sys;
unsigned long cmsg_ptr; unsigned long cmsg_ptr;
int err, iov_size, total_len, len; int err, iov_size, total_len, len;
struct scm_cookie scm;
/* kernel mode address */ /* kernel mode address */
char addr[MAX_SOCK_ADDR]; char addr[MAX_SOCK_ADDR];
...@@ -1811,20 +1810,35 @@ sys32_recvmsg (int fd, struct msghdr32 *msg, unsigned int flags) ...@@ -1811,20 +1810,35 @@ sys32_recvmsg (int fd, struct msghdr32 *msg, unsigned int flags)
if (sock->file->f_flags & O_NONBLOCK) if (sock->file->f_flags & O_NONBLOCK)
flags |= MSG_DONTWAIT; flags |= MSG_DONTWAIT;
memset(&scm, 0, sizeof(scm)); /* XXX This code needs massive updating... -DaveM */
lock_kernel(); lock_kernel();
{ {
err = sock->ops->recvmsg(sock, &msg_sys, total_len, flags, &scm); struct sock_iocb *si;
struct kiocb iocb;
init_sync_kiocb(&iocb, NULL);
si = kiocb_to_siocb(&iocb);
si->sock = sock;
si->scm = &si->async_scm;
si->msg = &msg_sys;
si->size = total_len;
si->flags = flags;
memset(si->scm, 0, sizeof(*si->scm));
err = sock->ops->recvmsg(&iocb, sock, &msg_sys, total_len,
flags, si->scm);
if (-EIOCBQUEUED == err)
err = wait_on_sync_kiocb(&iocb);
if (err < 0) if (err < 0)
goto out_unlock_freeiov; goto out_unlock_freeiov;
len = err; len = err;
if (!msg_sys.msg_control) { if (!msg_sys.msg_control) {
if (sock->passcred || scm.fp) if (sock->passcred || si->scm->fp)
msg_sys.msg_flags |= MSG_CTRUNC; msg_sys.msg_flags |= MSG_CTRUNC;
if (scm.fp) if (si->scm->fp)
__scm_destroy(&scm); __scm_destroy(si->scm);
} else { } else {
/* /*
* If recvmsg processing itself placed some control messages into * If recvmsg processing itself placed some control messages into
...@@ -1837,9 +1851,10 @@ sys32_recvmsg (int fd, struct msghdr32 *msg, unsigned int flags) ...@@ -1837,9 +1851,10 @@ sys32_recvmsg (int fd, struct msghdr32 *msg, unsigned int flags)
/* Wheee... */ /* Wheee... */
if (sock->passcred) if (sock->passcred)
put_cmsg32(&msg_sys, SOL_SOCKET, SCM_CREDENTIALS, put_cmsg32(&msg_sys, SOL_SOCKET, SCM_CREDENTIALS,
sizeof(scm.creds), &scm.creds); sizeof(si->scm->creds),
if (scm.fp != NULL) &si->scm->creds);
scm_detach_fds32(&msg_sys, &scm); if (si->scm->fp != NULL)
scm_detach_fds32(&msg_sys, si->scm);
} }
} }
unlock_kernel(); unlock_kernel();
......
...@@ -3320,20 +3320,33 @@ asmlinkage long sys32_recvmsg(int fd, struct msghdr32* user_msg, unsigned int us ...@@ -3320,20 +3320,33 @@ asmlinkage long sys32_recvmsg(int fd, struct msghdr32* user_msg, unsigned int us
sock = sockfd_lookup(fd, &err); sock = sockfd_lookup(fd, &err);
if (sock != NULL) { if (sock != NULL) {
struct scm_cookie scm; struct sock_iocb *si;
struct kiocb iocb;
if (sock->file->f_flags & O_NONBLOCK) if (sock->file->f_flags & O_NONBLOCK)
user_flags |= MSG_DONTWAIT; user_flags |= MSG_DONTWAIT;
memset(&scm, 0, sizeof(scm));
err = sock->ops->recvmsg(sock, &kern_msg, total_len, init_sync_kiocb(&iocb, NULL);
user_flags, &scm); si = kiocb_to_siocb(&iocb);
si->sock = sock;
si->scm = &si->async_scm;
si->msg = &kern_msg;
si->size = total_len;
si->flags = user_flags;
memset(si->scm, 0, sizeof(*si->scm));
err = sock->ops->recvmsg(&iocb, sock, &kern_msg, total_len,
user_flags, si->scm);
if (-EIOCBQUEUED == err)
err = wait_on_sync_kiocb(&iocb);
if(err >= 0) { if(err >= 0) {
len = err; len = err;
if(!kern_msg.msg_control) { if(!kern_msg.msg_control) {
if(sock->passcred || scm.fp) if(sock->passcred || si->scm->fp)
kern_msg.msg_flags |= MSG_CTRUNC; kern_msg.msg_flags |= MSG_CTRUNC;
if(scm.fp) if(si->scm->fp)
__scm_destroy(&scm); __scm_destroy(si->scm);
} else { } else {
/* If recvmsg processing itself placed some /* If recvmsg processing itself placed some
* control messages into user space, it's is * control messages into user space, it's is
...@@ -3347,9 +3360,10 @@ asmlinkage long sys32_recvmsg(int fd, struct msghdr32* user_msg, unsigned int us ...@@ -3347,9 +3360,10 @@ asmlinkage long sys32_recvmsg(int fd, struct msghdr32* user_msg, unsigned int us
if(sock->passcred) if(sock->passcred)
put_cmsg32(&kern_msg, put_cmsg32(&kern_msg,
SOL_SOCKET, SCM_CREDENTIALS, SOL_SOCKET, SCM_CREDENTIALS,
sizeof(scm.creds), &scm.creds); sizeof(si->scm->creds),
if(scm.fp != NULL) &si->scm->creds);
scm_detach_fds32(&kern_msg, &scm); if(si->scm->fp != NULL)
scm_detach_fds32(&kern_msg, si->scm);
} }
} }
sockfd_put(sock); sockfd_put(sock);
......
...@@ -2596,20 +2596,33 @@ asmlinkage int sys32_recvmsg(int fd, struct msghdr32 *user_msg, unsigned int use ...@@ -2596,20 +2596,33 @@ asmlinkage int sys32_recvmsg(int fd, struct msghdr32 *user_msg, unsigned int use
sock = sockfd_lookup(fd, &err); sock = sockfd_lookup(fd, &err);
if (sock != NULL) { if (sock != NULL) {
struct scm_cookie scm; struct sock_iocb *si;
struct kiocb iocb;
if (sock->file->f_flags & O_NONBLOCK) if (sock->file->f_flags & O_NONBLOCK)
user_flags |= MSG_DONTWAIT; user_flags |= MSG_DONTWAIT;
memset(&scm, 0, sizeof(scm));
err = sock->ops->recvmsg(sock, &kern_msg, total_len, init_sync_kiocb(&iocb, NULL);
user_flags, &scm); si = kiocb_to_siocb(&iocb);
si->sock = sock;
si->scm = &si->async_scm;
si->msg = &kern_msg;
si->size = total_len;
si->flags = user_flags;
memset(si->scm, 0, sizeof(*si->scm));
err = sock->ops->recvmsg(&iocb, sock, &kern_msg, total_len,
user_flags, si->scm);
if (-EIOCBQUEUED == err)
err = wait_on_sync_kiocb(&iocb);
if(err >= 0) { if(err >= 0) {
len = err; len = err;
if(!kern_msg.msg_control) { if(!kern_msg.msg_control) {
if(sock->passcred || scm.fp) if(sock->passcred || si->scm->fp)
kern_msg.msg_flags |= MSG_CTRUNC; kern_msg.msg_flags |= MSG_CTRUNC;
if(scm.fp) if(si->scm->fp)
__scm_destroy(&scm); __scm_destroy(si->scm);
} else { } else {
/* If recvmsg processing itself placed some /* If recvmsg processing itself placed some
* control messages into user space, it's is * control messages into user space, it's is
...@@ -2623,9 +2636,10 @@ asmlinkage int sys32_recvmsg(int fd, struct msghdr32 *user_msg, unsigned int use ...@@ -2623,9 +2636,10 @@ asmlinkage int sys32_recvmsg(int fd, struct msghdr32 *user_msg, unsigned int use
if(sock->passcred) if(sock->passcred)
put_cmsg32(&kern_msg, put_cmsg32(&kern_msg,
SOL_SOCKET, SCM_CREDENTIALS, SOL_SOCKET, SCM_CREDENTIALS,
sizeof(scm.creds), &scm.creds); sizeof(si->scm->creds),
if(scm.fp != NULL) &si->scm->creds);
scm_detach_fds32(&kern_msg, &scm); if(si->scm->fp != NULL)
scm_detach_fds32(&kern_msg, si->scm);
} }
} }
sockfd_put(sock); sockfd_put(sock);
...@@ -2746,6 +2760,8 @@ sys32_recvmsg (int fd, struct msghdr32 *msg, unsigned int flags) ...@@ -2746,6 +2760,8 @@ sys32_recvmsg (int fd, struct msghdr32 *msg, unsigned int flags)
struct msghdr msg_sys; struct msghdr msg_sys;
unsigned long cmsg_ptr; unsigned long cmsg_ptr;
int err, iov_size, total_len, len; int err, iov_size, total_len, len;
struct sock_iocb *si;
struct kiocb iocb;
/* kernel mode address */ /* kernel mode address */
char addr[MAX_SOCK_ADDR]; char addr[MAX_SOCK_ADDR];
...@@ -2753,7 +2769,6 @@ sys32_recvmsg (int fd, struct msghdr32 *msg, unsigned int flags) ...@@ -2753,7 +2769,6 @@ sys32_recvmsg (int fd, struct msghdr32 *msg, unsigned int flags)
/* user mode address pointers */ /* user mode address pointers */
struct sockaddr *uaddr; struct sockaddr *uaddr;
int *uaddr_len; int *uaddr_len;
struct scm_cookie scm;
err=-EFAULT; err=-EFAULT;
if (msghdr_from_user32_to_kern(&msg_sys, msg)) if (msghdr_from_user32_to_kern(&msg_sys, msg))
...@@ -2793,9 +2808,20 @@ sys32_recvmsg (int fd, struct msghdr32 *msg, unsigned int flags) ...@@ -2793,9 +2808,20 @@ sys32_recvmsg (int fd, struct msghdr32 *msg, unsigned int flags)
if (sock->file->f_flags & O_NONBLOCK) if (sock->file->f_flags & O_NONBLOCK)
flags |= MSG_DONTWAIT; flags |= MSG_DONTWAIT;
memset(&scm, 0, sizeof(scm));
err = sock->ops->recvmsg(sock, &msg_sys, total_len, init_sync_kiocb(&iocb, NULL);
flags, &scm); si = kiocb_to_siocb(&iocb);
si->sock = sock;
si->scm = &si->async_scm;
si->msg = &msg_sys;
si->size = total_len;
si->flags = flags;
memset(si->scm, 0, sizeof(*si->scm));
err = sock->ops->recvmsg(&iocb, sock, &msg_sys, total_len,
flags, si->scm);
if (-EIOCBQUEUED == err)
err = wait_on_sync_kiocb(&iocb);
if (err < 0) if (err < 0)
goto out_freeiov; goto out_freeiov;
len = err; len = err;
...@@ -2808,10 +2834,10 @@ sys32_recvmsg (int fd, struct msghdr32 *msg, unsigned int flags) ...@@ -2808,10 +2834,10 @@ sys32_recvmsg (int fd, struct msghdr32 *msg, unsigned int flags)
goto out_freeiov; goto out_freeiov;
} }
if(!msg_sys.msg_control) { if(!msg_sys.msg_control) {
if(sock->passcred || scm.fp) if(sock->passcred || si->scm->fp)
msg_sys.msg_flags |= MSG_CTRUNC; msg_sys.msg_flags |= MSG_CTRUNC;
if(scm.fp) if(si->scm->fp)
__scm_destroy(&scm); __scm_destroy(si->scm);
} else { } else {
/* If recvmsg processing itself placed some /* If recvmsg processing itself placed some
* control messages into user space, it's is * control messages into user space, it's is
...@@ -2824,9 +2850,9 @@ sys32_recvmsg (int fd, struct msghdr32 *msg, unsigned int flags) ...@@ -2824,9 +2850,9 @@ sys32_recvmsg (int fd, struct msghdr32 *msg, unsigned int flags)
if(sock->passcred) if(sock->passcred)
put_cmsg32(&msg_sys, put_cmsg32(&msg_sys,
SOL_SOCKET, SCM_CREDENTIALS, SOL_SOCKET, SCM_CREDENTIALS,
sizeof(scm.creds), &scm.creds); sizeof(si->scm->creds), &si->scm->creds);
if(scm.fp != NULL) if(si->scm->fp != NULL)
scm_detach_fds32(&msg_sys, &scm); scm_detach_fds32(&msg_sys, si->scm);
} }
out_freeiov: out_freeiov:
......
...@@ -2599,20 +2599,33 @@ asmlinkage int sys32_recvmsg(int fd, struct msghdr32 *user_msg, unsigned int use ...@@ -2599,20 +2599,33 @@ asmlinkage int sys32_recvmsg(int fd, struct msghdr32 *user_msg, unsigned int use
sock = sockfd_lookup(fd, &err); sock = sockfd_lookup(fd, &err);
if (sock != NULL) { if (sock != NULL) {
struct scm_cookie scm; struct sock_iocb *si;
struct kiocb iocb;
if (sock->file->f_flags & O_NONBLOCK) if (sock->file->f_flags & O_NONBLOCK)
user_flags |= MSG_DONTWAIT; user_flags |= MSG_DONTWAIT;
memset(&scm, 0, sizeof(scm));
err = sock->ops->recvmsg(sock, &kern_msg, total_len, init_sync_kiocb(&iocb, NULL);
user_flags, &scm); si = kiocb_to_siocb(&iocb);
si->sock = sock;
si->scm = &si->async_scm;
si->msg = &kern_msg;
si->size = total_len;
si->flags = user_flags;
memset(si->scm, 0, sizeof(*si->scm));
err = sock->ops->recvmsg(&iocb, sock, &kern_msg, total_len,
user_flags, si->scm);
if (-EIOCBQUEUED == err)
err = wait_on_sync_kiocb(&iocb);
if(err >= 0) { if(err >= 0) {
len = err; len = err;
if(!kern_msg.msg_control) { if(!kern_msg.msg_control) {
if(sock->passcred || scm.fp) if(sock->passcred || si->scm->fp)
kern_msg.msg_flags |= MSG_CTRUNC; kern_msg.msg_flags |= MSG_CTRUNC;
if(scm.fp) if(si->scm->fp)
__scm_destroy(&scm); __scm_destroy(si->scm);
} else { } else {
/* If recvmsg processing itself placed some /* If recvmsg processing itself placed some
* control messages into user space, it's is * control messages into user space, it's is
...@@ -2626,9 +2639,10 @@ asmlinkage int sys32_recvmsg(int fd, struct msghdr32 *user_msg, unsigned int use ...@@ -2626,9 +2639,10 @@ asmlinkage int sys32_recvmsg(int fd, struct msghdr32 *user_msg, unsigned int use
if(sock->passcred) if(sock->passcred)
put_cmsg32(&kern_msg, put_cmsg32(&kern_msg,
SOL_SOCKET, SCM_CREDENTIALS, SOL_SOCKET, SCM_CREDENTIALS,
sizeof(scm.creds), &scm.creds); sizeof(si->scm->creds),
if(scm.fp != NULL) &si->scm->creds);
scm_detach_fds32(&kern_msg, &scm); if(si->scm->fp != NULL)
scm_detach_fds32(&kern_msg, si->scm);
} }
} }
sockfd_put(sock); sockfd_put(sock);
......
...@@ -436,20 +436,33 @@ asmlinkage int sys32_recvmsg(int fd, struct msghdr32 *user_msg, unsigned int use ...@@ -436,20 +436,33 @@ asmlinkage int sys32_recvmsg(int fd, struct msghdr32 *user_msg, unsigned int use
sock = sockfd_lookup(fd, &err); sock = sockfd_lookup(fd, &err);
if (sock != NULL) { if (sock != NULL) {
struct scm_cookie scm; struct sock_iocb *si;
struct kiocb iocb;
if (sock->file->f_flags & O_NONBLOCK) if (sock->file->f_flags & O_NONBLOCK)
user_flags |= MSG_DONTWAIT; user_flags |= MSG_DONTWAIT;
memset(&scm, 0, sizeof(scm));
err = sock->ops->recvmsg(sock, &kern_msg, total_len, init_sync_kiocb(&iocb, NULL);
user_flags, &scm); si = kiocb_to_siocb(&iocb);
si->sock = sock;
si->scm = &si->async_scm;
si->msg = &kern_msg;
si->size = total_len;
si->flags = user_flags;
memset(si->scm, 0, sizeof(*si->scm));
err = sock->ops->recvmsg(&iocb, sock, &kern_msg, total_len,
user_flags, si->scm);
if (-EIOCBQUEUED == err)
err = wait_on_sync_kiocb(&iocb);
if(err >= 0) { if(err >= 0) {
len = err; len = err;
if(!kern_msg.msg_control) { if(!kern_msg.msg_control) {
if(sock->passcred || scm.fp) if(sock->passcred || si->scm->fp)
kern_msg.msg_flags |= MSG_CTRUNC; kern_msg.msg_flags |= MSG_CTRUNC;
if(scm.fp) if(si->scm->fp)
__scm_destroy(&scm); __scm_destroy(si->scm);
} else { } else {
/* If recvmsg processing itself placed some /* If recvmsg processing itself placed some
* control messages into user space, it's is * control messages into user space, it's is
...@@ -463,9 +476,10 @@ asmlinkage int sys32_recvmsg(int fd, struct msghdr32 *user_msg, unsigned int use ...@@ -463,9 +476,10 @@ asmlinkage int sys32_recvmsg(int fd, struct msghdr32 *user_msg, unsigned int use
if(sock->passcred) if(sock->passcred)
put_cmsg32(&kern_msg, put_cmsg32(&kern_msg,
SOL_SOCKET, SCM_CREDENTIALS, SOL_SOCKET, SCM_CREDENTIALS,
sizeof(scm.creds), &scm.creds); sizeof(si->scm->creds),
if(scm.fp != NULL) &si->scm->creds);
scm_detach_fds32(&kern_msg, &scm); if(si->scm->fp != NULL)
scm_detach_fds32(&kern_msg, si->scm);
} }
} }
sockfd_put(sock); sockfd_put(sock);
......
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