]> git.baikalelectronics.ru Git - kernel.git/commit
tls: Fix context leak on tls_device_down
authorMaxim Mikityanskiy <maximmi@nvidia.com>
Thu, 12 May 2022 09:18:30 +0000 (12:18 +0300)
committerJakub Kicinski <kuba@kernel.org>
Thu, 12 May 2022 17:01:36 +0000 (10:01 -0700)
commitbf5c2d483b1302e81f4f4b9874229875da2eb562
tree642623aed22f6d728acd0e129891856c10cdfcac
parent2566a7bb7256d1c37deb9f19b48b2fa87a648b10
tls: Fix context leak on tls_device_down

The commit cited below claims to fix a use-after-free condition after
tls_device_down. Apparently, the description wasn't fully accurate. The
context stayed alive, but ctx->netdev became NULL, and the offload was
torn down without a proper fallback, so a bug was present, but a
different kind of bug.

Due to misunderstanding of the issue, the original patch dropped the
refcount_dec_and_test line for the context to avoid the alleged
premature deallocation. That line has to be restored, because it matches
the refcount_inc_not_zero from the same function, otherwise the contexts
that survived tls_device_down are leaked.

This patch fixes the described issue by restoring refcount_dec_and_test.
After this change, there is no leak anymore, and the fallback to
software kTLS still works.

Fixes: 77886d834bc2 ("net/tls: Fix use-after-free after the TLS device goes down and up")
Signed-off-by: Maxim Mikityanskiy <maximmi@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://lore.kernel.org/r/20220512091830.678684-1-maximmi@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/tls/tls_device.c