* [PATCH net] bareudp: Disallow udp port 0.
@ 2020-07-30 17:03 Martin Varghese
2020-07-30 23:20 ` Jakub Kicinski
0 siblings, 1 reply; 3+ messages in thread
From: Martin Varghese @ 2020-07-30 17:03 UTC (permalink / raw)
To: netdev, davem, kuba, jbenc, gnault; +Cc: Martin Varghese
From: Martin Varghese <martin.varghese@nokia.com>
Kernel does not support udp destination port 0 on wire. Hence
bareudp device with udp destination port 0 must be disallowed.
Fixes: 571912c69f0e ("net: UDP tunnel encapsulation module for tunnelling different protocols like MPLS, IP, NSH etc.")
Signed-off-by: Martin Varghese <martin.varghese@nokia.com>
---
drivers/net/bareudp.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/net/bareudp.c b/drivers/net/bareudp.c
index 88e7900853db..08b195d32cbe 100644
--- a/drivers/net/bareudp.c
+++ b/drivers/net/bareudp.c
@@ -578,8 +578,13 @@ static int bareudp2info(struct nlattr *data[], struct bareudp_conf *conf,
return -EINVAL;
}
- if (data[IFLA_BAREUDP_PORT])
+ if (data[IFLA_BAREUDP_PORT]) {
conf->port = nla_get_u16(data[IFLA_BAREUDP_PORT]);
+ if (!conf->port) {
+ NL_SET_ERR_MSG(extack, "udp port 0 not supported");
+ return -EINVAL;
+ }
+ }
if (data[IFLA_BAREUDP_ETHERTYPE])
conf->ethertype = nla_get_u16(data[IFLA_BAREUDP_ETHERTYPE]);
--
2.18.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net] bareudp: Disallow udp port 0.
2020-07-30 17:03 [PATCH net] bareudp: Disallow udp port 0 Martin Varghese
@ 2020-07-30 23:20 ` Jakub Kicinski
2020-07-31 2:50 ` Martin Varghese
0 siblings, 1 reply; 3+ messages in thread
From: Jakub Kicinski @ 2020-07-30 23:20 UTC (permalink / raw)
To: Martin Varghese; +Cc: netdev, davem, jbenc, gnault, Martin Varghese
On Thu, 30 Jul 2020 22:33:51 +0530 Martin Varghese wrote:
> From: Martin Varghese <martin.varghese@nokia.com>
>
> Kernel does not support udp destination port 0 on wire. Hence
> bareudp device with udp destination port 0 must be disallowed.
>
> Fixes: 571912c69f0e ("net: UDP tunnel encapsulation module for tunnelling different protocols like MPLS, IP, NSH etc.")
> Signed-off-by: Martin Varghese <martin.varghese@nokia.com>
> ---
> drivers/net/bareudp.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/bareudp.c b/drivers/net/bareudp.c
> index 88e7900853db..08b195d32cbe 100644
> --- a/drivers/net/bareudp.c
> +++ b/drivers/net/bareudp.c
> @@ -578,8 +578,13 @@ static int bareudp2info(struct nlattr *data[], struct bareudp_conf *conf,
> return -EINVAL;
> }
>
> - if (data[IFLA_BAREUDP_PORT])
> + if (data[IFLA_BAREUDP_PORT]) {
> conf->port = nla_get_u16(data[IFLA_BAREUDP_PORT]);
> + if (!conf->port) {
> + NL_SET_ERR_MSG(extack, "udp port 0 not supported");
> + return -EINVAL;
> + }
> + }
Please use one of the NLA_POLICY_**-ies, probably NLA_POLICY_MIN() ?
That's better for documenting, exporting for user space, and will also
point the user space to the attribute in exack automatically.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] bareudp: Disallow udp port 0.
2020-07-30 23:20 ` Jakub Kicinski
@ 2020-07-31 2:50 ` Martin Varghese
0 siblings, 0 replies; 3+ messages in thread
From: Martin Varghese @ 2020-07-31 2:50 UTC (permalink / raw)
To: Jakub Kicinski; +Cc: netdev, davem, jbenc, gnault, Martin Varghese
On Thu, Jul 30, 2020 at 04:20:30PM -0700, Jakub Kicinski wrote:
> On Thu, 30 Jul 2020 22:33:51 +0530 Martin Varghese wrote:
> > From: Martin Varghese <martin.varghese@nokia.com>
> >
> > Kernel does not support udp destination port 0 on wire. Hence
> > bareudp device with udp destination port 0 must be disallowed.
> >
> > Fixes: 571912c69f0e ("net: UDP tunnel encapsulation module for tunnelling different protocols like MPLS, IP, NSH etc.")
> > Signed-off-by: Martin Varghese <martin.varghese@nokia.com>
> > ---
> > drivers/net/bareudp.c | 7 ++++++-
> > 1 file changed, 6 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/bareudp.c b/drivers/net/bareudp.c
> > index 88e7900853db..08b195d32cbe 100644
> > --- a/drivers/net/bareudp.c
> > +++ b/drivers/net/bareudp.c
> > @@ -578,8 +578,13 @@ static int bareudp2info(struct nlattr *data[], struct bareudp_conf *conf,
> > return -EINVAL;
> > }
> >
> > - if (data[IFLA_BAREUDP_PORT])
> > + if (data[IFLA_BAREUDP_PORT]) {
> > conf->port = nla_get_u16(data[IFLA_BAREUDP_PORT]);
> > + if (!conf->port) {
> > + NL_SET_ERR_MSG(extack, "udp port 0 not supported");
> > + return -EINVAL;
> > + }
> > + }
>
> Please use one of the NLA_POLICY_**-ies, probably NLA_POLICY_MIN() ?
> That's better for documenting, exporting for user space, and will also
> point the user space to the attribute in exack automatically.
Ok, I will check how to do this way. Thanks for the feedback.
Regards,
Martin
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-07-31 2:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-30 17:03 [PATCH net] bareudp: Disallow udp port 0 Martin Varghese
2020-07-30 23:20 ` Jakub Kicinski
2020-07-31 2:50 ` Martin Varghese
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).