]> git.baikalelectronics.ru Git - kernel.git/commit
net/smc: fix use-after-free of delayed events
authorKarsten Graul <kgraul@linux.ibm.com>
Wed, 14 Oct 2020 17:43:27 +0000 (19:43 +0200)
committerJakub Kicinski <kuba@kernel.org>
Thu, 15 Oct 2020 16:54:43 +0000 (09:54 -0700)
commit90bb8f0af0088de9e7c49346b953c0ea44681d31
treed2993ff8994afb8d39cda0e156b0a669364b6f0c
parenta533b6a3c5b3de1d549defe997f91848b737ee26
net/smc: fix use-after-free of delayed events

When a delayed event is enqueued then the event worker will send this
event the next time it is running and no other flow is currently
active. The event handler is called for the delayed event, and the
pointer to the event keeps set in lgr->delayed_event. This pointer is
cleared later in the processing by smc_llc_flow_start().
This can lead to a use-after-free condition when the processing does not
reach smc_llc_flow_start(), but frees the event because of an error
situation. Then the delayed_event pointer is still set but the event is
freed.
Fix this by always clearing the delayed event pointer when the event is
provided to the event handler for processing, and remove the code to
clear it in smc_llc_flow_start().

Fixes: 96fc5c847c20 ("net/smc: add event-based llc_flow framework")
Signed-off-by: Karsten Graul <kgraul@linux.ibm.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/smc/smc_llc.c