lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Wed, 4 Jan 2017 23:45:30 +0000
From:   YUAN Linyu <Linyu.Yuan@...atel-sbell.com.cn>
To:     David Miller <davem@...emloft.net>,
        "cugyly@....com" <cugyly@....com>
CC:     "netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: RE: [PATCH] scm: remove use CMSG{_COMPAT}_ALIGN(sizeof(struct
 {compat_}cmsghdr))

Thanks

> -----Original Message-----
> From: David Miller [mailto:davem@...emloft.net]
> Sent: Thursday, January 05, 2017 2:25 AM
> To: cugyly@....com
> Cc: netdev@...r.kernel.org; YUAN Linyu
> Subject: Re: [PATCH] scm: remove use CMSG{_COMPAT}_ALIGN(sizeof(struct
> {compat_}cmsghdr))
> 
> From: yuan linyu <cugyly@....com>
> Date: Tue,  3 Jan 2017 20:42:17 +0800
> 
> > From: yuan linyu <Linyu.Yuan@...atel-sbell.com.cn>
> >
> > sizeof(struct cmsghdr) and sizeof(struct compat_cmsghdr) already aligned.
> > remove use CMSG_ALIGN(sizeof(struct cmsghdr)) and
> > CMSG_COMPAT_ALIGN(sizeof(struct compat_cmsghdr)) keep code
> consistent.
> >
> > Signed-off-by: yuan linyu <Linyu.Yuan@...atel-sbell.com.cn>
> 
> Applied, and I added the following commit which will make sure our
> analysis is accurate.
> 
> ====================
> [PATCH] net: Assert at build time the assumptions we make about the CMSG
> header.
> 
> It must always be the case that CMSG_ALIGN(sizeof(hdr)) == sizeof(hdr).
> 
> Otherwise there are missing adjustments in the various calculations
> that parse and build these things.
> 
> Signed-off-by: David S. Miller <davem@...emloft.net>
> ---
>  net/compat.c | 3 +++
>  net/socket.c | 2 ++
>  2 files changed, 5 insertions(+)
> 
> diff --git a/net/compat.c b/net/compat.c
> index 4e27dd1..ba3ac72 100644
> --- a/net/compat.c
> +++ b/net/compat.c
> @@ -130,6 +130,9 @@ int cmsghdr_from_user_compat_to_kern(struct
> msghdr *kmsg, struct sock *sk,
>  	__kernel_size_t kcmlen, tmp;
>  	int err = -EFAULT;
> 
> +	BUILD_BUG_ON(sizeof(struct compat_cmsghdr) !=
> +		     CMSG_COMPAT_ALIGN(sizeof(struct compat_cmsghdr)));
> +
>  	kcmlen = 0;
>  	kcmsg_base = kcmsg = (struct cmsghdr *)stackbuf;
>  	ucmsg = CMSG_COMPAT_FIRSTHDR(kmsg);
> diff --git a/net/socket.c b/net/socket.c
> index 8487bf1..5f3b5a2 100644
> --- a/net/socket.c
> +++ b/net/socket.c
> @@ -1948,6 +1948,8 @@ static int ___sys_sendmsg(struct socket *sock,
> struct user_msghdr __user *msg,
>  		ctl_buf = msg_sys->msg_control;
>  		ctl_len = msg_sys->msg_controllen;
>  	} else if (ctl_len) {
> +		BUILD_BUG_ON(sizeof(struct cmsghdr) !=
> +			     CMSG_ALIGN(sizeof(struct cmsghdr)));
>  		if (ctl_len > sizeof(ctl)) {
>  			ctl_buf = sock_kmalloc(sock->sk, ctl_len, GFP_KERNEL);
>  			if (ctl_buf == NULL)
> --
> 2.4.11

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ