]> git.baikalelectronics.ru Git - kernel.git/commit
net/tls: don't leak IV and record seq when offload fails
authorJakub Kicinski <jakub.kicinski@netronome.com>
Fri, 19 Apr 2019 23:52:19 +0000 (16:52 -0700)
committerDavid S. Miller <davem@davemloft.net>
Sun, 21 Apr 2019 03:36:51 +0000 (20:36 -0700)
commit9aa8775c03c5bf7e05595c3f1c0ae6f60a96d9cf
treee7eb8437b2d9d6f8b592019a768c27815e697cfd
parent57fd2d45490b7519e49a921b73267dfb04cb1762
net/tls: don't leak IV and record seq when offload fails

When device refuses the offload in tls_set_device_offload_rx()
it calls tls_sw_free_resources_rx() to clean up software context
state.

Unfortunately, tls_sw_free_resources_rx() does not free all
the state tls_set_sw_offload() allocated - it leaks IV and
sequence number buffers.  All other code paths which lead to
tls_sw_release_resources_rx() (which tls_sw_free_resources_rx()
calls) free those right before the call.

Avoid the leak by moving freeing of iv and rec_seq into
tls_sw_release_resources_rx().

Fixes: 81b6ef1732a9 ("tls: Add rx inline crypto offload")
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Dirk van der Merwe <dirk.vandermerwe@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/tls/tls_device.c
net/tls/tls_main.c
net/tls/tls_sw.c