linux-brain/net/can
Oleksij Rempel 7eef18c047 can: j1939: j1939_session_deactivate(): clarify lifetime of session object
commit 0c71437dd50dd687c15d8ca80b3b68f10bb21d63 upstream.

The j1939_session_deactivate() is decrementing the session ref-count and
potentially can free() the session. This would cause use-after-free
situation.

However, the code calling j1939_session_deactivate() does always hold
another reference to the session, so that it would not be free()ed in
this code path.

This patch adds a comment to make this clear and a WARN_ON, to ensure
that future changes will not violate this requirement. Further this
patch avoids dereferencing the session pointer as a precaution to avoid
use-after-free if the session is actually free()ed.

Fixes: 9d71dd0c70 ("can: add support of SAE J1939 protocol")
Link: https://lore.kernel.org/r/20210714111602.24021-1-o.rempel@pengutronix.de
Reported-by: Xiaochen Zou <xzou017@ucr.edu>
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-08-04 12:27:40 +02:00
..
j1939 can: j1939: j1939_session_deactivate(): clarify lifetime of session object 2021-08-04 12:27:40 +02:00
Kconfig can: add support of SAE J1939 protocol 2019-09-04 14:22:33 +02:00
Makefile can: add support of SAE J1939 protocol 2019-09-04 14:22:33 +02:00
af_can.c net: introduce CAN specific pointer in the struct net_device 2021-04-07 14:47:41 +02:00
af_can.h can: introduce CAN midlayer private and allocate it automatically 2019-09-04 13:29:14 +02:00
bcm.c can: bcm: delay release of struct bcm_op after synchronize_rcu() 2021-07-14 16:53:04 +02:00
gw.c can: gw: synchronize rcu operations before removing gw job entry 2021-07-14 16:53:04 +02:00
proc.c net: introduce CAN specific pointer in the struct net_device 2021-04-07 14:47:41 +02:00
raw.c can: raw: raw_setsockopt(): fix raw_rcv panic for sock UAF 2021-08-04 12:27:38 +02:00