Skip to content

Commit 6209451

Browse files
committed
net: ieee802154: do not leave a dangling sk pointer in ieee802154_create()
JIRA: https://issues.redhat.com/browse/RHEL-73817 JIRA: https://issues.redhat.com/browse/RHEL-72282 CVE: CVE-2024-56602 commit b4fcd63 Author: Ignat Korchagin <ignat@cloudflare.com> Date: Mon Oct 14 16:38:04 2024 +0100 net: ieee802154: do not leave a dangling sk pointer in ieee802154_create() sock_init_data() attaches the allocated sk object to the provided sock object. If ieee802154_create() fails later, the allocated sk object is freed, but the dangling pointer remains in the provided sock object, which may allow use-after-free. Clear the sk pointer in the sock object on error. Signed-off-by: Ignat Korchagin <ignat@cloudflare.com> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com> Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com> Reviewed-by: Eric Dumazet <edumazet@google.com> Link: https://patch.msgid.link/20241014153808.51894-6-ignat@cloudflare.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
1 parent 2730be8 commit 6209451

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

net/ieee802154/socket.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,19 +1037,21 @@ static int ieee802154_create(struct net *net, struct socket *sock,
10371037

10381038
if (sk->sk_prot->hash) {
10391039
rc = sk->sk_prot->hash(sk);
1040-
if (rc) {
1041-
sk_common_release(sk);
1042-
goto out;
1043-
}
1040+
if (rc)
1041+
goto out_sk_release;
10441042
}
10451043

10461044
if (sk->sk_prot->init) {
10471045
rc = sk->sk_prot->init(sk);
10481046
if (rc)
1049-
sk_common_release(sk);
1047+
goto out_sk_release;
10501048
}
10511049
out:
10521050
return rc;
1051+
out_sk_release:
1052+
sk_common_release(sk);
1053+
sock->sk = NULL;
1054+
goto out;
10531055
}
10541056

10551057
static const struct net_proto_family ieee802154_family_ops = {

0 commit comments

Comments
 (0)