* [PATCH net-next] ip: silence udp zerocopy smatch false positive
@ 2018-12-08 11:22 Willem de Bruijn
2018-12-08 20:27 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Willem de Bruijn @ 2018-12-08 11:22 UTC (permalink / raw)
To: netdev; +Cc: davem, Willem de Bruijn
From: Willem de Bruijn <willemb@google.com>
extra_uref is used in __ip(6)_append_data only if uarg is set.
Smatch sees that the variable is passed to sock_zerocopy_put_abort.
This function accesses it only when uarg is set, but smatch cannot
infer this.
Make this dependency explicit.
Fixes: 52900d22288e ("udp: elide zerocopy operation in hot path")
Signed-off-by: Willem de Bruijn <willemb@google.com>
---
net/ipv4/ip_output.c | 3 ++-
net/ipv6/ip6_output.c | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 78f028bdad30b..ab6618036afed 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -1130,7 +1130,8 @@ static int __ip_append_data(struct sock *sk,
error_efault:
err = -EFAULT;
error:
- sock_zerocopy_put_abort(uarg, extra_uref);
+ if (uarg)
+ sock_zerocopy_put_abort(uarg, extra_uref);
cork->length -= length;
IP_INC_STATS(sock_net(sk), IPSTATS_MIB_OUTDISCARDS);
refcount_add(wmem_alloc_delta, &sk->sk_wmem_alloc);
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 6592a39e5ec10..be25b34dc5c2f 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -1575,7 +1575,8 @@ static int __ip6_append_data(struct sock *sk,
error_efault:
err = -EFAULT;
error:
- sock_zerocopy_put_abort(uarg, extra_uref);
+ if (uarg)
+ sock_zerocopy_put_abort(uarg, extra_uref);
cork->length -= length;
IP6_INC_STATS(sock_net(sk), rt->rt6i_idev, IPSTATS_MIB_OUTDISCARDS);
refcount_add(wmem_alloc_delta, &sk->sk_wmem_alloc);
--
2.20.0.rc2.403.gdbc3b29805-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next] ip: silence udp zerocopy smatch false positive
2018-12-08 11:22 [PATCH net-next] ip: silence udp zerocopy smatch false positive Willem de Bruijn
@ 2018-12-08 20:27 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2018-12-08 20:27 UTC (permalink / raw)
To: willemdebruijn.kernel; +Cc: netdev, willemb
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Date: Sat, 8 Dec 2018 06:22:46 -0500
> From: Willem de Bruijn <willemb@google.com>
>
> extra_uref is used in __ip(6)_append_data only if uarg is set.
>
> Smatch sees that the variable is passed to sock_zerocopy_put_abort.
> This function accesses it only when uarg is set, but smatch cannot
> infer this.
>
> Make this dependency explicit.
>
> Fixes: 52900d22288e ("udp: elide zerocopy operation in hot path")
> Signed-off-by: Willem de Bruijn <willemb@google.com>
I looked and can't figure out a better way to fix this :)
Applied, thanks Willem.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-12-08 20:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-08 11:22 [PATCH net-next] ip: silence udp zerocopy smatch false positive Willem de Bruijn
2018-12-08 20:27 ` 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).