summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Kicinski <kuba@kernel.org>2022-07-09 05:52:54 +0300
committerJakub Kicinski <kuba@kernel.org>2022-07-12 05:48:33 +0300
commit57128e98c33d79285adc523e670fe02d11b7e5da (patch)
tree9ee7003da826041c975f55e34825b4b6fa54c368
parentbb56cea9abd85c22175b31d8f7c44d6c615fe526 (diff)
downloadlinux-57128e98c33d79285adc523e670fe02d11b7e5da.tar.xz
tls: rx: fix the NoPad getsockopt
Maxim reports do_tls_getsockopt_no_pad() will always return an error. Indeed looks like refactoring gone wrong - remove err and use value. Reported-by: Maxim Mikityanskiy <maximmi@nvidia.com> Fixes: 88527790c079 ("tls: rx: add sockopt for enabling optimistic decrypt with TLS 1.3") Signed-off-by: Jakub Kicinski <kuba@kernel.org>
-rw-r--r--net/tls/tls_main.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/net/tls/tls_main.c b/net/tls/tls_main.c
index f3d9dbfa507e..f71b46568112 100644
--- a/net/tls/tls_main.c
+++ b/net/tls/tls_main.c
@@ -539,8 +539,7 @@ static int do_tls_getsockopt_no_pad(struct sock *sk, char __user *optval,
int __user *optlen)
{
struct tls_context *ctx = tls_get_ctx(sk);
- unsigned int value;
- int err, len;
+ int value, len;
if (ctx->prot_info.version != TLS_1_3_VERSION)
return -EINVAL;
@@ -551,12 +550,12 @@ static int do_tls_getsockopt_no_pad(struct sock *sk, char __user *optval,
return -EINVAL;
lock_sock(sk);
- err = -EINVAL;
+ value = -EINVAL;
if (ctx->rx_conf == TLS_SW || ctx->rx_conf == TLS_HW)
value = ctx->rx_no_pad;
release_sock(sk);
- if (err)
- return err;
+ if (value < 0)
+ return value;
if (put_user(sizeof(value), optlen))
return -EFAULT;