Commit d7256d0e authored by Jean-Mickael Guerin's avatar Jean-Mickael Guerin Committed by David S. Miller

net: compat_mmsghdr must be used in sys_recvmmsg

Both to traverse the entries and to set the msg_len field.

Commiter note: folded two patches and avoided one branch repeating the
compat test.
Signed-off-by: default avatarJean-Mickael Guerin <jean-mickael.guerin@6wind.com>
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 810c0719
...@@ -2144,6 +2144,7 @@ int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen, ...@@ -2144,6 +2144,7 @@ int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,
int fput_needed, err, datagrams; int fput_needed, err, datagrams;
struct socket *sock; struct socket *sock;
struct mmsghdr __user *entry; struct mmsghdr __user *entry;
struct compat_mmsghdr __user *compat_entry;
struct msghdr msg_sys; struct msghdr msg_sys;
struct timespec end_time; struct timespec end_time;
...@@ -2163,19 +2164,30 @@ int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen, ...@@ -2163,19 +2164,30 @@ int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,
goto out_put; goto out_put;
entry = mmsg; entry = mmsg;
compat_entry = (struct compat_mmsghdr __user *)mmsg;
while (datagrams < vlen) { while (datagrams < vlen) {
/* /*
* No need to ask LSM for more than the first datagram. * No need to ask LSM for more than the first datagram.
*/ */
err = __sys_recvmsg(sock, (struct msghdr __user *)entry, if (MSG_CMSG_COMPAT & flags) {
&msg_sys, flags, datagrams); err = __sys_recvmsg(sock, (struct msghdr __user *)compat_entry,
if (err < 0) &msg_sys, flags, datagrams);
break; if (err < 0)
err = put_user(err, &entry->msg_len); break;
err = __put_user(err, &compat_entry->msg_len);
++compat_entry;
} else {
err = __sys_recvmsg(sock, (struct msghdr __user *)entry,
&msg_sys, flags, datagrams);
if (err < 0)
break;
err = put_user(err, &entry->msg_len);
++entry;
}
if (err) if (err)
break; break;
++entry;
++datagrams; ++datagrams;
if (timeout) { if (timeout) {
......
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