zerocopy fixes
Subsystems (2)
cover zerocopy fixes
From: Willem de Bruijn <[email protected]>
Fix two issues introduced in the msg_zerocopy patchset.
Willem de Bruijn (2):
sock: fix zerocopy panic in mem accounting
sock: fix zerocopy_success regression with msg_zerocopy
include/linux/skbuff.h | 9 +++++++-- net/core/skbuff.c | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-)
Signature · 1 line
2.14.0.434.g98096fd7a8-goog
PATCH 1/2 sock: fix zerocopy panic in mem accounting
From: Willem de Bruijn <[email protected]>
Only call mm_unaccount_pinned_pages when releasing a struct ubuf_info that has initialized its field uarg->mmp.
Before this patch, a vhost-net with experimental_zcopytx can crash in
mm_unaccount_pinned_pages
sock_zerocopy_put
skb_zcopy_clear
skb_release_data
Only sock_zerocopy_alloc initializes this field. Move the unaccount call from generic sock_zerocopy_put to its specific callback sock_zerocopy_callback.
--- net/core/skbuff.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/core/skbuff.c +2 -2
@@ -1044,6 +1044,8 @@ void sock_zerocopy_callback(struct ubuf_info *uarg, bool success)u32 lo, hi;u16 len; +mm_unaccount_pinned_pages (&uarg->mmp); +/* if !len, there was only 1 call, and it was aborted * so do not queue a completion notification */
@@ -1084,8 +1086,6 @@ EXPORT_SYMBOL_GPL(sock_zerocopy_callback);void sock_zerocopy_put (struct ubuf_info *uarg) {if (uarg &&atomic_dec_and_test (&uarg->refcnt)) { -mm_unaccount_pinned_pages (&uarg->mmp); -if (uarg->callback) uarg->callback (uarg, uarg->zerocopy);else
Signature · 1 line
2.14.0.434.g98096fd7a8-goog
PATCH 2/2 sock: fix zerocopy_success regression with msg_zerocopy
In reply to Willem de BruijnFrom: Willem de Bruijn <[email protected]>
Do not use uarg->zerocopy outside msg_zerocopy. In other paths the field is not explicitly initialized and aliases another field.
Those paths have only one reference so do not need this intermediate variable. Call uarg->callback directly.
--- include/linux/skbuff.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
include/linux/skbuff.h +7 -2
@@ -1273,8 +1273,13 @@ static inline void skb_zcopy_clear(struct sk_buff *skb, bool zerocopy)struct ubuf_info *uarg =skb_zcopy (skb);if (uarg) { - uarg->zerocopy = uarg->zerocopy && zerocopy; -sock_zerocopy_put (uarg); +if (uarg->callback == sock_zerocopy_callback) { + uarg->zerocopy = uarg->zerocopy && zerocopy; +sock_zerocopy_put (uarg); + }else { + uarg->callback (uarg, zerocopy); + } +skb_shinfo (skb)->tx_flags &= ~SKBTX_ZEROCOPY_FRAG ; } }
Signature · 1 line
2.14.0.434.g98096fd7a8-goog
David Miller
maintainerFrom: Willem de Bruijn <[email protected]>
Date: Wed, 9 Aug 2017 19:09:42 -0400
Quoted 1 line
Fix two issues introduced in the
msg_zerocopypatchset.
Series applied, thanks for following up on this so quickly.
Quoted 4 lines · Willem de Bruijn
From: Willem de Bruijn <[email protected]>
Fix two issues introduced in the
msg_zerocopypatchset.
Quoted 8 lines
Willem de Bruijn (2):
sock: fix zerocopy panic in mem accounting
sock: fixzerocopy_successregression withmsg_zerocopyinclude/linux/skbuff.h | 9 +++++++-- net/core/skbuff.c | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-)
Fixes the problem I reported. Thanks for the quick turn around.