]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commit
net: qrtr: Avoid potential use after free in MHI send
authorBjorn Andersson <bjorn.andersson@linaro.org>
Wed, 21 Apr 2021 17:40:07 +0000 (10:40 -0700)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 19 May 2021 08:03:33 +0000 (10:03 +0200)
commit29668be20eb1fb5d03c6ede469664abf1661777b
treef901a4701d4a83451d322a402eb60c115267e26b
parentd4bad720744adafc24011cc44c7074da41328072
net: qrtr: Avoid potential use after free in MHI send

BugLink: https://bugs.launchpad.net/bugs/1928850
commit 47a017f33943278570c072bc71681809b2567b3a upstream.

It is possible that the MHI ul_callback will be invoked immediately
following the queueing of the skb for transmission, leading to the
callback decrementing the refcount of the associated sk and freeing the
skb.

As such the dereference of skb and the increment of the sk refcount must
happen before the skb is queued, to avoid the skb to be used after free
and potentially the sk to drop its last refcount..

Fixes: 6e728f321393 ("net: qrtr: Add MHI transport layer")
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
net/qrtr/mhi.c