From: Nagamani PV <nagamani@linux.ibm.com>
To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com
Cc: horms@kernel.org, linux-s390@vger.kernel.org,
netdev@vger.kernel.org, wintera@linux.ibm.com,
twinkler@linux.ibm.com, heiko.carstens@de.ibm.com,
hidayath@linux.ibm.com, borntraeger@linux.ibm.com,
stable@vger.kernel.org
Subject: [PATCH net-next] net/iucv: fix UAF in afiucv_netdev_event()
Date: Mon, 3 Aug 2026 20:20:53 +0200 [thread overview]
Message-ID: <20260803182053.2355882-1-nagamani@linux.ibm.com> (raw)
afiucv_netdev_event() traverses iucv_sk_list without holding
iucv_sk_list.lock.
A concurrent socket teardown can unlink and free an af_iucv socket via
iucv_sock_kill() while the netdevice notifier path is still traversing
the list, resulting in a use-after-free when dereferencing the socket.
syzbot reported a KASAN slab-use-after-free triggered from the netdevice
notifier path:
BUG: KASAN: slab-use-after-free in afiucv_netdev_event+0x166/0x570
Read of size 8 at addr 001a54009dcda368 by task syz.3.24/516
Call Trace:
afiucv_netdev_event+0x166/0x570 net/iucv/af_iucv.c:2193
notifier_call_chain+0x18e/0x510 kernel/notifier.c:85
call_netdevice_notifiers net/core/dev.c:2301 [inline]
__dev_close_many+0x1c6/0x680 net/core/dev.c:1747
unregister_netdevice_many_notify+0x9b6/0x2650 net/core/dev.c:12388
unregister_netdevice_queue+0x392/0x3d0 net/core/dev.c:12291
__tun_detach+0xa50/0x1990 drivers/net/tun.c:621
Allocated by task 521:
sk_prot_alloc+0xd2/0x230 net/core/sock.c:2247
sk_alloc+0x48/0x680 net/core/sock.c:2303
iucv_sock_alloc+0x4e/0x710 net/iucv/af_iucv.c:456
iucv_sock_create+0x114/0x180 net/iucv/af_iucv.c:2254
Freed by task 519:
kfree+0x164/0x500 mm/slub.c:6561
iucv_sock_release+0x12e/0x150 net/iucv/af_iucv.c:1482
sock_close+0xa4/0x230 net/socket.c:1514
Protect the list traversal with the existing read-side lock.
Use read_lock_bh()/read_unlock_bh() to synchronize with
write_lock_bh()-protected updates to iucv_sk_list.
Fixes: 9fbd87d41392 ("af_iucv: handle netdev events")
Cc: stable@vger.kernel.org
Suggested-by: Hidayath Khan <hidayath@linux.ibm.com>
Signed-off-by: Nagamani PV <nagamani@linux.ibm.com>
---
net/iucv/af_iucv.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
index ea047bab65e7..034039c50941 100644
--- a/net/iucv/af_iucv.c
+++ b/net/iucv/af_iucv.c
@@ -2213,6 +2213,7 @@ static int afiucv_netdev_event(struct notifier_block *this,
switch (event) {
case NETDEV_REBOOT:
case NETDEV_GOING_DOWN:
+ read_lock_bh(&iucv_sk_list.lock);
sk_for_each(sk, &iucv_sk_list.head) {
iucv = iucv_sk(sk);
if ((iucv->hs_dev == event_dev) &&
@@ -2223,6 +2224,7 @@ static int afiucv_netdev_event(struct notifier_block *this,
sk->sk_state_change(sk);
}
}
+ read_unlock_bh(&iucv_sk_list.lock);
break;
case NETDEV_DOWN:
case NETDEV_UNREGISTER:
--
2.53.0
next reply other threads:[~2026-08-03 18:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-03 18:20 Nagamani PV [this message]
2026-08-04 8:33 ` [PATCH net-next] net/iucv: fix UAF in afiucv_netdev_event() Alexandra Winter
2026-08-04 12:52 ` Nagamani PV
2026-08-04 13:30 ` Alexandra Winter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260803182053.2355882-1-nagamani@linux.ibm.com \
--to=nagamani@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=heiko.carstens@de.ibm.com \
--cc=hidayath@linux.ibm.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=stable@vger.kernel.org \
--cc=twinkler@linux.ibm.com \
--cc=wintera@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox