* [PATCH net] net: sched: act_ctinfo: fix memory leak
@ 2020-01-19 4:45 Eric Dumazet
2020-01-19 6:56 ` Kevin 'ldir' Darbyshire-Bryant
2020-01-19 15:03 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Eric Dumazet @ 2020-01-19 4:45 UTC (permalink / raw)
To: David S . Miller
Cc: netdev, Eric Dumazet, Eric Dumazet, syzbot,
Kevin 'ldir' Darbyshire-Bryant, Cong Wang,
Toke Høiland-Jørgensen
Implement a cleanup method to properly free ci->params
BUG: memory leak
unreferenced object 0xffff88811746e2c0 (size 64):
comm "syz-executor617", pid 7106, jiffies 4294943055 (age 14.250s)
hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
c0 34 60 84 ff ff ff ff 00 00 00 00 00 00 00 00 .4`.............
backtrace:
[<0000000015aa236f>] kmemleak_alloc_recursive include/linux/kmemleak.h:43 [inline]
[<0000000015aa236f>] slab_post_alloc_hook mm/slab.h:586 [inline]
[<0000000015aa236f>] slab_alloc mm/slab.c:3320 [inline]
[<0000000015aa236f>] kmem_cache_alloc_trace+0x145/0x2c0 mm/slab.c:3549
[<000000002c946bd1>] kmalloc include/linux/slab.h:556 [inline]
[<000000002c946bd1>] kzalloc include/linux/slab.h:670 [inline]
[<000000002c946bd1>] tcf_ctinfo_init+0x21a/0x530 net/sched/act_ctinfo.c:236
[<0000000086952cca>] tcf_action_init_1+0x400/0x5b0 net/sched/act_api.c:944
[<000000005ab29bf8>] tcf_action_init+0x135/0x1c0 net/sched/act_api.c:1000
[<00000000392f56f9>] tcf_action_add+0x9a/0x200 net/sched/act_api.c:1410
[<0000000088f3c5dd>] tc_ctl_action+0x14d/0x1bb net/sched/act_api.c:1465
[<000000006b39d986>] rtnetlink_rcv_msg+0x178/0x4b0 net/core/rtnetlink.c:5424
[<00000000fd6ecace>] netlink_rcv_skb+0x61/0x170 net/netlink/af_netlink.c:2477
[<0000000047493d02>] rtnetlink_rcv+0x1d/0x30 net/core/rtnetlink.c:5442
[<00000000bdcf8286>] netlink_unicast_kernel net/netlink/af_netlink.c:1302 [inline]
[<00000000bdcf8286>] netlink_unicast+0x223/0x310 net/netlink/af_netlink.c:1328
[<00000000fc5b92d9>] netlink_sendmsg+0x2c0/0x570 net/netlink/af_netlink.c:1917
[<00000000da84d076>] sock_sendmsg_nosec net/socket.c:639 [inline]
[<00000000da84d076>] sock_sendmsg+0x54/0x70 net/socket.c:659
[<0000000042fb2eee>] ____sys_sendmsg+0x2d0/0x300 net/socket.c:2330
[<000000008f23f67e>] ___sys_sendmsg+0x8a/0xd0 net/socket.c:2384
[<00000000d838e4f6>] __sys_sendmsg+0x80/0xf0 net/socket.c:2417
[<00000000289a9cb1>] __do_sys_sendmsg net/socket.c:2426 [inline]
[<00000000289a9cb1>] __se_sys_sendmsg net/socket.c:2424 [inline]
[<00000000289a9cb1>] __x64_sys_sendmsg+0x23/0x30 net/socket.c:2424
Fixes: 24ec483cec98 ("net: sched: Introduce act_ctinfo action")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: syzbot <syzkaller@googlegroups.com>
Cc: Kevin 'ldir' Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
Cc: Cong Wang <xiyou.wangcong@gmail.com>
Cc: Toke Høiland-Jørgensen <toke@redhat.com>
---
net/sched/act_ctinfo.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/net/sched/act_ctinfo.c b/net/sched/act_ctinfo.c
index 40038c321b4a970dc940714ccda4b39f0d261d6a..19649623493b158b3008c82ce2409ae80ffa6dc6 100644
--- a/net/sched/act_ctinfo.c
+++ b/net/sched/act_ctinfo.c
@@ -360,6 +360,16 @@ static int tcf_ctinfo_search(struct net *net, struct tc_action **a, u32 index)
return tcf_idr_search(tn, a, index);
}
+static void tcf_ctinfo_cleanup(struct tc_action *a)
+{
+ struct tcf_ctinfo *ci = to_ctinfo(a);
+ struct tcf_ctinfo_params *cp;
+
+ cp = rcu_dereference_protected(ci->params, 1);
+ if (cp)
+ kfree_rcu(cp, rcu);
+}
+
static struct tc_action_ops act_ctinfo_ops = {
.kind = "ctinfo",
.id = TCA_ID_CTINFO,
@@ -367,6 +377,7 @@ static struct tc_action_ops act_ctinfo_ops = {
.act = tcf_ctinfo_act,
.dump = tcf_ctinfo_dump,
.init = tcf_ctinfo_init,
+ .cleanup= tcf_ctinfo_cleanup,
.walk = tcf_ctinfo_walker,
.lookup = tcf_ctinfo_search,
.size = sizeof(struct tcf_ctinfo),
--
2.25.0.341.g760bfbb309-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net] net: sched: act_ctinfo: fix memory leak
2020-01-19 4:45 [PATCH net] net: sched: act_ctinfo: fix memory leak Eric Dumazet
@ 2020-01-19 6:56 ` Kevin 'ldir' Darbyshire-Bryant
2020-01-19 15:03 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Kevin 'ldir' Darbyshire-Bryant @ 2020-01-19 6:56 UTC (permalink / raw)
To: Eric Dumazet
Cc: David S . Miller, netdev, Eric Dumazet, syzbot, Cong Wang,
Toke Høiland-Jørgensen
[-- Attachment #1: Type: text/plain, Size: 4070 bytes --]
> On 19 Jan 2020, at 04:45, Eric Dumazet <edumazet@google.com> wrote:
>
> Implement a cleanup method to properly free ci->params
>
> BUG: memory leak
> unreferenced object 0xffff88811746e2c0 (size 64):
> comm "syz-executor617", pid 7106, jiffies 4294943055 (age 14.250s)
> hex dump (first 32 bytes):
> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> c0 34 60 84 ff ff ff ff 00 00 00 00 00 00 00 00 .4`.............
> backtrace:
> [<0000000015aa236f>] kmemleak_alloc_recursive include/linux/kmemleak.h:43 [inline]
> [<0000000015aa236f>] slab_post_alloc_hook mm/slab.h:586 [inline]
> [<0000000015aa236f>] slab_alloc mm/slab.c:3320 [inline]
> [<0000000015aa236f>] kmem_cache_alloc_trace+0x145/0x2c0 mm/slab.c:3549
> [<000000002c946bd1>] kmalloc include/linux/slab.h:556 [inline]
> [<000000002c946bd1>] kzalloc include/linux/slab.h:670 [inline]
> [<000000002c946bd1>] tcf_ctinfo_init+0x21a/0x530 net/sched/act_ctinfo.c:236
> [<0000000086952cca>] tcf_action_init_1+0x400/0x5b0 net/sched/act_api.c:944
> [<000000005ab29bf8>] tcf_action_init+0x135/0x1c0 net/sched/act_api.c:1000
> [<00000000392f56f9>] tcf_action_add+0x9a/0x200 net/sched/act_api.c:1410
> [<0000000088f3c5dd>] tc_ctl_action+0x14d/0x1bb net/sched/act_api.c:1465
> [<000000006b39d986>] rtnetlink_rcv_msg+0x178/0x4b0 net/core/rtnetlink.c:5424
> [<00000000fd6ecace>] netlink_rcv_skb+0x61/0x170 net/netlink/af_netlink.c:2477
> [<0000000047493d02>] rtnetlink_rcv+0x1d/0x30 net/core/rtnetlink.c:5442
> [<00000000bdcf8286>] netlink_unicast_kernel net/netlink/af_netlink.c:1302 [inline]
> [<00000000bdcf8286>] netlink_unicast+0x223/0x310 net/netlink/af_netlink.c:1328
> [<00000000fc5b92d9>] netlink_sendmsg+0x2c0/0x570 net/netlink/af_netlink.c:1917
> [<00000000da84d076>] sock_sendmsg_nosec net/socket.c:639 [inline]
> [<00000000da84d076>] sock_sendmsg+0x54/0x70 net/socket.c:659
> [<0000000042fb2eee>] ____sys_sendmsg+0x2d0/0x300 net/socket.c:2330
> [<000000008f23f67e>] ___sys_sendmsg+0x8a/0xd0 net/socket.c:2384
> [<00000000d838e4f6>] __sys_sendmsg+0x80/0xf0 net/socket.c:2417
> [<00000000289a9cb1>] __do_sys_sendmsg net/socket.c:2426 [inline]
> [<00000000289a9cb1>] __se_sys_sendmsg net/socket.c:2424 [inline]
> [<00000000289a9cb1>] __x64_sys_sendmsg+0x23/0x30 net/socket.c:2424
>
> Fixes: 24ec483cec98 ("net: sched: Introduce act_ctinfo action")
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Reported-by: syzbot <syzkaller@googlegroups.com>
> Cc: Kevin 'ldir' Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
> Cc: Cong Wang <xiyou.wangcong@gmail.com>
> Cc: Toke Høiland-Jørgensen <toke@redhat.com>
> ---
> net/sched/act_ctinfo.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/net/sched/act_ctinfo.c b/net/sched/act_ctinfo.c
> index 40038c321b4a970dc940714ccda4b39f0d261d6a..19649623493b158b3008c82ce2409ae80ffa6dc6 100644
> --- a/net/sched/act_ctinfo.c
> +++ b/net/sched/act_ctinfo.c
> @@ -360,6 +360,16 @@ static int tcf_ctinfo_search(struct net *net, struct tc_action **a, u32 index)
> return tcf_idr_search(tn, a, index);
> }
>
> +static void tcf_ctinfo_cleanup(struct tc_action *a)
> +{
> + struct tcf_ctinfo *ci = to_ctinfo(a);
> + struct tcf_ctinfo_params *cp;
> +
> + cp = rcu_dereference_protected(ci->params, 1);
> + if (cp)
> + kfree_rcu(cp, rcu);
> +}
> +
> static struct tc_action_ops act_ctinfo_ops = {
> .kind = "ctinfo",
> .id = TCA_ID_CTINFO,
> @@ -367,6 +377,7 @@ static struct tc_action_ops act_ctinfo_ops = {
> .act = tcf_ctinfo_act,
> .dump = tcf_ctinfo_dump,
> .init = tcf_ctinfo_init,
> + .cleanup= tcf_ctinfo_cleanup,
> .walk = tcf_ctinfo_walker,
> .lookup = tcf_ctinfo_search,
> .size = sizeof(struct tcf_ctinfo),
> --
> 2.25.0.341.g760bfbb309-goog
>
Oh wow & oops! Thanks for fixing that.
Acked-by: Kevin 'ldir' Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
Cheers,
Kevin D-B
gpg: 012C ACB2 28C6 C53E 9775 9123 B3A2 389B 9DE2 334A
[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] net: sched: act_ctinfo: fix memory leak
2020-01-19 4:45 [PATCH net] net: sched: act_ctinfo: fix memory leak Eric Dumazet
2020-01-19 6:56 ` Kevin 'ldir' Darbyshire-Bryant
@ 2020-01-19 15:03 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2020-01-19 15:03 UTC (permalink / raw)
To: edumazet; +Cc: netdev, eric.dumazet, syzkaller, ldir, xiyou.wangcong, toke
From: Eric Dumazet <edumazet@google.com>
Date: Sat, 18 Jan 2020 20:45:06 -0800
> Implement a cleanup method to properly free ci->params
...
> Fixes: 24ec483cec98 ("net: sched: Introduce act_ctinfo action")
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Reported-by: syzbot <syzkaller@googlegroups.com>
Applied and queued up for -stable, thanks Eric.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-01-19 15:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-19 4:45 [PATCH net] net: sched: act_ctinfo: fix memory leak Eric Dumazet
2020-01-19 6:56 ` Kevin 'ldir' Darbyshire-Bryant
2020-01-19 15:03 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.