net/sched: cls_route: No longer copy tcf_result on update to avoid use-after-free

[ Upstream commit b80b829e9e2c1b3f7aae34855e04d8f6ecaf13c8 ]

When route4_change() is called on an existing filter, the whole
tcf_result struct is always copied into the new instance of the filter.

This causes a problem when updating a filter bound to a class,
as tcf_unbind_filter() is always called on the old instance in the
success path, decreasing filter_cnt of the still referenced class
and allowing it to be deleted, leading to a use-after-free.

Fix this by no longer copying the tcf_result struct from the old filter.

BUG=b/296442227
SOURCE=UPSTREAM(b80b829e9e2c)
TEST=presubmit
RELEASE_NOTE=None

cos-patch: security-high
Fixes: 1109c00547fc ("net: sched: RCU cls_route")
Reported-by: valis <[email protected]>
Reported-by: Bing-Jhong Billy Jheng <[email protected]>
Change-Id: If38d82bccceccd4abf65d6765acc30fadfc8cdc9
Signed-off-by: valis <[email protected]>
Signed-off-by: Jamal Hadi Salim <[email protected]>
Signed-off-by: Jakub Kicinski <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
Reviewed-on: https://cos-review.googlesource.com/c/third_party/kernel/+/55578
Main-Branch-Verified: Cusky Presubmit Bot <[email protected]>
Reviewed-by: Oleksandr Tymoshenko <[email protected]>
Tested-by: Cusky Presubmit Bot <[email protected]>
1 file changed