From: Arjun Roy <arjunroy.kdev@gmail.com>
To: davem@davemloft.net, netdev@vger.kernel.org
Cc: arjunroy@google.com, soheil@google.com, edumazet@google.com,
willemb@google.com
Subject: [PATCH net-next] tcp-zerocopy: Update returned getsockopt() optlen.
Date: Mon, 24 Feb 2020 21:58:06 -0800 [thread overview]
Message-ID: <20200225055806.74881-1-arjunroy.kdev@gmail.com> (raw)
From: Arjun Roy <arjunroy@google.com>
TCP receive zerocopy currently does not update the returned optlen for
getsockopt(). Thus, userspace cannot properly determine if all the
fields are set in the passed-in struct. This patch sets the optlen
before return, in keeping with the expected operation of getsockopt().
Signed-off-by: Arjun Roy <arjunroy@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Soheil Hassas Yeganeh <soheil@google.com>
Signed-off-by: Willem de Bruijn <willemb@google.com>
---
net/ipv4/tcp.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 600deb39f17de..fb9894d3d30e9 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -4148,8 +4148,12 @@ static int do_tcp_getsockopt(struct sock *sk, int level,
zerocopy_rcv_inq:
zc.inq = tcp_inq_hint(sk);
zerocopy_rcv_out:
- if (!err && copy_to_user(optval, &zc, len))
- err = -EFAULT;
+ if (!err) {
+ if (put_user(len, optlen))
+ return -EFAULT;
+ if (copy_to_user(optval, &zc, len))
+ return -EFAULT;
+ }
return err;
}
#endif
--
2.25.0.265.gbab2e86ba0-goog
next reply other threads:[~2020-02-25 5:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-25 5:58 Arjun Roy [this message]
2020-02-25 6:01 ` [PATCH net-next] tcp-zerocopy: Update returned getsockopt() optlen Eric Dumazet
2020-02-25 6:06 Arjun Roy
2020-02-25 6:28 ` Eric Dumazet
2020-02-25 16:48 ` Arjun Roy
2020-02-25 17:04 ` Arjun Roy
2020-02-25 17:16 ` Soheil Hassas Yeganeh
2020-02-25 20:20 ` Arjun Roy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200225055806.74881-1-arjunroy.kdev@gmail.com \
--to=arjunroy.kdev@gmail.com \
--cc=arjunroy@google.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=netdev@vger.kernel.org \
--cc=soheil@google.com \
--cc=willemb@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).