genetlink: prevent memory leak in netlbl_unlabel_defconf
Subsystems (5)
PATCH 1/1 genetlink: prevent memory leak in netlbl_unlabel_defconf
In netlbl_unlabel_defconf if netlbl_domhsh_add_default fails the allocated entry should be released.
--- net/netlabel/netlabel_unlabeled.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/netlabel/netlabel_unlabeled.c +3 -1
@@ -1541,8 +1541,10 @@ int __init netlbl_unlabel_defconf(void) entry->family =AF_UNSPEC ; entry->def.type =NETLBL_NLTYPE_UNLABELED ; ret_val =netlbl_domhsh_add_default (entry, &audit_info); -if (ret_val !=0 ) +if (ret_val !=0 ) { +kfree (entry);return ret_val; + }netlbl_unlabel_acceptflg_set (1 , &audit_info);
Signature · 1 line
2.17.1
Quoted 8 lines · Navid Emamdoost
In
netlbl_unlabel_defconfifnetlbl_domhsh_add_defaultfails the allocated entry should be released.Signed-off-by Navid Emamdoost <[email protected]>--- net/netlabel/netlabel_unlabeled.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
It is worth noting that netlbl_unlabel_defconf() is only called during kernel boot by netlbl_init() and if netlbl_unlabel_defconf() returns an error code the system panics, so this isn't currently a very practical concern.
That said, netlbl_unlabel_defconf() *should* clean up here just on principal if nothing else.
Quoted 19 lines
net/netlabel/netlabel_unlabeled.c +3
-2@@ -1541,8 +1541,10 @@ int __init netlbl_unlabel_defconf(void) entry->family =AF_UNSPEC ; entry->def.type =NETLBL_NLTYPE_UNLABELED ; ret_val =netlbl_domhsh_add_default (entry, &audit_info); -if (ret_val !=0 ) +if (ret_val !=0 ) { +kfree (entry);return ret_val; + }netlbl_unlabel_acceptflg_set (1 , &audit_info); --2.17.1
Signature · 2 lines
paul moore www.paul-moore.com
Quoted 2 lines
Quoted 2 lines
In
netlbl_unlabel_defconfifnetlbl_domhsh_add_defaultfails the allocated entry should be released.
…
Quoted 2 lines
That said,
netlbl_unlabel_defconf()*should* clean up here just on principal if nothing else.
How do you think about to add the tag “Fixes” then?
Regards,
Markus
Paul Moore
maintainerQuoted 8 lines · Markus Elfring
Quoted 3 lines
Quoted 3 lines
In
netlbl_unlabel_defconfifnetlbl_domhsh_add_defaultfails the allocated entry should be released.…
Quoted 2 lines
That said,
netlbl_unlabel_defconf()*should* clean up here just on principal if nothing else.How do you think about to add the tag “Fixes” then?
From what I've seen the "Fixes" tag is typically used by people who are backporting patches, e.g. the -stable folks, to help decide what they need to backport. As I mentioned in my previous email this missing free doesn't actually manifest itself as a practical leak on any of the existing kernels so there isn't a need to backport this patch. For that reason I would probably skip the "Fixes" metadata here, but I don't feel strongly enough about it to object if others want it. FWIW, I play things very conservatively when talking about backporting patches to stable kernels; if it doesn't fix a serious user-visible bug it shouldn't be backported IMHO.
This patch is more of a conceptual fix than a practical fix. Not that there is anything wrong with this patch, I just think it isn't as critical as most people would think from reading "memory leak" in the subject line. Yes, there is a memory leak, but the kernel panics soon after so it's a bit moot. Further, even if the panic was somehow skipped (?) the memory leak only happens once during boot; the failed initialization is undoubtedly going to be far more damaging to the system than a few lost bytes of memory.
Signature · 2 lines
paul moore www.paul-moore.com
David Miller
maintainerFrom: Paul Moore <[email protected]>
Date: Fri, 27 Sep 2019 10:48:54 -0400
Quoted 3 lines
From what I've seen the "Fixes" tag is typically used by people who are backporting patches, e.g. the -stable folks, to help decide what they need to backport.
Fixes: tags say what commit introduced the code being fixed, whether it manifests in a real problem or not.
It has nothing directly to do with -stable and exists in it's own right whether a change gets backported to -stable or not.