]> git.baikalelectronics.ru Git - kernel.git/commit
xfrm: fix refcount leak in __xfrm_policy_check()
authorXin Xiong <xiongx18@fudan.edu.cn>
Sun, 24 Jul 2022 09:55:58 +0000 (17:55 +0800)
committerSteffen Klassert <steffen.klassert@secunet.com>
Tue, 26 Jul 2022 21:08:24 +0000 (23:08 +0200)
commit616dcfaf18ae824a5315390f307bf21499ecce15
tree465e49197666e7be63090845a56c00cc4f05b722
parent24a46ac8d00834e7423d2fc11ce9d7f5771dfa45
xfrm: fix refcount leak in __xfrm_policy_check()

The issue happens on an error path in __xfrm_policy_check(). When the
fetching process of the object `pols[1]` fails, the function simply
returns 0, forgetting to decrement the reference count of `pols[0]`,
which is incremented earlier by either xfrm_sk_policy_lookup() or
xfrm_policy_lookup(). This may result in memory leaks.

Fix it by decreasing the reference count of `pols[0]` in that path.

Fixes: 4a44371f5f4b ("IPsec: propagate security module errors up from flow_cache_lookup")
Signed-off-by: Xin Xiong <xiongx18@fudan.edu.cn>
Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
net/xfrm/xfrm_policy.c