lkml.org 
[lkml]   [2017]   [Mar]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v2] selinux: check for address length in selinux_socket_bind()
From
Date
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>


\
 
 \ /
  Last update: 2017-03-06 21:28    [W:0.532 / U:0.176 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site