* [PATCH net] netrom: Fix memory leak in nr_sendmsg()
@ 2025-11-29 4:13 Wang Liang
2025-12-04 10:10 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Wang Liang @ 2025-11-29 4:13 UTC (permalink / raw)
To: davem, edumazet, kuba, pabeni, horms
Cc: linux-hams, netdev, linux-kernel, yuehaibing, zhangchangzhong,
wangliang74
syzbot reported a memory leak [1].
When function sock_alloc_send_skb() return NULL in nr_output(), the
original skb is not freed, which was allocated in nr_sendmsg(). Fix this
by freeing it before return.
[1]
BUG: memory leak
unreferenced object 0xffff888129f35500 (size 240):
comm "syz.0.17", pid 6119, jiffies 4294944652
hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 10 52 28 81 88 ff ff ..........R(....
backtrace (crc 1456a3e4):
kmemleak_alloc_recursive include/linux/kmemleak.h:44 [inline]
slab_post_alloc_hook mm/slub.c:4983 [inline]
slab_alloc_node mm/slub.c:5288 [inline]
kmem_cache_alloc_node_noprof+0x36f/0x5e0 mm/slub.c:5340
__alloc_skb+0x203/0x240 net/core/skbuff.c:660
alloc_skb include/linux/skbuff.h:1383 [inline]
alloc_skb_with_frags+0x69/0x3f0 net/core/skbuff.c:6671
sock_alloc_send_pskb+0x379/0x3e0 net/core/sock.c:2965
sock_alloc_send_skb include/net/sock.h:1859 [inline]
nr_sendmsg+0x287/0x450 net/netrom/af_netrom.c:1105
sock_sendmsg_nosec net/socket.c:727 [inline]
__sock_sendmsg net/socket.c:742 [inline]
sock_write_iter+0x293/0x2a0 net/socket.c:1195
new_sync_write fs/read_write.c:593 [inline]
vfs_write+0x45d/0x710 fs/read_write.c:686
ksys_write+0x143/0x170 fs/read_write.c:738
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xa4/0xfa0 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Reported-by: syzbot+d7abc36bbbb6d7d40b58@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=d7abc36bbbb6d7d40b58
Tested-by: syzbot+d7abc36bbbb6d7d40b58@syzkaller.appspotmail.com
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Wang Liang <wangliang74@huawei.com>
---
net/netrom/nr_out.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/netrom/nr_out.c b/net/netrom/nr_out.c
index 5e531394a724..2b3cbceb0b52 100644
--- a/net/netrom/nr_out.c
+++ b/net/netrom/nr_out.c
@@ -43,8 +43,10 @@ void nr_output(struct sock *sk, struct sk_buff *skb)
frontlen = skb_headroom(skb);
while (skb->len > 0) {
- if ((skbn = sock_alloc_send_skb(sk, frontlen + NR_MAX_PACKET_SIZE, 0, &err)) == NULL)
+ if ((skbn = sock_alloc_send_skb(sk, frontlen + NR_MAX_PACKET_SIZE, 0, &err)) == NULL) {
+ kfree_skb(skb);
return;
+ }
skb_reserve(skbn, frontlen);
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH net] netrom: Fix memory leak in nr_sendmsg()
2025-11-29 4:13 [PATCH net] netrom: Fix memory leak in nr_sendmsg() Wang Liang
@ 2025-12-04 10:10 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-12-04 10:10 UTC (permalink / raw)
To: Wang Liang
Cc: davem, edumazet, kuba, pabeni, horms, linux-hams, netdev,
linux-kernel, yuehaibing, zhangchangzhong
Hello:
This patch was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:
On Sat, 29 Nov 2025 12:13:15 +0800 you wrote:
> syzbot reported a memory leak [1].
>
> When function sock_alloc_send_skb() return NULL in nr_output(), the
> original skb is not freed, which was allocated in nr_sendmsg(). Fix this
> by freeing it before return.
>
> [1]
> BUG: memory leak
> unreferenced object 0xffff888129f35500 (size 240):
> comm "syz.0.17", pid 6119, jiffies 4294944652
> hex dump (first 32 bytes):
> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> 00 00 00 00 00 00 00 00 00 10 52 28 81 88 ff ff ..........R(....
> backtrace (crc 1456a3e4):
> kmemleak_alloc_recursive include/linux/kmemleak.h:44 [inline]
> slab_post_alloc_hook mm/slub.c:4983 [inline]
> slab_alloc_node mm/slub.c:5288 [inline]
> kmem_cache_alloc_node_noprof+0x36f/0x5e0 mm/slub.c:5340
> __alloc_skb+0x203/0x240 net/core/skbuff.c:660
> alloc_skb include/linux/skbuff.h:1383 [inline]
> alloc_skb_with_frags+0x69/0x3f0 net/core/skbuff.c:6671
> sock_alloc_send_pskb+0x379/0x3e0 net/core/sock.c:2965
> sock_alloc_send_skb include/net/sock.h:1859 [inline]
> nr_sendmsg+0x287/0x450 net/netrom/af_netrom.c:1105
> sock_sendmsg_nosec net/socket.c:727 [inline]
> __sock_sendmsg net/socket.c:742 [inline]
> sock_write_iter+0x293/0x2a0 net/socket.c:1195
> new_sync_write fs/read_write.c:593 [inline]
> vfs_write+0x45d/0x710 fs/read_write.c:686
> ksys_write+0x143/0x170 fs/read_write.c:738
> do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
> do_syscall_64+0xa4/0xfa0 arch/x86/entry/syscall_64.c:94
> entry_SYSCALL_64_after_hwframe+0x77/0x7f
>
> [...]
Here is the summary with links:
- [net] netrom: Fix memory leak in nr_sendmsg()
https://git.kernel.org/netdev/net/c/613d12dd794e
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] 2+ messages in thread
end of thread, other threads:[~2025-12-04 10:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-29 4:13 [PATCH net] netrom: Fix memory leak in nr_sendmsg() Wang Liang
2025-12-04 10:10 ` 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