Skip to contentSkip to conversation

Problem with recent CMSG_COMPAT_OK fix

PATCH Applied Olaf Kirch 2 participants 2 messages Jan 4, 2005 – Jan 10, 2005

Subsystems (2)
lore
Share & tools
lore

Olaf Kirch

author
#0 lore raw

PATCH 1/1 Problem with recent CMSG_COMPAT_OK fix

Hi,

The recent fixes for cmsg_len handling seem to break 32bit compatibility at least on x86_64. The new CMSG_COMPAT_OK macro requires that cmsg_len is greater or equal the size of struct cmsghdr, which is the 64bit version of the struct. The code should really check against the size of struct compat_cmsghdr.

net/compat.c renamed from net/compat.c.orig +1 -1
@@ -125,7 +125,7 @@
 	 (struct compat_cmsghdr __user *)NULL)
 
 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
-	((ucmlen) >= sizeof(struct cmsghdr) && \
+	((ucmlen) >= sizeof(struct compat_cmsghdr) && \
 	 (ucmlen) <= (unsigned long) \
 	 ((mhdr)->msg_controllen - \
 	  ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
Signature · 3 lines
Olaf Kirch     | Things that make Monday morning interesting, #2:
[email protected]   |        "We have 8,000 NFS mount points, why do we keep
---------------+ 	 running out of privileged ports?"

From: Olaf Kirch <[email protected]>
Subject: Fix cmsg_len checks in 32bit compat mode
References: 49517 - LTC13227

The recent fixes for cmsg_len handling seem to break 32bit compatibility at least on x86_64. The new CMSG_COMPAT_OK macro requires that cmsg_len is greater or equal the size of struct cmsghdr, which is the 64bit version of the struct. The code should really check against the size of struct compat_cmsghdr.

net/compat.c renamed from net/compat.c.orig +1 -1
@@ -125,7 +125,7 @@
 	 (struct compat_cmsghdr __user *)NULL)
 
 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
-	((ucmlen) >= sizeof(struct cmsghdr) && \
+	((ucmlen) >= sizeof(struct compat_cmsghdr) && \
 	 (ucmlen) <= (unsigned long) \
 	 ((mhdr)->msg_controllen - \
 	  ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
maintainer Applied
#1 lore raw
Quoted 7 lines · On Tue, 4 Jan 2005 17:59:34 +0100 Olaf Kirch <[email protected]> wrote:

The recent fixes for cmsg_len handling seem to break 32bit compatibility at least on x86_64. The new CMSG_COMPAT_OK macro requires that cmsg_len is greater or equal the size of struct cmsghdr, which is the 64bit version of the struct. The code should really check against the size of struct compat_cmsghdr.

Applied, thanks Olaf.