Thread (4 messages) 4 messages, 3 authors, 2010-10-30

Re: [PATCH] net: core: scm: fix information leak to userland

From: Vasiliy Kulikov <hidden>
Date: 2010-10-30 14:50:51
Also in: kernel-janitors, lkml

On Sat, Oct 30, 2010 at 16:33 +0200, Eric Dumazet wrote:
Le samedi 30 octobre 2010 à 18:26 +0400, Vasiliy Kulikov a écrit :
quoted
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.

Signed-off-by: Vasiliy Kulikov <redacted>
---
 Compile tested.

 net/core/scm.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/net/core/scm.c b/net/core/scm.c
index 413cab8..a4a9b70 100644
--- a/net/core/scm.c
+++ b/net/core/scm.c
@@ -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 ?
Ah, sorry, nowhere :)  int is stored quite OK after long.  Please ignore this patch.

Thanks,

-- 
Vasiliy
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help