* [PATCH net 0/4] udp: a few fixes
@ 2019-02-21 16:43 Paolo Abeni
2019-02-21 16:43 ` [PATCH net 1/4] udpv6: add the required annotation to mib type Paolo Abeni
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Paolo Abeni @ 2019-02-21 16:43 UTC (permalink / raw)
To: netdev; +Cc: David S. Miller, Stefano Brivio
This series includes some UDP-related fixlet. All this stuff has been
pointed out by the sparse tool. The first two patches are just annotation
related, while the last 2 cover some very unlikely races.
Paolo Abeni (4):
udpv6: add the required annotation to mib type
fou6: fix proto error handler argument type
udpv6: fix possible user after free in error handler
udp: fix possible user after free in error handler
net/ipv4/udp.c | 6 ++++--
net/ipv6/fou6.c | 2 +-
net/ipv6/udp.c | 12 +++++++-----
3 files changed, 12 insertions(+), 8 deletions(-)
--
2.20.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH net 1/4] udpv6: add the required annotation to mib type
2019-02-21 16:43 [PATCH net 0/4] udp: a few fixes Paolo Abeni
@ 2019-02-21 16:43 ` Paolo Abeni
2019-02-21 16:43 ` [PATCH net 2/4] fou6: fix proto error handler argument type Paolo Abeni
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Paolo Abeni @ 2019-02-21 16:43 UTC (permalink / raw)
To: netdev; +Cc: David S. Miller, Stefano Brivio
In commit 029a37434880 ("udp6: cleanup stats accounting in recvmsg()")
I forgot to add the percpu annotation for the mib pointer. Add it, and
make sparse happy.
Fixes: 029a37434880 ("udp6: cleanup stats accounting in recvmsg()")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
net/ipv6/udp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 2596ffdeebea..e6c52c27f354 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -288,8 +288,8 @@ int udpv6_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
int peeked, peeking, off;
int err;
int is_udplite = IS_UDPLITE(sk);
+ struct udp_mib __percpu *mib;
bool checksum_valid = false;
- struct udp_mib *mib;
int is_udp4;
if (flags & MSG_ERRQUEUE)
--
2.20.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net 2/4] fou6: fix proto error handler argument type
2019-02-21 16:43 [PATCH net 0/4] udp: a few fixes Paolo Abeni
2019-02-21 16:43 ` [PATCH net 1/4] udpv6: add the required annotation to mib type Paolo Abeni
@ 2019-02-21 16:43 ` Paolo Abeni
2019-02-21 16:43 ` [PATCH net 3/4] udpv6: fix possible user after free in error handler Paolo Abeni
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Paolo Abeni @ 2019-02-21 16:43 UTC (permalink / raw)
To: netdev; +Cc: David S. Miller, Stefano Brivio
Last argument of gue6_err_proto_handler() has a wrong type annotation,
fix it and make sparse happy again.
Fixes: b8a51b38e4d4 ("fou, fou6: ICMP error handlers for FoU and GUE")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Acked-by: Stefano Brivio <sbrivio@redhat.com>
---
net/ipv6/fou6.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/ipv6/fou6.c b/net/ipv6/fou6.c
index b858bd5280bf..867474abe269 100644
--- a/net/ipv6/fou6.c
+++ b/net/ipv6/fou6.c
@@ -72,7 +72,7 @@ static int gue6_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e,
static int gue6_err_proto_handler(int proto, struct sk_buff *skb,
struct inet6_skb_parm *opt,
- u8 type, u8 code, int offset, u32 info)
+ u8 type, u8 code, int offset, __be32 info)
{
const struct inet6_protocol *ipprot;
--
2.20.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net 3/4] udpv6: fix possible user after free in error handler
2019-02-21 16:43 [PATCH net 0/4] udp: a few fixes Paolo Abeni
2019-02-21 16:43 ` [PATCH net 1/4] udpv6: add the required annotation to mib type Paolo Abeni
2019-02-21 16:43 ` [PATCH net 2/4] fou6: fix proto error handler argument type Paolo Abeni
@ 2019-02-21 16:43 ` Paolo Abeni
2019-02-21 16:44 ` [PATCH net 4/4] udp: " Paolo Abeni
2019-02-23 0:09 ` [PATCH net 0/4] udp: a few fixes David Miller
4 siblings, 0 replies; 6+ messages in thread
From: Paolo Abeni @ 2019-02-21 16:43 UTC (permalink / raw)
To: netdev; +Cc: David S. Miller, Stefano Brivio
Before derefencing the encap pointer, commit e7cc082455cb ("udp: Support
for error handlers of tunnels with arbitrary destination port") checks
for a NULL value, but the two fetch operation can race with removal.
Fix the above using a single access.
Also fix a couple of type annotations, to make sparse happy.
Fixes: e7cc082455cb ("udp: Support for error handlers of tunnels with arbitrary destination port")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Acked-by: Stefano Brivio <sbrivio@redhat.com>
---
net/ipv6/udp.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index e6c52c27f354..b444483cdb2b 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -420,17 +420,19 @@ EXPORT_SYMBOL(udpv6_encap_enable);
*/
static int __udp6_lib_err_encap_no_sk(struct sk_buff *skb,
struct inet6_skb_parm *opt,
- u8 type, u8 code, int offset, u32 info)
+ u8 type, u8 code, int offset, __be32 info)
{
int i;
for (i = 0; i < MAX_IPTUN_ENCAP_OPS; i++) {
int (*handler)(struct sk_buff *skb, struct inet6_skb_parm *opt,
- u8 type, u8 code, int offset, u32 info);
+ u8 type, u8 code, int offset, __be32 info);
+ const struct ip6_tnl_encap_ops *encap;
- if (!ip6tun_encaps[i])
+ encap = rcu_dereference(ip6tun_encaps[i]);
+ if (!encap)
continue;
- handler = rcu_dereference(ip6tun_encaps[i]->err_handler);
+ handler = encap->err_handler;
if (handler && !handler(skb, opt, type, code, offset, info))
return 0;
}
--
2.20.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net 4/4] udp: fix possible user after free in error handler
2019-02-21 16:43 [PATCH net 0/4] udp: a few fixes Paolo Abeni
` (2 preceding siblings ...)
2019-02-21 16:43 ` [PATCH net 3/4] udpv6: fix possible user after free in error handler Paolo Abeni
@ 2019-02-21 16:44 ` Paolo Abeni
2019-02-23 0:09 ` [PATCH net 0/4] udp: a few fixes David Miller
4 siblings, 0 replies; 6+ messages in thread
From: Paolo Abeni @ 2019-02-21 16:44 UTC (permalink / raw)
To: netdev; +Cc: David S. Miller, Stefano Brivio
Similar to the previous commit, this addresses the same issue for
ipv4: use a single fetch operation and use the correct rcu
annotation.
Fixes: e7cc082455cb ("udp: Support for error handlers of tunnels with arbitrary destination port")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Acked-by: Stefano Brivio <sbrivio@redhat.com>
---
net/ipv4/udp.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 5c3cd5d84a6f..372fdc5381a9 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -562,10 +562,12 @@ static int __udp4_lib_err_encap_no_sk(struct sk_buff *skb, u32 info)
for (i = 0; i < MAX_IPTUN_ENCAP_OPS; i++) {
int (*handler)(struct sk_buff *skb, u32 info);
+ const struct ip_tunnel_encap_ops *encap;
- if (!iptun_encaps[i])
+ encap = rcu_dereference(iptun_encaps[i]);
+ if (!encap)
continue;
- handler = rcu_dereference(iptun_encaps[i]->err_handler);
+ handler = encap->err_handler;
if (handler && !handler(skb, info))
return 0;
}
--
2.20.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net 0/4] udp: a few fixes
2019-02-21 16:43 [PATCH net 0/4] udp: a few fixes Paolo Abeni
` (3 preceding siblings ...)
2019-02-21 16:44 ` [PATCH net 4/4] udp: " Paolo Abeni
@ 2019-02-23 0:09 ` David Miller
4 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2019-02-23 0:09 UTC (permalink / raw)
To: pabeni; +Cc: netdev, sbrivio
From: Paolo Abeni <pabeni@redhat.com>
Date: Thu, 21 Feb 2019 17:43:56 +0100
> This series includes some UDP-related fixlet. All this stuff has been
> pointed out by the sparse tool. The first two patches are just annotation
> related, while the last 2 cover some very unlikely races.
Series applied and queued up for -stable, thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-02-23 0:11 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-21 16:43 [PATCH net 0/4] udp: a few fixes Paolo Abeni
2019-02-21 16:43 ` [PATCH net 1/4] udpv6: add the required annotation to mib type Paolo Abeni
2019-02-21 16:43 ` [PATCH net 2/4] fou6: fix proto error handler argument type Paolo Abeni
2019-02-21 16:43 ` [PATCH net 3/4] udpv6: fix possible user after free in error handler Paolo Abeni
2019-02-21 16:44 ` [PATCH net 4/4] udp: " Paolo Abeni
2019-02-23 0:09 ` [PATCH net 0/4] udp: a few fixes David Miller
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).