From: David Miller <davem@davemloft.net>
To: zenczykowski@gmail.com
Cc: maze@google.com, netdev@vger.kernel.org, edumazet@google.com
Subject: Re: [PATCH] net: port < inet_prot_sock(net) --> inet_port_requires_bind_service(net, port)
Date: Mon, 25 Nov 2019 14:45:22 -0800 (PST) [thread overview]
Message-ID: <20191125.144522.2288594830565793222.davem@davemloft.net> (raw)
In-Reply-To: <20191124092715.252532-1-zenczykowski@gmail.com>
From: Maciej Żenczykowski <zenczykowski@gmail.com>
Date: Sun, 24 Nov 2019 01:27:15 -0800
> -static inline int inet_prot_sock(struct net *net)
> +static inline bool inet_port_requires_bind_service(struct net *net, int port)
"int port"
> -static inline int inet_prot_sock(struct net *net)
> +static inline bool inet_port_requires_bind_service(struct net *net, int port)
"int port"
> @@ -495,7 +495,7 @@ int __inet_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len,
>
> snum = ntohs(addr->sin_port);
> err = -EACCES;
> - if (snum && snum < inet_prot_sock(net) &&
> + if (snum && inet_port_requires_bind_service(net, snum) &&
"unsigned short snum"
> @@ -292,7 +292,7 @@ static int __inet6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len,
> return -EINVAL;
>
> snum = ntohs(addr->sin6_port);
> - if (snum && snum < inet_prot_sock(net) &&
> + if (snum && inet_port_requires_bind_service(net, snum) &&
"unsigned short snum"
> diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
> index 3be7398901e0..8d14a1acbc37 100644
> --- a/net/netfilter/ipvs/ip_vs_ctl.c
> +++ b/net/netfilter/ipvs/ip_vs_ctl.c
> @@ -423,7 +423,7 @@ ip_vs_service_find(struct netns_ipvs *ipvs, int af, __u32 fwmark, __u16 protocol
>
> if (!svc && protocol == IPPROTO_TCP &&
> atomic_read(&ipvs->ftpsvc_counter) &&
> - (vport == FTPDATA || ntohs(vport) >= inet_prot_sock(ipvs->net))) {
> + (vport == FTPDATA || !inet_port_requires_bind_service(ipvs->net, ntohs(vport)))) {
ntohs(__be16 vport)
> @@ -384,7 +384,7 @@ static int sctp_do_bind(struct sock *sk, union sctp_addr *addr, int len)
> }
> }
>
> - if (snum && snum < inet_prot_sock(net) &&
> + if (snum && inet_port_requires_bind_service(net, snum) &&
"unsigned short snum"
And so on and so forth.
Please make the types in the helper(s) match actual usage, thank you.
next prev parent reply other threads:[~2019-11-25 22:45 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-22 7:21 [PATCH 1/3] net: inet_is_local_reserved_port() should return bool not int Maciej Żenczykowski
2019-11-22 7:21 ` [PATCH 2/3] net: port < inet_prot_sock(net) --> inet_port_requires_bind_service(net, port) Maciej Żenczykowski
2019-11-22 7:21 ` [PATCH 3/3] net: Fail explicit unprivileged bind to local reserved ports Maciej Żenczykowski
2019-11-22 18:06 ` [PATCH 1/3] net: inet_is_local_reserved_port() should return bool not int David Miller
2019-11-22 21:48 ` Maciej Żenczykowski
2019-11-22 21:50 ` [PATCH] " Maciej Żenczykowski
2019-11-23 0:55 ` Jakub Kicinski
2019-11-23 3:31 ` Maciej Żenczykowski
2019-11-24 9:24 ` [PATCH 1/3] " Maciej Żenczykowski
2019-11-24 9:27 ` [PATCH] net: port < inet_prot_sock(net) --> inet_port_requires_bind_service(net, port) Maciej Żenczykowski
2019-11-25 22:45 ` David Miller [this message]
2019-11-25 23:32 ` Maciej Żenczykowski
2019-11-25 23:37 ` [PATCH v2] " Maciej Żenczykowski
2019-11-26 21:20 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191125.144522.2288594830565793222.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=maze@google.com \
--cc=netdev@vger.kernel.org \
--cc=zenczykowski@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).