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] [thread-next>] [day] [month] [year] [list]
Message-ID: <5cf64605-7005-ac06-6ee1-18547910697a@iogearbox.net>
Date:   Wed, 5 Jan 2022 14:01:41 +0100
From:   Daniel Borkmann <daniel@...earbox.net>
To:     menglong8.dong@...il.com, kuba@...nel.org
Cc:     davem@...emloft.net, yoshfuji@...ux-ipv6.org, dsahern@...nel.org,
        edumazet@...gle.com, ast@...nel.org, andrii@...nel.org,
        kafai@...com, songliubraving@...com, yhs@...com,
        john.fastabend@...il.com, kpsingh@...nel.org,
        netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
        bpf@...r.kernel.org, Menglong Dong <imagedong@...cent.com>
Subject: Re: [PATCH v2 net-next 1/2] net: bpf: handle return value of
 BPF_CGROUP_RUN_PROG_INET{4,6}_POST_BIND()

On 12/30/21 9:03 AM, menglong8.dong@...il.com wrote:
[...]
> diff --git a/include/net/sock.h b/include/net/sock.h
> index 44cc25f0bae7..f5fc0432374e 100644
> --- a/include/net/sock.h
> +++ b/include/net/sock.h
> @@ -1209,6 +1209,7 @@ struct proto {
>   	void			(*unhash)(struct sock *sk);
>   	void			(*rehash)(struct sock *sk);
>   	int			(*get_port)(struct sock *sk, unsigned short snum);
> +	void			(*put_port)(struct sock *sk);
>   #ifdef CONFIG_BPF_SYSCALL
>   	int			(*psock_update_sk_prot)(struct sock *sk,
>   							struct sk_psock *psock,
> diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
> index 5d18d32557d2..8784e72d4b8b 100644
> --- a/net/ipv4/af_inet.c
> +++ b/net/ipv4/af_inet.c
> @@ -531,6 +531,8 @@ int __inet_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len,
>   			err = BPF_CGROUP_RUN_PROG_INET4_POST_BIND(sk);
>   			if (err) {
>   				inet->inet_saddr = inet->inet_rcv_saddr = 0;
> +				if (sk->sk_prot->get_port)
> +					sk->sk_prot->put_port(sk);
>   				goto out_release_sock;
>   			}
>   		}
[...]
> diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
> index d1636425654e..ddfc6821e682 100644
> --- a/net/ipv6/af_inet6.c
> +++ b/net/ipv6/af_inet6.c
> @@ -413,6 +413,8 @@ static int __inet6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len,
>   			if (err) {
>   				sk->sk_ipv6only = saved_ipv6only;
>   				inet_reset_saddr(sk);
> +				if (sk->sk_prot->get_port)
> +					sk->sk_prot->put_port(sk);
>   				goto out;
>   			}
>   		}

I presume both tests above should test for non-zero sk->sk_prot->put_port
callback given that is what they end up calling when true, no?

Thanks,
Daniel

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ