]> git.proxmox.com Git - mirror_ubuntu-jammy-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)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 10 Aug 2022 07:22:11 +0000 (09:22 +0200)
commit636636dd7bded9d353a1f2133292707286306867
tree252dcdb08177f1359aae87060cb6be293a148533
parent3190653df660072f24f60cddf580804c08bc86e8
tls: Fix context leak on tls_device_down

BugLink: https://bugs.launchpad.net/bugs/1980278
[ Upstream commit 3740651bf7e200109dd42d5b2fb22226b26f960a ]

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: c55dcdd435aa ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
net/tls/tls_device.c