public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] efivarfs: fix memory leak in efivarfs_create()
@ 2020-10-23 11:54 Vamshi K Sthambamkadi
  2020-10-26  7:15 ` Ard Biesheuvel
  2020-11-17 17:47 ` [tip: efi/urgent] " tip-bot2 for Vamshi K Sthambamkadi
  0 siblings, 2 replies; 3+ messages in thread
From: Vamshi K Sthambamkadi @ 2020-10-23 11:54 UTC (permalink / raw)
  To: matthew.garrett, jk, ardb; +Cc: linux-efi, linux-kernel

kmemleak report:
  unreferenced object 0xffff9b8915fcb000 (size 4096):
  comm "efivarfs.sh", pid 2360, jiffies 4294920096 (age 48.264s)
  hex dump (first 32 bytes):
    2d 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:
    [<00000000cc4d897c>] kmem_cache_alloc_trace+0x155/0x4b0
    [<000000007d1dfa72>] efivarfs_create+0x6e/0x1a0
    [<00000000e6ee18fc>] path_openat+0xe4b/0x1120
    [<000000000ad0414f>] do_filp_open+0x91/0x100
    [<00000000ce93a198>] do_sys_openat2+0x20c/0x2d0
    [<000000002a91be6d>] do_sys_open+0x46/0x80
    [<000000000a854999>] __x64_sys_openat+0x20/0x30
    [<00000000c50d89c9>] do_syscall_64+0x38/0x90
    [<00000000cecd6b5f>] entry_SYSCALL_64_after_hwframe+0x44/0xa9

In efivarfs_create(), inode->i_private is setup with efivar_entry
object which is never freed.

Signed-off-by: Vamshi K Sthambamkadi <vamshi.k.sthambamkadi@gmail.com>
---
 fs/efivarfs/super.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/efivarfs/super.c b/fs/efivarfs/super.c
index 15880a6..f943fd0 100644
--- a/fs/efivarfs/super.c
+++ b/fs/efivarfs/super.c
@@ -21,6 +21,7 @@ LIST_HEAD(efivarfs_list);
 static void efivarfs_evict_inode(struct inode *inode)
 {
 	clear_inode(inode);
+	kfree(inode->i_private);
 }
 
 static const struct super_operations efivarfs_ops = {
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] efivarfs: fix memory leak in efivarfs_create()
  2020-10-23 11:54 [PATCH] efivarfs: fix memory leak in efivarfs_create() Vamshi K Sthambamkadi
@ 2020-10-26  7:15 ` Ard Biesheuvel
  2020-11-17 17:47 ` [tip: efi/urgent] " tip-bot2 for Vamshi K Sthambamkadi
  1 sibling, 0 replies; 3+ messages in thread
From: Ard Biesheuvel @ 2020-10-26  7:15 UTC (permalink / raw)
  To: Vamshi K Sthambamkadi
  Cc: Matthew Garrett, Jeremy Kerr, linux-efi,
	Linux Kernel Mailing List

On Fri, 23 Oct 2020 at 13:54, Vamshi K Sthambamkadi
<vamshi.k.sthambamkadi@gmail.com> wrote:
>
> kmemleak report:
>   unreferenced object 0xffff9b8915fcb000 (size 4096):
>   comm "efivarfs.sh", pid 2360, jiffies 4294920096 (age 48.264s)
>   hex dump (first 32 bytes):
>     2d 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:
>     [<00000000cc4d897c>] kmem_cache_alloc_trace+0x155/0x4b0
>     [<000000007d1dfa72>] efivarfs_create+0x6e/0x1a0
>     [<00000000e6ee18fc>] path_openat+0xe4b/0x1120
>     [<000000000ad0414f>] do_filp_open+0x91/0x100
>     [<00000000ce93a198>] do_sys_openat2+0x20c/0x2d0
>     [<000000002a91be6d>] do_sys_open+0x46/0x80
>     [<000000000a854999>] __x64_sys_openat+0x20/0x30
>     [<00000000c50d89c9>] do_syscall_64+0x38/0x90
>     [<00000000cecd6b5f>] entry_SYSCALL_64_after_hwframe+0x44/0xa9
>
> In efivarfs_create(), inode->i_private is setup with efivar_entry
> object which is never freed.
>
> Signed-off-by: Vamshi K Sthambamkadi <vamshi.k.sthambamkadi@gmail.com>

Queued as a fix, thanks!

> ---
>  fs/efivarfs/super.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/fs/efivarfs/super.c b/fs/efivarfs/super.c
> index 15880a6..f943fd0 100644
> --- a/fs/efivarfs/super.c
> +++ b/fs/efivarfs/super.c
> @@ -21,6 +21,7 @@ LIST_HEAD(efivarfs_list);
>  static void efivarfs_evict_inode(struct inode *inode)
>  {
>         clear_inode(inode);
> +       kfree(inode->i_private);
>  }
>
>  static const struct super_operations efivarfs_ops = {
> --
> 2.7.4
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tip: efi/urgent] efivarfs: fix memory leak in efivarfs_create()
  2020-10-23 11:54 [PATCH] efivarfs: fix memory leak in efivarfs_create() Vamshi K Sthambamkadi
  2020-10-26  7:15 ` Ard Biesheuvel
@ 2020-11-17 17:47 ` tip-bot2 for Vamshi K Sthambamkadi
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Vamshi K Sthambamkadi @ 2020-11-17 17:47 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: stable, Vamshi K Sthambamkadi, Ard Biesheuvel, x86, linux-kernel

The following commit has been merged into the efi/urgent branch of tip:

Commit-ID:     fe5186cf12e30facfe261e9be6c7904a170bd822
Gitweb:        https://git.kernel.org/tip/fe5186cf12e30facfe261e9be6c7904a170bd822
Author:        Vamshi K Sthambamkadi <vamshi.k.sthambamkadi@gmail.com>
AuthorDate:    Fri, 23 Oct 2020 17:24:39 +05:30
Committer:     Ard Biesheuvel <ardb@kernel.org>
CommitterDate: Mon, 26 Oct 2020 08:15:24 +01:00

efivarfs: fix memory leak in efivarfs_create()

kmemleak report:
  unreferenced object 0xffff9b8915fcb000 (size 4096):
  comm "efivarfs.sh", pid 2360, jiffies 4294920096 (age 48.264s)
  hex dump (first 32 bytes):
    2d 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:
    [<00000000cc4d897c>] kmem_cache_alloc_trace+0x155/0x4b0
    [<000000007d1dfa72>] efivarfs_create+0x6e/0x1a0
    [<00000000e6ee18fc>] path_openat+0xe4b/0x1120
    [<000000000ad0414f>] do_filp_open+0x91/0x100
    [<00000000ce93a198>] do_sys_openat2+0x20c/0x2d0
    [<000000002a91be6d>] do_sys_open+0x46/0x80
    [<000000000a854999>] __x64_sys_openat+0x20/0x30
    [<00000000c50d89c9>] do_syscall_64+0x38/0x90
    [<00000000cecd6b5f>] entry_SYSCALL_64_after_hwframe+0x44/0xa9

In efivarfs_create(), inode->i_private is setup with efivar_entry
object which is never freed.

Cc: <stable@vger.kernel.org>
Signed-off-by: Vamshi K Sthambamkadi <vamshi.k.sthambamkadi@gmail.com>
Link: https://lore.kernel.org/r/20201023115429.GA2479@cosmos
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
 fs/efivarfs/super.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/efivarfs/super.c b/fs/efivarfs/super.c
index 15880a6..f943fd0 100644
--- a/fs/efivarfs/super.c
+++ b/fs/efivarfs/super.c
@@ -21,6 +21,7 @@ LIST_HEAD(efivarfs_list);
 static void efivarfs_evict_inode(struct inode *inode)
 {
 	clear_inode(inode);
+	kfree(inode->i_private);
 }
 
 static const struct super_operations efivarfs_ops = {

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-11-17 17:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-23 11:54 [PATCH] efivarfs: fix memory leak in efivarfs_create() Vamshi K Sthambamkadi
2020-10-26  7:15 ` Ard Biesheuvel
2020-11-17 17:47 ` [tip: efi/urgent] " tip-bot2 for Vamshi K Sthambamkadi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox