Skip to content

Commit 1daea69

Browse files
committed
Merge: CVE-2024-56600: net: inet6: do not leave a dangling sk pointer in inet6_create()
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/6101 JIRA: https://issues.redhat.com/browse/RHEL-72313 CVE: CVE-2024-56600 ``` net: inet6: do not leave a dangling sk pointer in inet6_create() sock_init_data() attaches the allocated sk pointer to the provided sock object. If inet6_create() fails later, the sk object is released, but the sock object retains the dangling sk pointer, which may cause use-after-free later. Clear the sock sk pointer on error. Signed-off-by: Ignat Korchagin <ignat@cloudflare.com> Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com> Reviewed-by: Eric Dumazet <edumazet@google.com> Link: https://patch.msgid.link/20241014153808.51894-8-ignat@cloudflare.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> (cherry picked from commit 9df99c3) ``` Signed-off-by: CKI Backport Bot <cki-ci-bot+cki-gitlab-backport-bot@redhat.com> --- <small>Created 2025-01-07 03:10 UTC by backporter - [KWF FAQ](https://red.ht/kernel_workflow_doc) - [Slack #team-kernel-workflow](https://redhat-internal.slack.com/archives/C04LRUPMJQ5) - [Source](https://gitlab.com/cki-project/kernel-workflow/-/blob/main/webhook/utils/backporter.py) - [Documentation](https://gitlab.com/cki-project/kernel-workflow/-/blob/main/docs/README.backporter.md) - [Report an issue](https://gitlab.com/cki-project/kernel-workflow/-/issues/new?issue%5Btitle%5D=backporter%20webhook%20issue)</small> Approved-by: Hangbin Liu <haliu@redhat.com> Approved-by: Sabrina Dubroca <sdubroca@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Rado Vrbovsky <rvrbovsk@redhat.com>
2 parents 9b62ae5 + 4c2958f commit 1daea69

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

net/ipv6/af_inet6.c

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -260,31 +260,29 @@ static int inet6_create(struct net *net, struct socket *sock, int protocol,
260260
*/
261261
inet->inet_sport = htons(inet->inet_num);
262262
err = sk->sk_prot->hash(sk);
263-
if (err) {
264-
sk_common_release(sk);
265-
goto out;
266-
}
263+
if (err)
264+
goto out_sk_release;
267265
}
268266
if (sk->sk_prot->init) {
269267
err = sk->sk_prot->init(sk);
270-
if (err) {
271-
sk_common_release(sk);
272-
goto out;
273-
}
268+
if (err)
269+
goto out_sk_release;
274270
}
275271

276272
if (!kern) {
277273
err = BPF_CGROUP_RUN_PROG_INET_SOCK(sk);
278-
if (err) {
279-
sk_common_release(sk);
280-
goto out;
281-
}
274+
if (err)
275+
goto out_sk_release;
282276
}
283277
out:
284278
return err;
285279
out_rcu_unlock:
286280
rcu_read_unlock();
287281
goto out;
282+
out_sk_release:
283+
sk_common_release(sk);
284+
sock->sk = NULL;
285+
goto out;
288286
}
289287

290288
static int __inet6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len,

0 commit comments

Comments
 (0)