Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1593701

Re: [PATCH v2] selinux: check for address length in selinux_socket_bind()

From Eric Dumazet <eric.dumazet@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCH v2] selinux: check for address length in selinux_socket_bind()
Date 2017-03-06 21:30 +0100
Message-ID <ti7qx-53n-11@gated-at.bofh.it> (permalink)
References <ti5RL-3Nc-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon, 2017-03-06 at 19:46 +0100, Alexander Potapenko wrote:
> KMSAN (KernelMemorySanitizer, a new error detection tool) reports use of
> uninitialized memory in selinux_socket_bind():
> 
...
> Signed-off-by: Alexander Potapenko <glider@google.com>
> ---
> Changes since v1:
>  - fixed patch description
>  - fixed addrlen tests to match those in inet_bind() and inet6_bind()
>    (per comment from Eric Dumazet)
> ---
>  security/selinux/hooks.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
> index 0a4b4b040e0a..ddc4aca6c840 100644
> --- a/security/selinux/hooks.c
> +++ b/security/selinux/hooks.c
> @@ -4351,10 +4351,19 @@ static int selinux_socket_bind(struct socket *sock, struct sockaddr *address, in
>  		u32 sid, node_perm;
>  
>  		if (family == PF_INET) {
> +			if (addrlen < sizeof(struct sockaddr_in)) {
> +				err = -EINVAL;
> +				goto out;
> +			}
>  			addr4 = (struct sockaddr_in *)address;
>  			snum = ntohs(addr4->sin_port);
>  			addrp = (char *)&addr4->sin_addr.s_addr;
> +
>  		} else {
> +			if (addrlen < SIN6_LEN_RFC2133) {
> +				err = -EINVAL;
> +				goto out;
> +			}
>  			addr6 = (struct sockaddr_in6 *)address;
>  			snum = ntohs(addr6->sin6_port);
>  			addrp = (char *)&addr6->sin6_addr.s6_addr;

Acked-by: Eric Dumazet <edumazet@google.com>

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2] selinux: check for address length in selinux_socket_bind() Alexander Potapenko <glider@google.com> - 2017-03-06 19:50 +0100
  Re: [PATCH v2] selinux: check for address length in  selinux_socket_bind() Eric Dumazet <eric.dumazet@gmail.com> - 2017-03-06 21:30 +0100
  Re: [PATCH v2] selinux: check for address length in  selinux_socket_bind() David Miller <davem@davemloft.net> - 2017-03-09 08:20 +0100
    Re: [PATCH v2] selinux: check for address length in selinux_socket_bind() Paul Moore <paul@paul-moore.com> - 2017-03-10 13:10 +0100
      Re: [PATCH v2] selinux: check for address length in selinux_socket_bind() Paul Moore <paul@paul-moore.com> - 2017-03-10 21:30 +0100

csiph-web