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


Groups > linux.kernel > #1159911

[PATCH] kasan: Set shadow memory is not memory leaked

Path csiph.com!aioe.org!gothmog.csi.it!bofh.it!news.nic.it!robomod
From Masami Ichikawa <masami256@gmail.com>
Newsgroups linux.kernel
Subject [PATCH] kasan: Set shadow memory is not memory leaked
Date Sat, 06 Jun 2015 16:20:01 +0200
Message-ID <pyn73-2tM-5@gated-at.bofh.it> (permalink)
X-Original-To linux-kernel@vger.kernel.org
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=PM+PYR2wCwvR92x+XXxufY3LN4m2eyOUlKMFdvOHl6w=; b=dVpfdNzKCjVfguoQnVSWK3LLZs+EdcAXefaxmdjqRTlVVaYxljO4d0/CCK5fsU3nr3 4xAd+5sHUXqUK5xhby8ZS2P+5t1v3oM4z/KOOHWU4AGN3jKzVx/qHyKPw9pG1SeBLsMh TXUdqMNk9GHNyST+OsR5jkhBiNSb8m6gNBPbMmTeoCG1p3uSxChBgtxJp7oh8c7TuZK8 VL7zqdPQh8FdahFS4Lp6MLTHL97kF4sBTut4CVGZAtIdZLip6+fmCXH3JwyDLW8vL8U8 SKWVIP6qJoaNwY8uBBROSJ3ZgB8aJCrWIXe7ZS4sMDjZHKDCZZd/Y26pvQM+A/b5Vkya IEOg==
X-Received by 10.66.119.239 with SMTP id kx15mr14637181pab.156.1433599837765; Sat, 06 Jun 2015 07:10:37 -0700 (PDT)
X-Mailer git-send-email 2.4.2
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 49
Organization linux.* mail to news gateway
X-Original-Cc Masami Ichikawa <masami256@gmail.com>
X-Original-Date Sat, 6 Jun 2015 23:10:31 +0900
X-Original-Message-ID <1433599831-6196-1-git-send-email-masami256@gmail.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref aioe.org linux.kernel:1159911

Show key headers only | View raw


kmemleak reported memory leak in kasan_module_alloc() like following
log, even through kasan_free_shadow() frees that address.

unreferenced object 0xfffffbfff40ac000 (size 118784):
  comm "modprobe", pid 196, jiffies 4294878847 (age 87.590s)
  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:
    [<ffffffff81853a8e>] kmemleak_alloc+0x4e/0xc0
    [<ffffffff812868d0>] __vmalloc_node_range+0x340/0x3f0
    [<ffffffff812b0ae2>] kasan_module_alloc+0x72/0xd0
    [<ffffffff8108c908>] module_alloc+0x78/0xb0
    [<ffffffff81189474>] module_alloc_update_bounds+0x14/0x70
    [<ffffffff8118a457>] load_module+0xf67/0x4670
    [<ffffffff8118dd35>] SyS_init_module+0x1d5/0x220
    [<ffffffff8186642e>] system_call_fastpath+0x12/0x71
    [<ffffffffffffffff>] 0xffffffffffffffff

Kmemleak may think anyone take care of result of __vmalloc_node_range()
after the function.
So, it would be nice to call kmemleak_not_leak() to tell memory is not
leaked.

Signed-off-by: Masami Ichikawa <masami256@gmail.com>
---
 mm/kasan/kasan.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/mm/kasan/kasan.c b/mm/kasan/kasan.c
index 6c513a6..0ef75b9 100644
--- a/mm/kasan/kasan.c
+++ b/mm/kasan/kasan.c
@@ -430,6 +430,7 @@ int kasan_module_alloc(void *addr, size_t size)
 			__builtin_return_address(0));
 
 	if (ret) {
+		kmemleak_not_leak(ret);
 		find_vm_area(addr)->flags |= VM_KASAN;
 		return 0;
 	}
-- 
2.4.2

--
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/

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH] kasan: Set shadow memory is not memory leaked Masami Ichikawa <masami256@gmail.com> - 2015-06-06 16:20 +0200

csiph-web