[syzbot] memory leak in do_replace

11 views
Skip to first unread message

syzbot

unread,
Sep 19, 2022, 7:27:39 PM9/19/22
to bri...@lists.linux-foundation.org, core...@netfilter.org, da...@davemloft.net, edum...@google.com, f...@strlen.de, kad...@netfilter.org, ku...@kernel.org, linux-...@vger.kernel.org, net...@vger.kernel.org, netfilt...@vger.kernel.org, pab...@redhat.com, pa...@netfilter.org, ra...@blackwall.org, ro...@nvidia.com, syzkall...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 3245cb65fd91 Merge tag 'devicetree-fixes-for-6.0-2' of git..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=17a88ef7080000
kernel config: https://syzkaller.appspot.com/x/.config?x=a4afe4efcad47dde
dashboard link: https://syzkaller.appspot.com/bug?extid=a24c5252f3e3ab733464
compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=14b0e87f080000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1100f1d8880000

Downloadable assets:
disk image: https://storage.googleapis.com/2d6c9d59c55a/disk-3245cb65.raw.xz
vmlinux: https://storage.googleapis.com/0f52632026ad/vmlinux-3245cb65.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+a24c52...@syzkaller.appspotmail.com

executing program
executing program
executing program
executing program
BUG: memory leak
unreferenced object 0xffffc90000ded000 (size 4096):
comm "syz-executor317", pid 3615, jiffies 4294946120 (age 22.550s)
hex dump (first 32 bytes):
90 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 00 00 00 00 00 00 ................
backtrace:
[<ffffffff8153105f>] __vmalloc_node_range+0xb3f/0xbd0 mm/vmalloc.c:3224
[<ffffffff81531239>] __vmalloc_node mm/vmalloc.c:3261 [inline]
[<ffffffff81531239>] __vmalloc+0x49/0x50 mm/vmalloc.c:3275
[<ffffffff83e28027>] do_replace+0x197/0x340 net/bridge/netfilter/ebtables.c:1131
[<ffffffff83e2880c>] do_ebt_set_ctl+0x22c/0x310 net/bridge/netfilter/ebtables.c:2520
[<ffffffff83a3fb68>] nf_setsockopt+0x68/0xa0 net/netfilter/nf_sockopt.c:101
[<ffffffff83bb5d69>] ip_setsockopt+0x259/0x2040 net/ipv4/ip_sockglue.c:1444
[<ffffffff83bcbe10>] tcp_setsockopt+0x70/0x1430 net/ipv4/tcp.c:3789
[<ffffffff8425d1d8>] smc_setsockopt+0xd8/0x5c0 net/smc/af_smc.c:2941
[<ffffffff8386dd2b>] __sys_setsockopt+0x1ab/0x380 net/socket.c:2252
[<ffffffff8386df22>] __do_sys_setsockopt net/socket.c:2263 [inline]
[<ffffffff8386df22>] __se_sys_setsockopt net/socket.c:2260 [inline]
[<ffffffff8386df22>] __x64_sys_setsockopt+0x22/0x30 net/socket.c:2260
[<ffffffff845eab35>] do_syscall_x64 arch/x86/entry/common.c:50 [inline]
[<ffffffff845eab35>] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
[<ffffffff84800087>] entry_SYSCALL_64_after_hwframe+0x63/0xcd

BUG: memory leak
unreferenced object 0xffffc90000df5000 (size 4096):
comm "syz-executor317", pid 3615, jiffies 4294946120 (age 22.550s)
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 00 00 00 00 00 00 00 ................
backtrace:
[<ffffffff8153105f>] __vmalloc_node_range+0xb3f/0xbd0 mm/vmalloc.c:3224
[<ffffffff81531239>] __vmalloc_node mm/vmalloc.c:3261 [inline]
[<ffffffff81531239>] __vmalloc+0x49/0x50 mm/vmalloc.c:3275
[<ffffffff83e28071>] do_replace+0x1e1/0x340 net/bridge/netfilter/ebtables.c:1138
[<ffffffff83e2880c>] do_ebt_set_ctl+0x22c/0x310 net/bridge/netfilter/ebtables.c:2520
[<ffffffff83a3fb68>] nf_setsockopt+0x68/0xa0 net/netfilter/nf_sockopt.c:101
[<ffffffff83bb5d69>] ip_setsockopt+0x259/0x2040 net/ipv4/ip_sockglue.c:1444
[<ffffffff83bcbe10>] tcp_setsockopt+0x70/0x1430 net/ipv4/tcp.c:3789
[<ffffffff8425d1d8>] smc_setsockopt+0xd8/0x5c0 net/smc/af_smc.c:2941
[<ffffffff8386dd2b>] __sys_setsockopt+0x1ab/0x380 net/socket.c:2252
[<ffffffff8386df22>] __do_sys_setsockopt net/socket.c:2263 [inline]
[<ffffffff8386df22>] __se_sys_setsockopt net/socket.c:2260 [inline]
[<ffffffff8386df22>] __x64_sys_setsockopt+0x22/0x30 net/socket.c:2260
[<ffffffff845eab35>] do_syscall_x64 arch/x86/entry/common.c:50 [inline]
[<ffffffff845eab35>] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
[<ffffffff84800087>] entry_SYSCALL_64_after_hwframe+0x63/0xcd



---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
syzbot can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches

syzbot

unread,
Sep 20, 2022, 2:46:18 AM9/20/22
to f...@strlen.de, syzkall...@googlegroups.com
Hello,

syzbot tried to test the proposed patch but the build/boot failed:

net/bridge/netfilter/ebtables.c:1044:16: error: expected ';' before ':' token


Tested on:

commit: 521a547c Linux 6.0-rc6
git tree: upstream
dashboard link: https://syzkaller.appspot.com/bug?extid=a24c5252f3e3ab733464
compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
patch: https://syzkaller.appspot.com/x/patch.diff?x=17bf760f080000

syzbot

unread,
Sep 20, 2022, 3:22:25 AM9/20/22
to f...@strlen.de, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-and-tested-by: syzbot+a24c52...@syzkaller.appspotmail.com

Tested on:

commit: 521a547c Linux 6.0-rc6
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=12c5d56f080000
kernel config: https://syzkaller.appspot.com/x/.config?x=3a17ef673fa12765
dashboard link: https://syzkaller.appspot.com/bug?extid=a24c5252f3e3ab733464
compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
patch: https://syzkaller.appspot.com/x/patch.diff?x=15d24a54880000

Note: testing is done by a robot and is best-effort only.

Florian Westphal

unread,
Sep 20, 2022, 8:20:28 AM9/20/22
to netfilt...@vger.kernel.org, syzkall...@googlegroups.com, Florian Westphal, syzbot+a24c52...@syzkaller.appspotmail.com
The bug fix was incomplete, it "replaced" crash with a memory leak.
The old code had an assignment to "ret" embedded into the conditional,
restore this.

Fixes: 7997eff82828 ("netfilter: ebtables: reject blobs that don't provide all entry points")
Reported-and-tested-by: syzbot+a24c52...@syzkaller.appspotmail.com
Signed-off-by: Florian Westphal <f...@strlen.de>
---
net/bridge/netfilter/ebtables.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
index 8f6639e095a0..c4af063c0c8f 100644
--- a/net/bridge/netfilter/ebtables.c
+++ b/net/bridge/netfilter/ebtables.c
@@ -1040,8 +1040,10 @@ static int do_replace_finish(struct net *net, struct ebt_replace *repl,
goto free_iterate;
}

- if (repl->valid_hooks != t->valid_hooks)
+ if (repl->valid_hooks != t->valid_hooks) {
+ ret = -EINVAL;
goto free_unlock;
+ }

if (repl->num_counters && repl->num_counters != t->private->nentries) {
ret = -EINVAL;
--
2.18.1

Reply all
Reply to author
Forward
0 new messages