Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1273980 > unrolled thread

[RFC PATCH] iommu/amd: make kmemleak ignore the 'irq_remap_table' object

Started byMichael Wang <yun.wang@profitbricks.com>
First post2015-11-20 12:10 +0100
Last post2015-11-25 16:20 +0100
Articles 6 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [RFC PATCH] iommu/amd: make kmemleak ignore the 'irq_remap_table'  object Michael Wang <yun.wang@profitbricks.com> - 2015-11-20 12:10 +0100
    [RFC PATCH v2] iommu/amd: gray the 'irq_remap_table' object for  kmemleak Michael Wang <yun.wang@profitbricks.com> - 2015-11-20 12:40 +0100
      Re: [RFC PATCH v2] iommu/amd: gray the 'irq_remap_table' object for  kmemleak Michael Wang <yun.wang@profitbricks.com> - 2015-11-20 13:40 +0100
      Re: [RFC PATCH v2] iommu/amd: gray the 'irq_remap_table' object for  kmemleak Michael Wang <yun.wang@profitbricks.com> - 2015-11-25 12:20 +0100
      Re: [RFC PATCH v2] iommu/amd: gray the 'irq_remap_table' object for  kmemleak Joerg Roedel <joro@8bytes.org> - 2015-11-25 16:10 +0100
        Re: [RFC PATCH v2] iommu/amd: gray the 'irq_remap_table' object for  kmemleak Michael Wang <yun.wang@profitbricks.com> - 2015-11-25 16:20 +0100

#1273980 — [RFC PATCH] iommu/amd: make kmemleak ignore the 'irq_remap_table' object

FromMichael Wang <yun.wang@profitbricks.com>
Date2015-11-20 12:10 +0100
Subject[RFC PATCH] iommu/amd: make kmemleak ignore the 'irq_remap_table' object
Message-ID<qwRJL-6qF-5@gated-at.bofh.it>
The kmemleak testing on 3.18.24 show:

unreferenced object 0xffff880233ff9010 (size 16):
  comm "swapper/0", pid 1, jiffies 4294937440 (age 2010.490s)
  hex dump (first 16 bytes):
    0a 0a 00 00 20 00 00 00 00 44 fb 33 02 88 ff ff  .... ....D.3....
  backtrace:
    [<ffffffff8118192d>] create_object+0x10d/0x2d0
    [<ffffffff815c2d4b>] kmemleak_alloc+0x5b/0xc0
    [<ffffffff8116dd19>] kmem_cache_alloc_trace+0xb9/0x160
    [<ffffffff814ffe51>] get_irq_table+0x151/0x380

This is caused by the 'irq_lookup_table' was allocated with
__get_free_pages() which won't create kmemleak object, thus it's
pointers won't be count as referencing in kmemleak scanning.

The 'irq_remap_table' allocated won't be freed after initialized,
doesn't make sense to let kmemleak scan it.

This patch mark the 'irq_remap_table' object as 'ignored' to
stop the 'false positives' report.

Signed-off-by: Michael Wang <yun.wang@profitbricks.com>
---
 drivers/iommu/amd_iommu.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index 8b2be1e..87a1a88 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -3603,6 +3603,7 @@ static struct irq_remap_table *get_irq_table(u16 devid, bool ioapic)
 	}
 
 	irq_lookup_table[devid] = table;
+	kmemleak_ignore(table);
 	set_dte_irq_entry(devid, table);
 	iommu_flush_dte(iommu, devid);
 	if (devid != alias) {
-- 
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1273993 — [RFC PATCH v2] iommu/amd: gray the 'irq_remap_table' object for kmemleak

FromMichael Wang <yun.wang@profitbricks.com>
Date2015-11-20 12:40 +0100
Subject[RFC PATCH v2] iommu/amd: gray the 'irq_remap_table' object for kmemleak
Message-ID<qwScO-6B6-7@gated-at.bofh.it>
In reply to#1273980
The kmemleak testing on 3.18.24 show:

unreferenced object 0xffff880233ff9010 (size 16):
  comm "swapper/0", pid 1, jiffies 4294937440 (age 2010.490s)
  hex dump (first 16 bytes):
    0a 0a 00 00 20 00 00 00 00 44 fb 33 02 88 ff ff  .... ....D.3....
  backtrace:
    [<ffffffff8118192d>] create_object+0x10d/0x2d0
    [<ffffffff815c2d4b>] kmemleak_alloc+0x5b/0xc0
    [<ffffffff8116dd19>] kmem_cache_alloc_trace+0xb9/0x160
    [<ffffffff814ffe51>] get_irq_table+0x151/0x380

This is caused by the 'irq_lookup_table' was allocated with
__get_free_pages() which won't create kmemleak object, thus it's
pointers won't be count as referencing 'irq_remap_table' in
kmemleak scan.

The 'irq_remap_table' won't be freed after initialized, doesn't
make sense to check it's leaking.

This patch mark the 'irq_remap_table' object as 'gray' to stop
the 'false positives' report.

Signed-off-by: Michael Wang <yun.wang@profitbricks.com>
---
v2:
  Use kmemleak_not_leak() instead of kmemleak_ignore() since
  the 'irq_remap_table' itself also contain pointer.

 drivers/iommu/amd_iommu.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index 8b2be1e..87a1a88 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -3603,6 +3603,7 @@ static struct irq_remap_table *get_irq_table(u16 devid, bool ioapic)
 	}
 
 	irq_lookup_table[devid] = table;
+	kmemleak_not_leak(table);
 	set_dte_irq_entry(devid, table);
 	iommu_flush_dte(iommu, devid);
 	if (devid != alias) {
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1274034 — Re: [RFC PATCH v2] iommu/amd: gray the 'irq_remap_table' object for kmemleak

FromMichael Wang <yun.wang@profitbricks.com>
Date2015-11-20 13:40 +0100
SubjectRe: [RFC PATCH v2] iommu/amd: gray the 'irq_remap_table' object for kmemleak
Message-ID<qwT8S-7d6-5@gated-at.bofh.it>
In reply to#1273993

On 11/20/2015 12:33 PM, Michael Wang wrote:
> The kmemleak testing on 3.18.24 show:
> 
> unreferenced object 0xffff880233ff9010 (size 16):
>   comm "swapper/0", pid 1, jiffies 4294937440 (age 2010.490s)
>   hex dump (first 16 bytes):
>     0a 0a 00 00 20 00 00 00 00 44 fb 33 02 88 ff ff  .... ....D.3....
>   backtrace:
>     [<ffffffff8118192d>] create_object+0x10d/0x2d0
>     [<ffffffff815c2d4b>] kmemleak_alloc+0x5b/0xc0
>     [<ffffffff8116dd19>] kmem_cache_alloc_trace+0xb9/0x160
>     [<ffffffff814ffe51>] get_irq_table+0x151/0x380
> 
> This is caused by the 'irq_lookup_table' was allocated with
> __get_free_pages() which won't create kmemleak object, thus it's
> pointers won't be count as referencing 'irq_remap_table' in
> kmemleak scan.
> 
> The 'irq_remap_table' won't be freed after initialized, doesn't
> make sense to check it's leaking.
> 
> This patch mark the 'irq_remap_table' object as 'gray' to stop
> the 'false positives' report.
> 
> Signed-off-by: Michael Wang <yun.wang@profitbricks.com>

Reported-by: Danil Kipnis <danil.kipnis@profitbricks.com>

Regards,
Michael Wang

> ---
> v2:
>   Use kmemleak_not_leak() instead of kmemleak_ignore() since
>   the 'irq_remap_table' itself also contain pointer.
> 
>  drivers/iommu/amd_iommu.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
> index 8b2be1e..87a1a88 100644
> --- a/drivers/iommu/amd_iommu.c
> +++ b/drivers/iommu/amd_iommu.c
> @@ -3603,6 +3603,7 @@ static struct irq_remap_table *get_irq_table(u16 devid, bool ioapic)
>  	}
>  
>  	irq_lookup_table[devid] = table;
> +	kmemleak_not_leak(table);
>  	set_dte_irq_entry(devid, table);
>  	iommu_flush_dte(iommu, devid);
>  	if (devid != alias) {
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1277247 — Re: [RFC PATCH v2] iommu/amd: gray the 'irq_remap_table' object for kmemleak

FromMichael Wang <yun.wang@profitbricks.com>
Date2015-11-25 12:20 +0100
SubjectRe: [RFC PATCH v2] iommu/amd: gray the 'irq_remap_table' object for kmemleak
Message-ID<qyGhd-5xi-49@gated-at.bofh.it>
In reply to#1273993
Hi, Joery

On 11/20/2015 12:33 PM, Michael Wang wrote:
> The kmemleak testing on 3.18.24 show:
> 
> unreferenced object 0xffff880233ff9010 (size 16):
>   comm "swapper/0", pid 1, jiffies 4294937440 (age 2010.490s)
>   hex dump (first 16 bytes):
>     0a 0a 00 00 20 00 00 00 00 44 fb 33 02 88 ff ff  .... ....D.3....
>   backtrace:
>     [<ffffffff8118192d>] create_object+0x10d/0x2d0
>     [<ffffffff815c2d4b>] kmemleak_alloc+0x5b/0xc0
>     [<ffffffff8116dd19>] kmem_cache_alloc_trace+0xb9/0x160
>     [<ffffffff814ffe51>] get_irq_table+0x151/0x380
> 
> This is caused by the 'irq_lookup_table' was allocated with
> __get_free_pages() which won't create kmemleak object, thus it's
> pointers won't be count as referencing 'irq_remap_table' in
> kmemleak scan.
> 
> The 'irq_remap_table' won't be freed after initialized, doesn't
> make sense to check it's leaking.
> 
> This patch mark the 'irq_remap_table' object as 'gray' to stop
> the 'false positives' report.

Any comments on this one?

Regards,
Michael Wang

> 
> Signed-off-by: Michael Wang <yun.wang@profitbricks.com>
> ---
> v2:
>   Use kmemleak_not_leak() instead of kmemleak_ignore() since
>   the 'irq_remap_table' itself also contain pointer.
> 
>  drivers/iommu/amd_iommu.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
> index 8b2be1e..87a1a88 100644
> --- a/drivers/iommu/amd_iommu.c
> +++ b/drivers/iommu/amd_iommu.c
> @@ -3603,6 +3603,7 @@ static struct irq_remap_table *get_irq_table(u16 devid, bool ioapic)
>  	}
>  
>  	irq_lookup_table[devid] = table;
> +	kmemleak_not_leak(table);
>  	set_dte_irq_entry(devid, table);
>  	iommu_flush_dte(iommu, devid);
>  	if (devid != alias) {
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1277449 — Re: [RFC PATCH v2] iommu/amd: gray the 'irq_remap_table' object for kmemleak

FromJoerg Roedel <joro@8bytes.org>
Date2015-11-25 16:10 +0100
SubjectRe: [RFC PATCH v2] iommu/amd: gray the 'irq_remap_table' object for kmemleak
Message-ID<qyJRL-7Wr-1@gated-at.bofh.it>
In reply to#1273993
On Fri, Nov 20, 2015 at 12:33:50PM +0100, Michael Wang wrote:
> The kmemleak testing on 3.18.24 show:
> 
> unreferenced object 0xffff880233ff9010 (size 16):
>   comm "swapper/0", pid 1, jiffies 4294937440 (age 2010.490s)
>   hex dump (first 16 bytes):
>     0a 0a 00 00 20 00 00 00 00 44 fb 33 02 88 ff ff  .... ....D.3....
>   backtrace:
>     [<ffffffff8118192d>] create_object+0x10d/0x2d0
>     [<ffffffff815c2d4b>] kmemleak_alloc+0x5b/0xc0
>     [<ffffffff8116dd19>] kmem_cache_alloc_trace+0xb9/0x160
>     [<ffffffff814ffe51>] get_irq_table+0x151/0x380
> 
> This is caused by the 'irq_lookup_table' was allocated with
> __get_free_pages() which won't create kmemleak object, thus it's
> pointers won't be count as referencing 'irq_remap_table' in
> kmemleak scan.

Isn't it better to allocate the kmemleak object manually instead of
ignoring all irq-table pointers? With this patch we might not notice any
real leak of irq-tables.



	Joerg

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1277467 — Re: [RFC PATCH v2] iommu/amd: gray the 'irq_remap_table' object for kmemleak

FromMichael Wang <yun.wang@profitbricks.com>
Date2015-11-25 16:20 +0100
SubjectRe: [RFC PATCH v2] iommu/amd: gray the 'irq_remap_table' object for kmemleak
Message-ID<qyK1s-7ZU-33@gated-at.bofh.it>
In reply to#1277449
On 11/25/2015 04:08 PM, Joerg Roedel wrote:
> On Fri, Nov 20, 2015 at 12:33:50PM +0100, Michael Wang wrote:
>> The kmemleak testing on 3.18.24 show:
>>
>> unreferenced object 0xffff880233ff9010 (size 16):
>>   comm "swapper/0", pid 1, jiffies 4294937440 (age 2010.490s)
>>   hex dump (first 16 bytes):
>>     0a 0a 00 00 20 00 00 00 00 44 fb 33 02 88 ff ff  .... ....D.3....
>>   backtrace:
>>     [<ffffffff8118192d>] create_object+0x10d/0x2d0
>>     [<ffffffff815c2d4b>] kmemleak_alloc+0x5b/0xc0
>>     [<ffffffff8116dd19>] kmem_cache_alloc_trace+0xb9/0x160
>>     [<ffffffff814ffe51>] get_irq_table+0x151/0x380
>>
>> This is caused by the 'irq_lookup_table' was allocated with
>> __get_free_pages() which won't create kmemleak object, thus it's
>> pointers won't be count as referencing 'irq_remap_table' in
>> kmemleak scan.
> 
> Isn't it better to allocate the kmemleak object manually instead of
> ignoring all irq-table pointers? With this patch we might not notice any
> real leak of irq-tables.

We've considered that too, but found that the irq-tables is not
dynamically alloc/free, they won't be freed once initialized, so there
is no leaking for such object :-)

Regards,
Michael Wang

> 
> 
> 
> 	Joerg
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web