Skip to contentSkip to conversation

net: core: scm: fix information leak to userland

PATCH In review Vasiliy Kulikov 3 participants 4 messages Oct 30, 2010

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: core: scm: fix information leak to userland

Structure cmsghdr is copied to userland with padding bytes unitialized on architectures where __kernel_size_t is unsigned long. It leads to leaking of contents of kernel stack memory.

---
Compile tested.

 net/core/scm.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
net/core/scm.c +1 -0
index 413cab8..a4a9b70 100644
@@ -233,6 +233,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
 		msg->msg_flags |= MSG_CTRUNC;
 		cmlen = msg->msg_controllen;
 	}
+	memset(&cmhdr, 0, sizeof(cmhdr));
 	cmhdr.cmsg_level = level;
 	cmhdr.cmsg_type = type;
 	cmhdr.cmsg_len = cmlen;
Signature · 1 line
1.7.0.4
#1 lore raw
Quoted 16 lines · Vasiliy Kulikov

Structure cmsghdr is copied to userland with padding bytes unitialized on architectures where __kernel_size_t is unsigned long. It leads to leaking of contents of kernel stack memory.

---
Compile tested.

 net/core/scm.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
net/core/scm.c +0 -0
index 413cab8..a4a9b70 100644

net/core/scm.c int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data) · line 239

Quoted 7 lines
net/core/scm.c +1 -0
@@ -233,6 +233,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
 		msg->msg_flags |= MSG_CTRUNC;
 		cmlen = msg->msg_controllen;
 	}
+	memset(&cmhdr, 0, sizeof(cmhdr));
 	cmhdr.cmsg_level = level;
 	cmhdr.cmsg_type = type;
 	cmhdr.cmsg_len = cmlen;

???

struct cmsghdr {

        __kernel_size_t cmsg_len;       /* data byte count, including hdr */
        int             cmsg_level;     /* originating protocol */
        int             cmsg_type;      /* protocol-specific type */

};

Could you explain where are the padding bytes ?

#2 lore raw
Quoted 28 lines · Eric Dumazet
Quoted 16 lines · Vasiliy Kulikov

Structure cmsghdr is copied to userland with padding bytes unitialized on architectures where __kernel_size_t is unsigned long. It leads to leaking of contents of kernel stack memory.

---
Compile tested.

 net/core/scm.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
net/core/scm.c +0 -0
index 413cab8..a4a9b70 100644

net/core/scm.c int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data) · line 239

Quoted 7 lines
net/core/scm.c +1 -0
@@ -233,6 +233,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
 		msg->msg_flags |= MSG_CTRUNC;
 		cmlen = msg->msg_controllen;
 	}
+	memset(&cmhdr, 0, sizeof(cmhdr));
 	cmhdr.cmsg_level = level;
 	cmhdr.cmsg_type = type;
 	cmhdr.cmsg_len = cmlen;

???

Quoted 7 lines

struct cmsghdr {

        __kernel_size_t cmsg_len;       /* data byte count, including hdr */
        int             cmsg_level;     /* originating protocol */
        int             cmsg_type;      /* protocol-specific type */

};

Could you explain where are the padding bytes ?

Ah, sorry, nowhere :) int is stored quite OK after long. Please ignore this patch.

Thanks,

Signature · 5 lines
Vasiliy
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
maintainer
#3 lore raw
In reply to Vasiliy Kulikov

Your patches are almost entirely baseless.

You haven't even made an effort to show a real case, in detail, where your patches actually fix a bug. The CMSG case shows that you didn't even bother to look at the assembly of even one architecture to see if padding bytes even existed in the structure, and that furthermore even if they existed that they would leak out ever.

I don't even buy the "preventative nature" argument for the address[128] thing. If a protocol is leaking kernel memory in that case, it also isn't filling in the address value properly, which is a bug times two.

I absolutely am not applying these patches, sorry.