]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit
can: j1939: transport: j1939_session_tx_dat(): fix use-after-free read in j1939_tp_tx...
authorOleksij Rempel <o.rempel@pengutronix.de>
Fri, 7 Aug 2020 10:51:57 +0000 (12:51 +0200)
committerKhalid Elmously <khalid.elmously@canonical.com>
Wed, 16 Sep 2020 09:13:26 +0000 (05:13 -0400)
commit98415daf69ce59b31d7d90ff7a892314200cac80
treee08383bed7b314c8fb8d2ceaef81902ba34e67a0
parent0d8f6a3ca92741c50917c3a218eded5726fd033f
can: j1939: transport: j1939_session_tx_dat(): fix use-after-free read in j1939_tp_txtimer()

BugLink: https://bugs.launchpad.net/bugs/1893115
commit cd3b3636c99fcac52c598b64061f3fe4413c6a12 upstream.

The current stack implementation do not support ECTS requests of not
aligned TP sized blocks.

If ECTS will request a block with size and offset spanning two TP
blocks, this will cause memcpy() to read beyond the queued skb (which
does only contain one TP sized block).

Sometimes KASAN will detect this read if the memory region beyond the
skb was previously allocated and freed. In other situations it will stay
undetected. The ETP transfer in any case will be corrupted.

This patch adds a sanity check to avoid this kind of read and abort the
session with error J1939_XTP_ABORT_ECTS_TOO_BIG.

Reported-by: syzbot+5322482fe520b02aea30@syzkaller.appspotmail.com
Fixes: 9d71dd0c7009 ("can: add support of SAE J1939 protocol")
Cc: linux-stable <stable@vger.kernel.org> # >= v5.4
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Link: https://lore.kernel.org/r/20200807105200.26441-3-o.rempel@pengutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
net/can/j1939/transport.c