]> git.baikalelectronics.ru Git - 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)
committerDavid S. Miller <davem@davemloft.net>
Wed, 21 Apr 2021 18:01:03 +0000 (11:01 -0700)
commitcb93e61a993c0586995b8cb0455192ae4c926492
treec66d2abce9babf4914ff97d2e3b20b8cd76023b1
parent9f2a450f9eeb911e7689048d97b05cf0170fb213
net: qrtr: Avoid potential use after free in MHI send

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: c63cf2f09ec2 ("net: qrtr: Add MHI transport layer")
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/qrtr/mhi.c