Powered by Linux
Re: alloc_page leaks tracing — Semantic Matching Tool

Re: alloc_page leaks tracing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Mar 08, 2022 at 12:28:59PM -0500, Oleg Drokin wrote:
> Hello!
> 
>    I am wondering why alloc_page and friends are not considering an allocation function?
>    Found a bit of code where there was an obvious alloc_page leak that was not caught that is caught if I change alloc_page to kmalloc.
> 
>    And while trying to put the support into smatch I suddenly found the structure changed so much from the previous time I looked at it it’s very non-obvious how to add it.
> 
>    I tried adding hooks in check_free_strict.c, check_frees_argument.c, check_leaks.c, smatch_constraints_required.c, smatch_fresh_alloc.c, smatch_parse_call_math.c
>   and tried to insert it alongside kmalloc in smatch_scripts/gen_allocation_list.sh and I still cannot make
>    it work in the actual kernel code even though a modified testcase from validation/sm_memory.c works.
> 
> 
>    Any hint?

The check_leaks.c function is really limitted in the type of leaks it
looks for.  It has basically no false positives, but misses 90% of bugs.

If you're looking for leaks the right place to add it is probably in
check_unwind.c.

regards,
dan carpenter

diff --git a/check_unwind.c b/check_unwind.c
index 569792ad5a57..7ef040d2ca59 100644
--- a/check_unwind.c
+++ b/check_unwind.c
@@ -92,6 +92,10 @@ static struct ref_func_info func_table[] = {
 
 	{ "ieee80211_alloc_hw", ALLOC,  -1, "$", &valid_ptr_min_sval, &valid_ptr_max_sval },
 	{ "ieee80211_free_hw",  RELEASE, 0, "$" },
+
+	{ "alloc_pages", ALLOC,  -1, "$", &valid_ptr_min_sval, &valid_ptr_max_sval },
+	{ "__get_free_pages", ALLOC, -1, "$", &valid_ptr_min_sval, &valid_ptr_max_sval },
+	{ "free_pages", RELEASE, 0, "$" },
 };
 
 static struct smatch_state *unmatched_state(struct sm_state *sm)




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux