[Devel] [PATCH RHEL7 COMMIT] netlink: Don't manipulate @sk_peek_off if data fetching failed
Konstantin Khorenko
khorenko at virtuozzo.com
Mon Mar 27 05:42:13 PDT 2017
The commit is pushed to "branch-rh7-3.10.0-514.10.2.vz7.29.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-514.10.2.vz7.29.6
------>
commit 959f2bcf808c3fc6ebbe5d7f1b5fce826a235d74
Author: Cyrill Gorcunov <gorcunov at virtuozzo.com>
Date: Mon Mar 27 16:42:12 2017 +0400
netlink: Don't manipulate @sk_peek_off if data fetching failed
When skb_copy_datagram_iovec called to fetch queued data
it may fail with EFAULT and if MSG_PEEK set by a caller
the position get advanced even if data hasn't been read.
So we might loose data bits here on subsequent recvmsg
calls. Instead lets exit early with error.
In sake of https://jira.sw.ru/browse/PSBM-57921
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
Acked-by: Andrey Vagin <avagin at virtuozzo.com>
---
net/netlink/af_netlink.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 68795fb..d0af224 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -2483,11 +2483,12 @@ static int netlink_recvmsg(struct kiocb *kiocb, struct socket *sock,
skb_reset_transport_header(data_skb);
err = skb_copy_datagram_iovec(data_skb, skip, msg->msg_iov, copied);
-
- if (flags & MSG_PEEK)
- sk_peek_offset_fwd(sk, copied);
- else
- sk_peek_offset_bwd(sk, skb->len);
+ if (!err) {
+ if (flags & MSG_PEEK)
+ sk_peek_offset_fwd(sk, copied);
+ else
+ sk_peek_offset_bwd(sk, skb->len);
+ }
if (msg->msg_name) {
struct sockaddr_nl *addr = (struct sockaddr_nl *)msg->msg_name;
More information about the Devel
mailing list