diff mbox

[1/1] net: compat_sys_recvmmsg user timespec arg can be NULL

Message ID 1259689936-27570-1-git-send-email-acme@infradead.org
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Arnaldo Carvalho de Melo Dec. 1, 2009, 5:52 p.m. UTC
From: Jean-Mickael Guerin <jean-mickael.guerin@6wind.com>

We must test if user timespec is non-NULL before copying from userpace,
same as sys_recvmmsg().

Commiter note: changed it so that we have just one branch.

Signed-off-by: Jean-Mickael Guerin <jean-mickael.guerin@6wind.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 net/compat.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

Comments

David Miller Dec. 2, 2009, 9:23 a.m. UTC | #1
From: Arnaldo Carvalho de Melo <acme@infradead.org>
Date: Tue,  1 Dec 2009 15:52:16 -0200

> From: Jean-Mickael Guerin <jean-mickael.guerin@6wind.com>
> 
> We must test if user timespec is non-NULL before copying from userpace,
> same as sys_recvmmsg().
> 
> Commiter note: changed it so that we have just one branch.
> 
> Signed-off-by: Jean-Mickael Guerin <jean-mickael.guerin@6wind.com>
> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

Applied.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/compat.c b/net/compat.c
index 6a2f75f..e1a56ad 100644
--- a/net/compat.c
+++ b/net/compat.c
@@ -758,9 +758,13 @@  asmlinkage long compat_sys_recvmmsg(int fd, struct compat_mmsghdr __user *mmsg,
 {
 	int datagrams;
 	struct timespec ktspec;
-	struct compat_timespec __user *utspec =
-			(struct compat_timespec __user *)timeout;
+	struct compat_timespec __user *utspec;
 
+	if (timeout == NULL)
+		return __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen,
+				      flags | MSG_CMSG_COMPAT, NULL);
+
+	utspec = (struct compat_timespec __user *)timeout;
 	if (get_user(ktspec.tv_sec, &utspec->tv_sec) ||
 	    get_user(ktspec.tv_nsec, &utspec->tv_nsec))
 		return -EFAULT;