提交 aea0929e 编写于 作者: E Eric B Munson 提交者: David S. Miller

tcp: Return error instead of partial read for saved syn headers

Currently the getsockopt() requesting the cached contents of the syn
packet headers will fail silently if the caller uses a buffer that is
too small to contain the requested data.  Rather than fail silently and
discard the headers, getsockopt() should return an error and report the
required size to hold the data.
Signed-off-by: NEric B Munson <emunson@akamai.com>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
Cc: James Morris <jmorris@namei.org>
Cc: Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>
Cc: Patrick McHardy <kaber@trash.net>
Cc: netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 c9a70d43
...@@ -2845,7 +2845,15 @@ static int do_tcp_getsockopt(struct sock *sk, int level, ...@@ -2845,7 +2845,15 @@ static int do_tcp_getsockopt(struct sock *sk, int level,
lock_sock(sk); lock_sock(sk);
if (tp->saved_syn) { if (tp->saved_syn) {
len = min_t(unsigned int, tp->saved_syn[0], len); if (len < tp->saved_syn[0]) {
if (put_user(tp->saved_syn[0], optlen)) {
release_sock(sk);
return -EFAULT;
}
release_sock(sk);
return -EINVAL;
}
len = tp->saved_syn[0];
if (put_user(len, optlen)) { if (put_user(len, optlen)) {
release_sock(sk); release_sock(sk);
return -EFAULT; return -EFAULT;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册