Skip to content

Commit d7903b6

Browse files
net: af_can: do not leave a dangling sk pointer in can_create()
jira VULN-41237 cve CVE-2024-56603 commit-author Ignat Korchagin <ignat@cloudflare.com> commit 811a7ca On error can_create() frees the allocated sk object, but sock_init_data() has already attached it to the provided sock object. This will leave a dangling sk pointer in the sock object and may cause use-after-free later. Signed-off-by: Ignat Korchagin <ignat@cloudflare.com> Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr> Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com> Reviewed-by: Marc Kleine-Budde <mkl@pengutronix.de> Link: https://patch.msgid.link/20241014153808.51894-5-ignat@cloudflare.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> (cherry picked from commit 811a7ca) Signed-off-by: Pratham Patel <ppatel@ciq.com>
1 parent 2741a8c commit d7903b6

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

net/can/af_can.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ static int can_create(struct net *net, struct socket *sock, int protocol,
200200
/* release sk on errors */
201201
sock_orphan(sk);
202202
sock_put(sk);
203+
sock->sk = NULL;
203204
}
204205

205206
errout:

0 commit comments

Comments
 (0)