Message ID | 20210608015158.3848878-1-sunnanyong@huawei.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | net: ipv4: fix memory leak in netlbl_cipsov4_add_std | expand |
On Mon, Jun 7, 2021 at 9:19 PM Nanyong Sun <sunnanyong@huawei.com> wrote: > > Reported by syzkaller: > BUG: memory leak > unreferenced object 0xffff888105df7000 (size 64): > comm "syz-executor842", pid 360, jiffies 4294824824 (age 22.546s) > 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: > [<00000000e67ed558>] kmalloc include/linux/slab.h:590 [inline] > [<00000000e67ed558>] kzalloc include/linux/slab.h:720 [inline] > [<00000000e67ed558>] netlbl_cipsov4_add_std net/netlabel/netlabel_cipso_v4.c:145 [inline] > [<00000000e67ed558>] netlbl_cipsov4_add+0x390/0x2340 net/netlabel/netlabel_cipso_v4.c:416 > [<0000000006040154>] genl_family_rcv_msg_doit.isra.0+0x20e/0x320 net/netlink/genetlink.c:739 > [<00000000204d7a1c>] genl_family_rcv_msg net/netlink/genetlink.c:783 [inline] > [<00000000204d7a1c>] genl_rcv_msg+0x2bf/0x4f0 net/netlink/genetlink.c:800 > [<00000000c0d6a995>] netlink_rcv_skb+0x134/0x3d0 net/netlink/af_netlink.c:2504 > [<00000000d78b9d2c>] genl_rcv+0x24/0x40 net/netlink/genetlink.c:811 > [<000000009733081b>] netlink_unicast_kernel net/netlink/af_netlink.c:1314 [inline] > [<000000009733081b>] netlink_unicast+0x4a0/0x6a0 net/netlink/af_netlink.c:1340 > [<00000000d5fd43b8>] netlink_sendmsg+0x789/0xc70 net/netlink/af_netlink.c:1929 > [<000000000a2d1e40>] sock_sendmsg_nosec net/socket.c:654 [inline] > [<000000000a2d1e40>] sock_sendmsg+0x139/0x170 net/socket.c:674 > [<00000000321d1969>] ____sys_sendmsg+0x658/0x7d0 net/socket.c:2350 > [<00000000964e16bc>] ___sys_sendmsg+0xf8/0x170 net/socket.c:2404 > [<000000001615e288>] __sys_sendmsg+0xd3/0x190 net/socket.c:2433 > [<000000004ee8b6a5>] do_syscall_64+0x37/0x90 arch/x86/entry/common.c:47 > [<00000000171c7cee>] entry_SYSCALL_64_after_hwframe+0x44/0xae > > The memory of doi_def->map.std pointing is allocated in > netlbl_cipsov4_add_std, but no place has freed it. It should be > freed in cipso_v4_doi_free which frees the cipso DOI resource. > > Fixes: 96cb8e3313c7a ("[NetLabel]: CIPSOv4 and Unlabeled packet integration") > Reported-by: Hulk Robot <hulkci@huawei.com> > Signed-off-by: Nanyong Sun <sunnanyong@huawei.com> > --- > net/ipv4/cipso_ipv4.c | 1 + > 1 file changed, 1 insertion(+) Nice catch, thanks for fixing this. Acked-by: Paul Moore <paul@paul-moore.com> > diff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c > index d6e3a92841e3..099259fc826a 100644 > --- a/net/ipv4/cipso_ipv4.c > +++ b/net/ipv4/cipso_ipv4.c > @@ -471,6 +471,7 @@ void cipso_v4_doi_free(struct cipso_v4_doi *doi_def) > kfree(doi_def->map.std->lvl.local); > kfree(doi_def->map.std->cat.cipso); > kfree(doi_def->map.std->cat.local); > + kfree(doi_def->map.std); > break; > } > kfree(doi_def); > -- > 2.18.0.huawei.25
On Tue, Jun 8, 2021 at 9:57 AM Paul Moore <paul@paul-moore.com> wrote: > > On Mon, Jun 7, 2021 at 9:19 PM Nanyong Sun <sunnanyong@huawei.com> wrote: > > > > Reported by syzkaller: > > BUG: memory leak > > unreferenced object 0xffff888105df7000 (size 64): > > comm "syz-executor842", pid 360, jiffies 4294824824 (age 22.546s) > > 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: > > [<00000000e67ed558>] kmalloc include/linux/slab.h:590 [inline] > > [<00000000e67ed558>] kzalloc include/linux/slab.h:720 [inline] > > [<00000000e67ed558>] netlbl_cipsov4_add_std net/netlabel/netlabel_cipso_v4.c:145 [inline] > > [<00000000e67ed558>] netlbl_cipsov4_add+0x390/0x2340 net/netlabel/netlabel_cipso_v4.c:416 > > [<0000000006040154>] genl_family_rcv_msg_doit.isra.0+0x20e/0x320 net/netlink/genetlink.c:739 > > [<00000000204d7a1c>] genl_family_rcv_msg net/netlink/genetlink.c:783 [inline] > > [<00000000204d7a1c>] genl_rcv_msg+0x2bf/0x4f0 net/netlink/genetlink.c:800 > > [<00000000c0d6a995>] netlink_rcv_skb+0x134/0x3d0 net/netlink/af_netlink.c:2504 > > [<00000000d78b9d2c>] genl_rcv+0x24/0x40 net/netlink/genetlink.c:811 > > [<000000009733081b>] netlink_unicast_kernel net/netlink/af_netlink.c:1314 [inline] > > [<000000009733081b>] netlink_unicast+0x4a0/0x6a0 net/netlink/af_netlink.c:1340 > > [<00000000d5fd43b8>] netlink_sendmsg+0x789/0xc70 net/netlink/af_netlink.c:1929 > > [<000000000a2d1e40>] sock_sendmsg_nosec net/socket.c:654 [inline] > > [<000000000a2d1e40>] sock_sendmsg+0x139/0x170 net/socket.c:674 > > [<00000000321d1969>] ____sys_sendmsg+0x658/0x7d0 net/socket.c:2350 > > [<00000000964e16bc>] ___sys_sendmsg+0xf8/0x170 net/socket.c:2404 > > [<000000001615e288>] __sys_sendmsg+0xd3/0x190 net/socket.c:2433 > > [<000000004ee8b6a5>] do_syscall_64+0x37/0x90 arch/x86/entry/common.c:47 > > [<00000000171c7cee>] entry_SYSCALL_64_after_hwframe+0x44/0xae > > > > The memory of doi_def->map.std pointing is allocated in > > netlbl_cipsov4_add_std, but no place has freed it. It should be > > freed in cipso_v4_doi_free which frees the cipso DOI resource. > > > > Fixes: 96cb8e3313c7a ("[NetLabel]: CIPSOv4 and Unlabeled packet integration") > > Reported-by: Hulk Robot <hulkci@huawei.com> > > Signed-off-by: Nanyong Sun <sunnanyong@huawei.com> > > --- > > net/ipv4/cipso_ipv4.c | 1 + > > 1 file changed, 1 insertion(+) > > Nice catch, thanks for fixing this. > > Acked-by: Paul Moore <paul@paul-moore.com> > > > diff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c > > index d6e3a92841e3..099259fc826a 100644 > > --- a/net/ipv4/cipso_ipv4.c > > +++ b/net/ipv4/cipso_ipv4.c > > @@ -471,6 +471,7 @@ void cipso_v4_doi_free(struct cipso_v4_doi *doi_def) > > kfree(doi_def->map.std->lvl.local); > > kfree(doi_def->map.std->cat.cipso); > > kfree(doi_def->map.std->cat.local); > > + kfree(doi_def->map.std); > > break; > > } > > kfree(doi_def); Hi kernel developers, I doubt this patch may cause invalid free in other functions where map.std is not allocated or initialized, such as netlbl_cipsov4_add_local, netlbl_cipsov4_add_pass. Take netlbl_cipsov4_add_pass as an example, any failure after the doi_def allocation failure will go to cipso_v4_doi_free, and free doi_def->map.std. static int netlbl_cipsov4_add_pass(struct genl_info *info, struct netlbl_audit *audit_info) { int ret_val; struct cipso_v4_doi *doi_def = NULL; if (!info->attrs[NLBL_CIPSOV4_A_TAGLST]) return -EINVAL; doi_def = kmalloc(sizeof(*doi_def), GFP_KERNEL); if (doi_def == NULL) return -ENOMEM; doi_def->type = CIPSO_V4_MAP_PASS; ret_val = netlbl_cipsov4_add_common(info, doi_def); if (ret_val != 0) goto add_pass_failure; ret_val = cipso_v4_doi_add(doi_def, audit_info); if (ret_val != 0) goto add_pass_failure; return 0; add_pass_failure: cipso_v4_doi_free(doi_def); return ret_val; } [1] https://elixir.bootlin.com/linux/latest/source/net/netlabel/netlabel_cipso_v4.c#L326 > > -- > > 2.18.0.huawei.25 > > -- > paul moore > www.paul-moore.com
On Tue, Jun 8, 2021 at 10:30 AM Dongliang Mu <mudongliangabcd@gmail.com> wrote: > > On Tue, Jun 8, 2021 at 9:57 AM Paul Moore <paul@paul-moore.com> wrote: > > > > On Mon, Jun 7, 2021 at 9:19 PM Nanyong Sun <sunnanyong@huawei.com> wrote: > > > > > > Reported by syzkaller: > > > BUG: memory leak > > > unreferenced object 0xffff888105df7000 (size 64): > > > comm "syz-executor842", pid 360, jiffies 4294824824 (age 22.546s) > > > 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: > > > [<00000000e67ed558>] kmalloc include/linux/slab.h:590 [inline] > > > [<00000000e67ed558>] kzalloc include/linux/slab.h:720 [inline] > > > [<00000000e67ed558>] netlbl_cipsov4_add_std net/netlabel/netlabel_cipso_v4.c:145 [inline] > > > [<00000000e67ed558>] netlbl_cipsov4_add+0x390/0x2340 net/netlabel/netlabel_cipso_v4.c:416 > > > [<0000000006040154>] genl_family_rcv_msg_doit.isra.0+0x20e/0x320 net/netlink/genetlink.c:739 > > > [<00000000204d7a1c>] genl_family_rcv_msg net/netlink/genetlink.c:783 [inline] > > > [<00000000204d7a1c>] genl_rcv_msg+0x2bf/0x4f0 net/netlink/genetlink.c:800 > > > [<00000000c0d6a995>] netlink_rcv_skb+0x134/0x3d0 net/netlink/af_netlink.c:2504 > > > [<00000000d78b9d2c>] genl_rcv+0x24/0x40 net/netlink/genetlink.c:811 > > > [<000000009733081b>] netlink_unicast_kernel net/netlink/af_netlink.c:1314 [inline] > > > [<000000009733081b>] netlink_unicast+0x4a0/0x6a0 net/netlink/af_netlink.c:1340 > > > [<00000000d5fd43b8>] netlink_sendmsg+0x789/0xc70 net/netlink/af_netlink.c:1929 > > > [<000000000a2d1e40>] sock_sendmsg_nosec net/socket.c:654 [inline] > > > [<000000000a2d1e40>] sock_sendmsg+0x139/0x170 net/socket.c:674 > > > [<00000000321d1969>] ____sys_sendmsg+0x658/0x7d0 net/socket.c:2350 > > > [<00000000964e16bc>] ___sys_sendmsg+0xf8/0x170 net/socket.c:2404 > > > [<000000001615e288>] __sys_sendmsg+0xd3/0x190 net/socket.c:2433 > > > [<000000004ee8b6a5>] do_syscall_64+0x37/0x90 arch/x86/entry/common.c:47 > > > [<00000000171c7cee>] entry_SYSCALL_64_after_hwframe+0x44/0xae > > > > > > The memory of doi_def->map.std pointing is allocated in > > > netlbl_cipsov4_add_std, but no place has freed it. It should be > > > freed in cipso_v4_doi_free which frees the cipso DOI resource. > > > > > > Fixes: 96cb8e3313c7a ("[NetLabel]: CIPSOv4 and Unlabeled packet integration") > > > Reported-by: Hulk Robot <hulkci@huawei.com> > > > Signed-off-by: Nanyong Sun <sunnanyong@huawei.com> > > > --- > > > net/ipv4/cipso_ipv4.c | 1 + > > > 1 file changed, 1 insertion(+) > > > > Nice catch, thanks for fixing this. > > > > Acked-by: Paul Moore <paul@paul-moore.com> > > > > > diff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c > > > index d6e3a92841e3..099259fc826a 100644 > > > --- a/net/ipv4/cipso_ipv4.c > > > +++ b/net/ipv4/cipso_ipv4.c > > > @@ -471,6 +471,7 @@ void cipso_v4_doi_free(struct cipso_v4_doi *doi_def) > > > kfree(doi_def->map.std->lvl.local); > > > kfree(doi_def->map.std->cat.cipso); > > > kfree(doi_def->map.std->cat.local); > > > + kfree(doi_def->map.std); > > > break; > > > } > > > kfree(doi_def); > > Hi kernel developers, > > I doubt this patch may cause invalid free in other functions where > map.std is not allocated or initialized, such as > netlbl_cipsov4_add_local, netlbl_cipsov4_add_pass. > > Take netlbl_cipsov4_add_pass as an example, any failure after the > doi_def allocation failure will go to cipso_v4_doi_free, and free > doi_def->map.std. Sorry for the false alarm. The new added kfree(doi_def->map.std) is under the condition - case CIPSO_V4_MAP_TRANS. So there will be not invalid free. Sorry about this. > > static int netlbl_cipsov4_add_pass(struct genl_info *info, > struct netlbl_audit *audit_info) > { > int ret_val; > struct cipso_v4_doi *doi_def = NULL; > > if (!info->attrs[NLBL_CIPSOV4_A_TAGLST]) > return -EINVAL; > > doi_def = kmalloc(sizeof(*doi_def), GFP_KERNEL); > if (doi_def == NULL) > return -ENOMEM; > doi_def->type = CIPSO_V4_MAP_PASS; > > ret_val = netlbl_cipsov4_add_common(info, doi_def); > if (ret_val != 0) > goto add_pass_failure; > > ret_val = cipso_v4_doi_add(doi_def, audit_info); > if (ret_val != 0) > goto add_pass_failure; > return 0; > > add_pass_failure: > cipso_v4_doi_free(doi_def); > return ret_val; > } > > [1] https://elixir.bootlin.com/linux/latest/source/net/netlabel/netlabel_cipso_v4.c#L326 > > > > -- > > > 2.18.0.huawei.25 > > > > -- > > paul moore > > www.paul-moore.com
On Mon, Jun 7, 2021 at 10:31 PM Dongliang Mu <mudongliangabcd@gmail.com> wrote: > On Tue, Jun 8, 2021 at 9:57 AM Paul Moore <paul@paul-moore.com> wrote: > > On Mon, Jun 7, 2021 at 9:19 PM Nanyong Sun <sunnanyong@huawei.com> wrote: > > > > > > Reported by syzkaller: > > > BUG: memory leak > > > unreferenced object 0xffff888105df7000 (size 64): > > > comm "syz-executor842", pid 360, jiffies 4294824824 (age 22.546s) > > > 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: > > > [<00000000e67ed558>] kmalloc include/linux/slab.h:590 [inline] > > > [<00000000e67ed558>] kzalloc include/linux/slab.h:720 [inline] > > > [<00000000e67ed558>] netlbl_cipsov4_add_std net/netlabel/netlabel_cipso_v4.c:145 [inline] > > > [<00000000e67ed558>] netlbl_cipsov4_add+0x390/0x2340 net/netlabel/netlabel_cipso_v4.c:416 > > > [<0000000006040154>] genl_family_rcv_msg_doit.isra.0+0x20e/0x320 net/netlink/genetlink.c:739 > > > [<00000000204d7a1c>] genl_family_rcv_msg net/netlink/genetlink.c:783 [inline] > > > [<00000000204d7a1c>] genl_rcv_msg+0x2bf/0x4f0 net/netlink/genetlink.c:800 > > > [<00000000c0d6a995>] netlink_rcv_skb+0x134/0x3d0 net/netlink/af_netlink.c:2504 > > > [<00000000d78b9d2c>] genl_rcv+0x24/0x40 net/netlink/genetlink.c:811 > > > [<000000009733081b>] netlink_unicast_kernel net/netlink/af_netlink.c:1314 [inline] > > > [<000000009733081b>] netlink_unicast+0x4a0/0x6a0 net/netlink/af_netlink.c:1340 > > > [<00000000d5fd43b8>] netlink_sendmsg+0x789/0xc70 net/netlink/af_netlink.c:1929 > > > [<000000000a2d1e40>] sock_sendmsg_nosec net/socket.c:654 [inline] > > > [<000000000a2d1e40>] sock_sendmsg+0x139/0x170 net/socket.c:674 > > > [<00000000321d1969>] ____sys_sendmsg+0x658/0x7d0 net/socket.c:2350 > > > [<00000000964e16bc>] ___sys_sendmsg+0xf8/0x170 net/socket.c:2404 > > > [<000000001615e288>] __sys_sendmsg+0xd3/0x190 net/socket.c:2433 > > > [<000000004ee8b6a5>] do_syscall_64+0x37/0x90 arch/x86/entry/common.c:47 > > > [<00000000171c7cee>] entry_SYSCALL_64_after_hwframe+0x44/0xae > > > > > > The memory of doi_def->map.std pointing is allocated in > > > netlbl_cipsov4_add_std, but no place has freed it. It should be > > > freed in cipso_v4_doi_free which frees the cipso DOI resource. > > > > > > Fixes: 96cb8e3313c7a ("[NetLabel]: CIPSOv4 and Unlabeled packet integration") > > > Reported-by: Hulk Robot <hulkci@huawei.com> > > > Signed-off-by: Nanyong Sun <sunnanyong@huawei.com> > > > --- > > > net/ipv4/cipso_ipv4.c | 1 + > > > 1 file changed, 1 insertion(+) > > > > Nice catch, thanks for fixing this. > > > > Acked-by: Paul Moore <paul@paul-moore.com> > > > > > diff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c > > > index d6e3a92841e3..099259fc826a 100644 > > > --- a/net/ipv4/cipso_ipv4.c > > > +++ b/net/ipv4/cipso_ipv4.c > > > @@ -471,6 +471,7 @@ void cipso_v4_doi_free(struct cipso_v4_doi *doi_def) > > > kfree(doi_def->map.std->lvl.local); > > > kfree(doi_def->map.std->cat.cipso); > > > kfree(doi_def->map.std->cat.local); > > > + kfree(doi_def->map.std); > > > break; > > > } > > > kfree(doi_def); > > Hi kernel developers, > > I doubt this patch may cause invalid free in other functions where > map.std is not allocated or initialized, such as > netlbl_cipsov4_add_local, netlbl_cipsov4_add_pass. It isn't perfectly clear to me if you are implying there is a problem with the proposed patch or not, so I thought it might help to try and add some clarity. The patch above frees the cipso_v4_doi->map.std field, which is only valid when the cipso_v4_doi->type field is equal to CIPSO_V4_MAP_TRANS. This is why the cipso_v4_doi_free() function checks the type field before freeing the cipso_v4_doi->map related fields, and why the proposed patch places the new kfree() inside that conditional code block. If we look at netlalbel_cipsov4_add_pass() we see that the first thing it does after allocating a cipso_v4_doi struct is to set the type field to CIPSO_V4_MAP_PASS. Any calls to cipso_v4_doi_free after this point will not end up calling the proposed kfree() addition due to the cipso_v4_doi->type check. We see something very similar with netlbl_cipsov4_add_local(), although in this case the type field is set to CIPSO_V4_MAP_LOCAL. This type value will also not trigger the proposed kfree(). If you are aware of any other potential issues with this patch please do let us know, but from what I can see, the two concerns you presented here are not problems with the current or proposed code.
Hello: This patch was applied to netdev/net.git (refs/heads/master): On Tue, 8 Jun 2021 09:51:58 +0800 you wrote: > Reported by syzkaller: > BUG: memory leak > unreferenced object 0xffff888105df7000 (size 64): > comm "syz-executor842", pid 360, jiffies 4294824824 (age 22.546s) > 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: > [<00000000e67ed558>] kmalloc include/linux/slab.h:590 [inline] > [<00000000e67ed558>] kzalloc include/linux/slab.h:720 [inline] > [<00000000e67ed558>] netlbl_cipsov4_add_std net/netlabel/netlabel_cipso_v4.c:145 [inline] > [<00000000e67ed558>] netlbl_cipsov4_add+0x390/0x2340 net/netlabel/netlabel_cipso_v4.c:416 > [<0000000006040154>] genl_family_rcv_msg_doit.isra.0+0x20e/0x320 net/netlink/genetlink.c:739 > [<00000000204d7a1c>] genl_family_rcv_msg net/netlink/genetlink.c:783 [inline] > [<00000000204d7a1c>] genl_rcv_msg+0x2bf/0x4f0 net/netlink/genetlink.c:800 > [<00000000c0d6a995>] netlink_rcv_skb+0x134/0x3d0 net/netlink/af_netlink.c:2504 > [<00000000d78b9d2c>] genl_rcv+0x24/0x40 net/netlink/genetlink.c:811 > [<000000009733081b>] netlink_unicast_kernel net/netlink/af_netlink.c:1314 [inline] > [<000000009733081b>] netlink_unicast+0x4a0/0x6a0 net/netlink/af_netlink.c:1340 > [<00000000d5fd43b8>] netlink_sendmsg+0x789/0xc70 net/netlink/af_netlink.c:1929 > [<000000000a2d1e40>] sock_sendmsg_nosec net/socket.c:654 [inline] > [<000000000a2d1e40>] sock_sendmsg+0x139/0x170 net/socket.c:674 > [<00000000321d1969>] ____sys_sendmsg+0x658/0x7d0 net/socket.c:2350 > [<00000000964e16bc>] ___sys_sendmsg+0xf8/0x170 net/socket.c:2404 > [<000000001615e288>] __sys_sendmsg+0xd3/0x190 net/socket.c:2433 > [<000000004ee8b6a5>] do_syscall_64+0x37/0x90 arch/x86/entry/common.c:47 > [<00000000171c7cee>] entry_SYSCALL_64_after_hwframe+0x44/0xae > > [...] Here is the summary with links: - net: ipv4: fix memory leak in netlbl_cipsov4_add_std https://git.kernel.org/netdev/net/c/d612c3f3fae2 You are awesome, thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
diff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c index d6e3a92841e3..099259fc826a 100644 --- a/net/ipv4/cipso_ipv4.c +++ b/net/ipv4/cipso_ipv4.c @@ -471,6 +471,7 @@ void cipso_v4_doi_free(struct cipso_v4_doi *doi_def) kfree(doi_def->map.std->lvl.local); kfree(doi_def->map.std->cat.cipso); kfree(doi_def->map.std->cat.local); + kfree(doi_def->map.std); break; } kfree(doi_def);
Reported by syzkaller: BUG: memory leak unreferenced object 0xffff888105df7000 (size 64): comm "syz-executor842", pid 360, jiffies 4294824824 (age 22.546s) 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: [<00000000e67ed558>] kmalloc include/linux/slab.h:590 [inline] [<00000000e67ed558>] kzalloc include/linux/slab.h:720 [inline] [<00000000e67ed558>] netlbl_cipsov4_add_std net/netlabel/netlabel_cipso_v4.c:145 [inline] [<00000000e67ed558>] netlbl_cipsov4_add+0x390/0x2340 net/netlabel/netlabel_cipso_v4.c:416 [<0000000006040154>] genl_family_rcv_msg_doit.isra.0+0x20e/0x320 net/netlink/genetlink.c:739 [<00000000204d7a1c>] genl_family_rcv_msg net/netlink/genetlink.c:783 [inline] [<00000000204d7a1c>] genl_rcv_msg+0x2bf/0x4f0 net/netlink/genetlink.c:800 [<00000000c0d6a995>] netlink_rcv_skb+0x134/0x3d0 net/netlink/af_netlink.c:2504 [<00000000d78b9d2c>] genl_rcv+0x24/0x40 net/netlink/genetlink.c:811 [<000000009733081b>] netlink_unicast_kernel net/netlink/af_netlink.c:1314 [inline] [<000000009733081b>] netlink_unicast+0x4a0/0x6a0 net/netlink/af_netlink.c:1340 [<00000000d5fd43b8>] netlink_sendmsg+0x789/0xc70 net/netlink/af_netlink.c:1929 [<000000000a2d1e40>] sock_sendmsg_nosec net/socket.c:654 [inline] [<000000000a2d1e40>] sock_sendmsg+0x139/0x170 net/socket.c:674 [<00000000321d1969>] ____sys_sendmsg+0x658/0x7d0 net/socket.c:2350 [<00000000964e16bc>] ___sys_sendmsg+0xf8/0x170 net/socket.c:2404 [<000000001615e288>] __sys_sendmsg+0xd3/0x190 net/socket.c:2433 [<000000004ee8b6a5>] do_syscall_64+0x37/0x90 arch/x86/entry/common.c:47 [<00000000171c7cee>] entry_SYSCALL_64_after_hwframe+0x44/0xae The memory of doi_def->map.std pointing is allocated in netlbl_cipsov4_add_std, but no place has freed it. It should be freed in cipso_v4_doi_free which frees the cipso DOI resource. Fixes: 96cb8e3313c7a ("[NetLabel]: CIPSOv4 and Unlabeled packet integration") Reported-by: Hulk Robot <hulkci@huawei.com> Signed-off-by: Nanyong Sun <sunnanyong@huawei.com> --- net/ipv4/cipso_ipv4.c | 1 + 1 file changed, 1 insertion(+)