* [PATCH net 0/2] net: atm: protect dev_lec[] with a mutex
@ 2025-06-18 14:08 Eric Dumazet
2025-06-18 14:08 ` [PATCH net 1/2] net: atm: add lec_mutex Eric Dumazet
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Eric Dumazet @ 2025-06-18 14:08 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, netdev, eric.dumazet, Eric Dumazet
Based on an initial syzbot report.
First patch is adding lec_mutex to address the report.
Second patch protects /proc/net/atm/lec operations.
We probably should delete this driver, it seems quite broken.
Eric Dumazet (2):
net: atm: add lec_mutex
net: atm: fix /proc/net/atm/lec handling
net/atm/lec.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
--
2.50.0.rc2.696.g1fc2a0284f-goog
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH net 1/2] net: atm: add lec_mutex
2025-06-18 14:08 [PATCH net 0/2] net: atm: protect dev_lec[] with a mutex Eric Dumazet
@ 2025-06-18 14:08 ` Eric Dumazet
2025-06-18 14:08 ` [PATCH net 2/2] net: atm: fix /proc/net/atm/lec handling Eric Dumazet
2025-06-19 15:40 ` [PATCH net 0/2] net: atm: protect dev_lec[] with a mutex patchwork-bot+netdevbpf
2 siblings, 0 replies; 6+ messages in thread
From: Eric Dumazet @ 2025-06-18 14:08 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, netdev, eric.dumazet, Eric Dumazet,
syzbot+8b64dec3affaed7b3af5
syzbot found its way in net/atm/lec.c, and found an error path
in lecd_attach() could leave a dangling pointer in dev_lec[].
Add a mutex to protect dev_lecp[] uses from lecd_attach(),
lec_vcc_attach() and lec_mcast_attach().
Following patch will use this mutex for /proc/net/atm/lec.
BUG: KASAN: slab-use-after-free in lecd_attach net/atm/lec.c:751 [inline]
BUG: KASAN: slab-use-after-free in lane_ioctl+0x2224/0x23e0 net/atm/lec.c:1008
Read of size 8 at addr ffff88807c7b8e68 by task syz.1.17/6142
CPU: 1 UID: 0 PID: 6142 Comm: syz.1.17 Not tainted 6.16.0-rc1-syzkaller-00239-g08215f5486ec #0 PREEMPT(full)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/07/2025
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:94 [inline]
dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:120
print_address_description mm/kasan/report.c:408 [inline]
print_report+0xcd/0x680 mm/kasan/report.c:521
kasan_report+0xe0/0x110 mm/kasan/report.c:634
lecd_attach net/atm/lec.c:751 [inline]
lane_ioctl+0x2224/0x23e0 net/atm/lec.c:1008
do_vcc_ioctl+0x12c/0x930 net/atm/ioctl.c:159
sock_do_ioctl+0x118/0x280 net/socket.c:1190
sock_ioctl+0x227/0x6b0 net/socket.c:1311
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:907 [inline]
__se_sys_ioctl fs/ioctl.c:893 [inline]
__x64_sys_ioctl+0x18e/0x210 fs/ioctl.c:893
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xcd/0x4c0 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
</TASK>
Allocated by task 6132:
kasan_save_stack+0x33/0x60 mm/kasan/common.c:47
kasan_save_track+0x14/0x30 mm/kasan/common.c:68
poison_kmalloc_redzone mm/kasan/common.c:377 [inline]
__kasan_kmalloc+0xaa/0xb0 mm/kasan/common.c:394
kasan_kmalloc include/linux/kasan.h:260 [inline]
__do_kmalloc_node mm/slub.c:4328 [inline]
__kvmalloc_node_noprof+0x27b/0x620 mm/slub.c:5015
alloc_netdev_mqs+0xd2/0x1570 net/core/dev.c:11711
lecd_attach net/atm/lec.c:737 [inline]
lane_ioctl+0x17db/0x23e0 net/atm/lec.c:1008
do_vcc_ioctl+0x12c/0x930 net/atm/ioctl.c:159
sock_do_ioctl+0x118/0x280 net/socket.c:1190
sock_ioctl+0x227/0x6b0 net/socket.c:1311
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:907 [inline]
__se_sys_ioctl fs/ioctl.c:893 [inline]
__x64_sys_ioctl+0x18e/0x210 fs/ioctl.c:893
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xcd/0x4c0 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Freed by task 6132:
kasan_save_stack+0x33/0x60 mm/kasan/common.c:47
kasan_save_track+0x14/0x30 mm/kasan/common.c:68
kasan_save_free_info+0x3b/0x60 mm/kasan/generic.c:576
poison_slab_object mm/kasan/common.c:247 [inline]
__kasan_slab_free+0x51/0x70 mm/kasan/common.c:264
kasan_slab_free include/linux/kasan.h:233 [inline]
slab_free_hook mm/slub.c:2381 [inline]
slab_free mm/slub.c:4643 [inline]
kfree+0x2b4/0x4d0 mm/slub.c:4842
free_netdev+0x6c5/0x910 net/core/dev.c:11892
lecd_attach net/atm/lec.c:744 [inline]
lane_ioctl+0x1ce8/0x23e0 net/atm/lec.c:1008
do_vcc_ioctl+0x12c/0x930 net/atm/ioctl.c:159
sock_do_ioctl+0x118/0x280 net/socket.c:1190
sock_ioctl+0x227/0x6b0 net/socket.c:1311
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:907 [inline]
__se_sys_ioctl fs/ioctl.c:893 [inline]
__x64_sys_ioctl+0x18e/0x210 fs/ioctl.c:893
Fixes: da177e4c3f41 ("Linux-2.6.12-rc2")
Reported-by: syzbot+8b64dec3affaed7b3af5@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/netdev/6852c6f6.050a0220.216029.0018.GAE@google.com/T/#u
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
net/atm/lec.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/net/atm/lec.c b/net/atm/lec.c
index acef984f3367094ec6d30419166b8462c88181b3..1e1f3eb0e2ba3cc1caa52e49327cecb8d18250e7 100644
--- a/net/atm/lec.c
+++ b/net/atm/lec.c
@@ -124,6 +124,7 @@ static unsigned char bus_mac[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
/* Device structures */
static struct net_device *dev_lec[MAX_LEC_ITF];
+static DEFINE_MUTEX(lec_mutex);
#if IS_ENABLED(CONFIG_BRIDGE)
static void lec_handle_bridge(struct sk_buff *skb, struct net_device *dev)
@@ -685,6 +686,7 @@ static int lec_vcc_attach(struct atm_vcc *vcc, void __user *arg)
int bytes_left;
struct atmlec_ioc ioc_data;
+ lockdep_assert_held(&lec_mutex);
/* Lecd must be up in this case */
bytes_left = copy_from_user(&ioc_data, arg, sizeof(struct atmlec_ioc));
if (bytes_left != 0)
@@ -710,6 +712,7 @@ static int lec_vcc_attach(struct atm_vcc *vcc, void __user *arg)
static int lec_mcast_attach(struct atm_vcc *vcc, int arg)
{
+ lockdep_assert_held(&lec_mutex);
if (arg < 0 || arg >= MAX_LEC_ITF)
return -EINVAL;
arg = array_index_nospec(arg, MAX_LEC_ITF);
@@ -725,6 +728,7 @@ static int lecd_attach(struct atm_vcc *vcc, int arg)
int i;
struct lec_priv *priv;
+ lockdep_assert_held(&lec_mutex);
if (arg < 0)
arg = 0;
if (arg >= MAX_LEC_ITF)
@@ -742,6 +746,7 @@ static int lecd_attach(struct atm_vcc *vcc, int arg)
snprintf(dev_lec[i]->name, IFNAMSIZ, "lec%d", i);
if (register_netdev(dev_lec[i])) {
free_netdev(dev_lec[i]);
+ dev_lec[i] = NULL;
return -EINVAL;
}
@@ -1003,6 +1008,7 @@ static int lane_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
return -ENOIOCTLCMD;
}
+ mutex_lock(&lec_mutex);
switch (cmd) {
case ATMLEC_CTRL:
err = lecd_attach(vcc, (int)arg);
@@ -1017,6 +1023,7 @@ static int lane_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
break;
}
+ mutex_unlock(&lec_mutex);
return err;
}
--
2.50.0.rc2.696.g1fc2a0284f-goog
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net 2/2] net: atm: fix /proc/net/atm/lec handling
2025-06-18 14:08 [PATCH net 0/2] net: atm: protect dev_lec[] with a mutex Eric Dumazet
2025-06-18 14:08 ` [PATCH net 1/2] net: atm: add lec_mutex Eric Dumazet
@ 2025-06-18 14:08 ` Eric Dumazet
2025-06-18 23:43 ` Francois Romieu
2025-06-19 15:40 ` [PATCH net 0/2] net: atm: protect dev_lec[] with a mutex patchwork-bot+netdevbpf
2 siblings, 1 reply; 6+ messages in thread
From: Eric Dumazet @ 2025-06-18 14:08 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, netdev, eric.dumazet, Eric Dumazet
/proc/net/atm/lec must ensure safety against dev_lec[] changes.
It appears it had dev_put() calls without prior dev_hold(),
leading to imbalance and UAF.
Fixes: da177e4c3f41 ("Linux-2.6.12-rc2")
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
net/atm/lec.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/net/atm/lec.c b/net/atm/lec.c
index 1e1f3eb0e2ba3cc1caa52e49327cecb8d18250e7..afb8d3eb2185078eb994e70c67d581e6dd96a452 100644
--- a/net/atm/lec.c
+++ b/net/atm/lec.c
@@ -909,7 +909,6 @@ static void *lec_itf_walk(struct lec_state *state, loff_t *l)
v = (dev && netdev_priv(dev)) ?
lec_priv_walk(state, l, netdev_priv(dev)) : NULL;
if (!v && dev) {
- dev_put(dev);
/* Partial state reset for the next time we get called */
dev = NULL;
}
@@ -933,6 +932,7 @@ static void *lec_seq_start(struct seq_file *seq, loff_t *pos)
{
struct lec_state *state = seq->private;
+ mutex_lock(&lec_mutex);
state->itf = 0;
state->dev = NULL;
state->locked = NULL;
@@ -950,8 +950,9 @@ static void lec_seq_stop(struct seq_file *seq, void *v)
if (state->dev) {
spin_unlock_irqrestore(&state->locked->lec_arp_lock,
state->flags);
- dev_put(state->dev);
+ state->dev = NULL;
}
+ mutex_unlock(&lec_mutex);
}
static void *lec_seq_next(struct seq_file *seq, void *v, loff_t *pos)
--
2.50.0.rc2.696.g1fc2a0284f-goog
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net 2/2] net: atm: fix /proc/net/atm/lec handling
2025-06-18 14:08 ` [PATCH net 2/2] net: atm: fix /proc/net/atm/lec handling Eric Dumazet
@ 2025-06-18 23:43 ` Francois Romieu
2025-06-19 2:37 ` Eric Dumazet
0 siblings, 1 reply; 6+ messages in thread
From: Francois Romieu @ 2025-06-18 23:43 UTC (permalink / raw)
To: Eric Dumazet
Cc: David S . Miller, Jakub Kicinski, Paolo Abeni, Simon Horman,
netdev, eric.dumazet
Eric Dumazet <edumazet@google.com> :
> /proc/net/atm/lec must ensure safety against dev_lec[] changes.
>
> It appears it had dev_put() calls without prior dev_hold(),
> leading to imbalance and UAF.
>
> Fixes: da177e4c3f41 ("Linux-2.6.12-rc2")
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> ---
> net/atm/lec.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/net/atm/lec.c b/net/atm/lec.c
> index 1e1f3eb0e2ba3cc1caa52e49327cecb8d18250e7..afb8d3eb2185078eb994e70c67d581e6dd96a452 100644
> --- a/net/atm/lec.c
> +++ b/net/atm/lec.c
Acked-by: Francois Romieu <romieu@fr.zoreil.com> # Minor atm contributor
While moving proc handling code from net/atm/proc.c to net/atm/lec.c after
seq_file conversion back in september 2003, there was a misguided change
turning:
dev = state->dev ? state->dev : atm_lane_ops->get_lec(state->itf);
into:
dev = state->dev ? state->dev : dev_lec[state->itf];
.get_lec included dev_hold. I didn't notice the change :/
--
Ueimor
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net 2/2] net: atm: fix /proc/net/atm/lec handling
2025-06-18 23:43 ` Francois Romieu
@ 2025-06-19 2:37 ` Eric Dumazet
0 siblings, 0 replies; 6+ messages in thread
From: Eric Dumazet @ 2025-06-19 2:37 UTC (permalink / raw)
To: Francois Romieu
Cc: David S . Miller, Jakub Kicinski, Paolo Abeni, Simon Horman,
netdev, eric.dumazet
On Wed, Jun 18, 2025 at 4:43 PM Francois Romieu <romieu@fr.zoreil.com> wrote:
>
> Eric Dumazet <edumazet@google.com> :
> > /proc/net/atm/lec must ensure safety against dev_lec[] changes.
> >
> > It appears it had dev_put() calls without prior dev_hold(),
> > leading to imbalance and UAF.
> >
> > Fixes: da177e4c3f41 ("Linux-2.6.12-rc2")
> > Signed-off-by: Eric Dumazet <edumazet@google.com>
> > ---
> > net/atm/lec.c | 5 +++--
> > 1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/net/atm/lec.c b/net/atm/lec.c
> > index 1e1f3eb0e2ba3cc1caa52e49327cecb8d18250e7..afb8d3eb2185078eb994e70c67d581e6dd96a452 100644
> > --- a/net/atm/lec.c
> > +++ b/net/atm/lec.c
>
> Acked-by: Francois Romieu <romieu@fr.zoreil.com> # Minor atm contributor
>
> While moving proc handling code from net/atm/proc.c to net/atm/lec.c after
> seq_file conversion back in september 2003, there was a misguided change
> turning:
>
> dev = state->dev ? state->dev : atm_lane_ops->get_lec(state->itf);
>
> into:
>
> dev = state->dev ? state->dev : dev_lec[state->itf];
>
> .get_lec included dev_hold. I didn't notice the change :/
Thanks for doing the archeology work.
Indeed, this came with this change recorded in (
https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git )
commit 4aea2cbff4174dc81a3f7f8a0e07fea75333f8ff
Author: Chas Williams <chas@cmf.nrl.navy.mil>
Date: Thu Sep 25 07:15:41 2003 -0700
[ATM]: Move lan seq_file ops to lec.c [1/3]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net 0/2] net: atm: protect dev_lec[] with a mutex
2025-06-18 14:08 [PATCH net 0/2] net: atm: protect dev_lec[] with a mutex Eric Dumazet
2025-06-18 14:08 ` [PATCH net 1/2] net: atm: add lec_mutex Eric Dumazet
2025-06-18 14:08 ` [PATCH net 2/2] net: atm: fix /proc/net/atm/lec handling Eric Dumazet
@ 2025-06-19 15:40 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-06-19 15:40 UTC (permalink / raw)
To: Eric Dumazet; +Cc: davem, kuba, pabeni, horms, netdev, eric.dumazet
Hello:
This series was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Wed, 18 Jun 2025 14:08:42 +0000 you wrote:
> Based on an initial syzbot report.
>
> First patch is adding lec_mutex to address the report.
>
> Second patch protects /proc/net/atm/lec operations.
>
> We probably should delete this driver, it seems quite broken.
>
> [...]
Here is the summary with links:
- [net,1/2] net: atm: add lec_mutex
https://git.kernel.org/netdev/net/c/d13a3824bfd2
- [net,2/2] net: atm: fix /proc/net/atm/lec handling
https://git.kernel.org/netdev/net/c/d03b79f459c7
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-06-19 15:39 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-18 14:08 [PATCH net 0/2] net: atm: protect dev_lec[] with a mutex Eric Dumazet
2025-06-18 14:08 ` [PATCH net 1/2] net: atm: add lec_mutex Eric Dumazet
2025-06-18 14:08 ` [PATCH net 2/2] net: atm: fix /proc/net/atm/lec handling Eric Dumazet
2025-06-18 23:43 ` Francois Romieu
2025-06-19 2:37 ` Eric Dumazet
2025-06-19 15:40 ` [PATCH net 0/2] net: atm: protect dev_lec[] with a mutex patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).